static-code-analysis Questions

2

Solved

So I have an issue with SonarLint that I am not sure how to approach. let's say I have a class with a method public class Class(RemoteContext context) RemoteContext context = context; public ...
Cyrene asked 28/11, 2017 at 14:50

1

Solved

In Python, leaving a trailing comma like this is, of course, not a SyntaxError: In [1]: x = 1 , In [2]: x Out[2]: (1,) In [3]: type(x) Out[3]: tuple But, at the same time, if the trailing comm...
Cambrai asked 22/6, 2017 at 13:33

4

Solved

During one of the recent code reviews, I've stumbled upon the problem that was not immediately easy to spot - there was assertTrue() used instead of assertEqual() that basically resulted into a tes...
Intervention asked 11/4, 2017 at 16:47

1

Solved

I'd like to use a custom helper to simplify argument validation, something like this. public static void ThrowIfNull(this object value, string parameterName) { if (value == null) { throw new Ar...
Agamic asked 16/5, 2017 at 15:16

1

On a recent bug hunt, I found an issue with returning a pointer to a member of a temporary variable. The offending (simplified) code was: struct S { S(int i) : i(i) {} int i; int* ptr() { retur...
Vibrate asked 8/11, 2016 at 21:16

1

Solved

When a rule is defined to be fixable, fixable key should be specified which can have code or whitespace values: fixable (string) is either "code" or "whitespace" if the --fix option on the comma...

1

Solved

It is quite a common mistake to mix up the datetime.strptime() format string and date string arguments using: datetime.strptime("%B %d, %Y", "January 8, 2014") instead of the other way around: ...
Zingaro asked 1/7, 2016 at 14:26

3

I'm trying to get msbuild to output code analysis info like it does in VS. I have a configuration for my project called "CodeAnalysis" in VS that is set up to run code analysis on build (with the m...

1

Solved

I'm using Cppcheck to manage my code. I have the following function: bool my_function(std::string my_string) const { return 0 == my_string.compare("Some text"); // line 3 } To my surprise, I ge...
Corpuz asked 14/6, 2016 at 15:28

1

Solved

Recently cppcheck raised an error in some C code, that has the structure: ((void)(value_prev = value), value = new_value()) In most cases this can be split onto 2 lines, however there are some c...
Sixtynine asked 30/4, 2016 at 2:15

1

During a code review, i found source code like this: void f_odd(std::string &className, std::string &testName) { if (className.find("::") != std::string::npos) { testName = className.su...
Acquire asked 27/4, 2016 at 12:10

1

Solved

The Story: Currently, we are extending the recommended ESLint configuration: { "extends": "eslint:recommended", ... "plugins": [ "angular", "jasmine", "protractor" ], "rules": { "no-mult...
Pasteboard asked 26/3, 2016 at 17:42

1

Solved

This cppcheck --enable=style --inconclusive --check-config --xml --xml-version=2 -v -I.. -I../mocks -I../gmock -I../gtest -DUNIT_TEST ../src results in this <?xml version="1.0" encoding="UT...
Admirable asked 19/10, 2015 at 15:22

1

Solved

I recently installed Visual Sudio 2015 and was able to run code analysis for the solution with the following command: msbuild.exe MySolution.sln /p:RunCodeAnalysis=true where /p:RunCodeAnalysis=...
Sternson asked 23/11, 2015 at 15:34

4

Solved

Does anyone know of a free tool, similar to what is built into Visual Studio 2010 for managed code, that can do analysis of unmanaged, MFC C++ code and give metrics (lines of code, dependency...
Tipton asked 23/2, 2012 at 20:11

1

Solved

I am using cppcheck for static analysis. To accelerate review process I want to set up cppcheck to look for some custom rules, for example to check if geter functions defined as a const. If anyone...
Abfarad asked 20/6, 2015 at 13:59

3

Solved

I installed the Cppcheck tool for static code analysis of my C++ project and got the feeling that it performs poorly. For example, can anyone tell me why Cppcheck is unable to find an array out-of-...
Marianamariand asked 15/8, 2012 at 9:4

1

What I am trying to achieve is integrate SonarQube analysis into the build process, so that whenever mvn clean install is run, the code is analyzed with SonarQube. We want to use it for local analy...
Affright asked 17/3, 2015 at 12:54

2

I found several questions about this topic, and all of them with lot of references, but still I don't have a clear idea about that, because most of the references speak about concrete tools and not...
Isomorphism asked 14/10, 2012 at 17:21

4

Solved

When I program in python, I find using pylint very useful. However, when I program in R, there is nothing comparable. As a small side project, I thought it would be fun to try and write a small l...
Demoniac asked 1/3, 2011 at 20:47

1

Solved

Consider this piece of code: def test(): """This line is longer than 80 chars, but, for me this is ok inside a DOCSTRING, this one is shorter. """ if 'This is tooooooooooooooooooooooooooooooo...
Ulberto asked 31/12, 2014 at 11:51

3

Solved

Goal: Issue a warning in case an @author tag is used anywhere inside the .js files in the project. Question: Is it something that jshint or other static code check tools can help with? If not, ...
Joab asked 3/12, 2014 at 16:46

2

Solved

In the Python world there are multiple static code analysis tools that can be easily extended with custom checks via writing plugins or extensions, for example: pylint flake8 In the JavaScript ...
Dilapidation asked 3/12, 2014 at 17:31

1

Solved

Consider the following code: from bs4 import BeautifulSoup data = "<test>test text</test>" soup = BeautifulSoup(data) print(soup.find(text=re.compile(r'test$'))) It is missing an i...
Hecht asked 8/12, 2014 at 23:51

4

Solved

Consider the following code snippet: import MySQLdb def get_data(id): db = MySQLdb.connect(db='TEST') cursor = db.cursor() cursor.execute("SELECT * FROM TEST WHERE ID = '%s'" % id) return cu...
Latisha asked 10/12, 2014 at 13:37

© 2022 - 2024 — McMap. All rights reserved.