Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static analysis alarm by cppcheck #1711

Closed
ipodipad opened this issue Aug 20, 2019 · 1 comment
Closed

static analysis alarm by cppcheck #1711

ipodipad opened this issue Aug 20, 2019 · 1 comment
Labels
kind: bug solution: invalid the issue is not related to the library

Comments

@ipodipad
Copy link

  • What is the issue you have?
    static analysis warning by cppcheck

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

File name Line Offset Issue Severity Rule Debt Is New
json.hpp 1 0 Too many #ifdef configurations - cppcheck only checks 12 of 27 configurations. Use --force to check all configurations. INFO cppcheck:toomanyconfigs 5min Yes
json.hpp 2607 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2610 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2614 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2617 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2620 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2623 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2645 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2689 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 2697 0 Class 'input_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 9406 0 Class 'json_ref' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 9410 0 Class 'json_ref' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 9414 0 Class 'json_ref' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 9578 0 Class 'output_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 9581 0 Class 'output_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 9584 0 Class 'output_adapter' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 13962 0 Class 'basic_json' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 13986 0 Class 'basic_json' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 14530 0 Class 'basic_json' has a constructor with 1 argument that is not explicit. MAJOR cppcheck:noExplicitConstructor 5min Yes
json.hpp 8565 0 Function parameter 'token' should be passed by const reference. MINOR cppcheck:passedByValue 5min Yes
json.hpp 8628 0 Function parameter 'token' should be passed by const reference. MINOR cppcheck:passedByValue 5min Yes
json.hpp 9237 0 Function parameter 's' should be passed by const reference. MINOR cppcheck:passedByValue 5min Yes
json.hpp 14679 0 Function parameter 'other' should be passed by const reference. MINOR cppcheck:passedByValue 5min Yes
json.hpp 13168 0 Redundant code: Found a statement that begins with string constant. MINOR cppcheck:constStatement 5min Yes
json.hpp 13154 0 Redundant code: Found a statement that begins with string constant. MINOR cppcheck:constStatement 5min Yes
  • What is the expected behavior?
    N/A

  • And what is the actual behavior instead?
    N/A

  • Which compiler and operating system are you using? Is it a supported compiler?
    gcc 4.8

  • Did you use a released version of the library or the version from the develop branch?
    20190820 14:43 develop branch

  • If you experience a compilation error: can you compile and run the unit tests?

@nlohmann
Copy link
Owner

I am running cppcheck myself and observed the same warnings. However, there is little we can do about this:

  • cppcheck:toomanyconfigs - this can be "fixed" by allowing cppcheck to run through all configs
  • cppcheck:noExplicitConstructor - this is a feature and allows to write code like json foo = "bar";
  • cppcheck:passedByValue - I could not find the exact lines, but I think this is a false positive: either the type is something like an int where using a const reference makes little sense, or the variable is moved later on. Could you check these lines whether you think this can be fixed?
  • cppcheck:constStatement - this is a false positive

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants