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

Ignores some cppcheck warnings #1876

Closed
wants to merge 4 commits into from

Conversation

Xav83
Copy link
Contributor

@Xav83 Xav83 commented Dec 20, 2019

This Pull Request adds comments made so that, when using inline-suppr option, cppcheck will ignore the warnings about not using explicit keyword when a constructor has one parameter.

It addresses some of the warnings in #1759


Pull request checklist

Read the Contribution Guidelines for detailed information.

  • Changes are described in the pull request, or an existing issue is referenced.
  • The test suite compiles and runs without error.
  • Code coverage is 100%. Test cases can be added by editing the test suite.
  • The source code is amalgamated; that is, after making changes to the sources in the include/nlohmann directory, run make amalgamate to create the single-header file single_include/nlohmann/json.hpp. The whole process is described here.

Please don't

  • The C++11 support varies between different compilers and versions. Please note the list of supported compilers. Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with #ifdefs or other means.
  • Specifically, I am aware of compilation problems with Microsoft Visual Studio (there even is an issue label for these kind of bugs). I understand that even in 2016, complete C++11 support isn't there yet. But please also understand that I do not want to drop features or uglify the code just to make Microsoft's sub-standard compiler happy. The past has shown that there are ways to express the functionality such that the code compiles with the most recent MSVC - unfortunately, this is not the main objective of the project.
  • Please refrain from proposing changes that would break JSON conformance. If you propose a conformant extension of JSON to be supported by the library, please motivate this extension.
  • Please do not open pull requests that address multiple issues.

…tructor with one parameter in output_adapters.hpp.
…tructor with one parameter in input_adapters.hpp.
@Xav83 Xav83 requested a review from nlohmann as a code owner December 20, 2019 22:11
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e8678d3 on Xav83:ignoreCppcheckWarnings into bde5712 on nlohmann:develop.

Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly do not really like these changes. Instead of marking every single constructor, I would rather set the respective command-line argument to the make cppcheck target.

@Xav83
Copy link
Contributor Author

Xav83 commented Dec 23, 2019

Hi @nlohmann 😃

First of all, thanks for your interest in this Pull Request. 👍

I agree with you that this is not something really elegant.
But if someone uses cppcheck on a project including the json library, he should not have those warnings too (which is my personal objective, with the issue #1759).

There are other ways to suppress warnings in cppcheck, detailed in the manual.

We can suppress each warnings in the command line and given this line to the cppcheck users.
But the more warnings will be ignored, the less this command line will be easy to read, or to integrate in a project using the json library and cppcheck.

We can create a text file, or a xml file in which the ignored warning will be detailed and given to cppchek, so that it won't trigger them. If this solution is used, then, it should be well described in the README, to make it easy for the cppcheck users to integrate this file in their workflow(since they can integrate it from conan, or as a cmake external project, for example).

I would happily modify this PR to use another solution. 😃
But I will need you, @nlohmann , or someone else to validate which solution to integrate.

Thank you in advance 🙂

@stale
Copy link

stale bot commented Jan 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jan 22, 2020
@stale stale bot closed this Jan 30, 2020
@Xav83 Xav83 mentioned this pull request Apr 11, 2020
@ghost
Copy link

ghost commented Dec 15, 2020

@Xav83 I went ahead and reviewed it

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may have to fix line 386

@@ -374,6 +380,7 @@ class input_adapter
std::is_integral<typename std::remove_pointer<CharT>::type>::value and
sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0>
// cppcheck-suppress noExplicitConstructor
input_adapter(CharT b)
: input_adapter(reinterpret_cast<const char*>(b),
std::strlen(reinterpret_cast<const char*>(b))) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the reason why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants