-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fixes Cppcheck warnings #1759
Comments
PS: I don't know is this issue should be flagged as a feature request or as anything else, so I made it a regular issue. |
If I remove the warnings on non-explicit constructors (which are not a bug, but a feature for this library), we are left with the following issues:
PRs welcome! |
And even nicer than a PR fixes these issues would be adding the cppcheck to CI so that the codebase stays clean as well. |
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. |
Those 2 warnings:
seems to be false positive, since the expression can be true since their are initialize as such:
but cppcheck must deduce the warnings because of the default which is const too:
|
I have runned cppcheck on the version 3.7.3, the currently last release, and here are the warning that I have on a dummy project including the library through conan:
I'm currently creating a repository with a project able to run cppcheck on any version of I will update you when this repository will be ready to use 🙂 |
Here is a little update on where I am on the correction of the cppcheck fixes I've finalize to repository on which I can run easily cppcheck with a simple program on jsonformoderncpp library, like any user of the library will do, and check if any warning is generated. You can find this repository here. 🙂 👍 With that tool now available, I've stated correcting one warning on a Fork : I will update you when I will have other news to give you about this 😉 |
Hi everyone ! 😃 Here is another update. To ignore those, cppcheck manual indicates that we can add comments in the code to do so, and when running cppcheck, we only have to add the option So I am going to make a Pull Request which will ignore all the warnings that must be ignored, to be able to focus on the last warning that need some code modifications. I will make a list of the warnings that are left once the Pull Request will have been created and merge 😉 |
@Xav83 Thanks for the update. Just to make sure: are you aware of the Makefile target |
@nlohmann Actually, I wasn't aware of it ! This is great, it will simplify a lot the process I used to fix the warnings 😄 Thank you for this information ! |
@Xav83 Any news on this or can we close this? |
Hi @nlohmann ! The latest news was the Pull Request #1876 in which I detailed how what are the solutions that I know of, to suppress some warnings which are one false positive from cppcheck. I needed someone to validate which solution to integrate, or if another one is available, to finish having the library clear from cppcheck warnings |
@Xav83 I think a pull request should do the trick for now |
I today had another look at the warnings running Cppcheck 2.3 with
out of the long output, I think only the following reports are worth looking into: Shadowing
PR: #2536 Unnecessary copies
Will not be fixed; changing the signature to a const reference could break existing code. The copy is not too bad though, because the value is then stored inside the Possible STL algorithms
The other messages are not really helpful, and, as I stated in #1876, I do not think it is a good idea to add dozens of cppcheck exclusion comments to the code. |
cppcheck had a lot of update since I last runned it on the project 😄 @nlohmann To avoid having inline cppcheck exclusion comments, you can pass a file to cppcheck specifying the warnings to ignore: Inline comments would ease a lot the integration of cppcheck in projects using the json library, or the integration of the json library in projects using cppcheck 😄 |
With merging #2536 I fixed the issues that I found relevant to fix. I do not think that adding a suppression list to the project and cppcheck to the CI makes sense at this point. (We do use Cppcheck heavily at work, but I found it less useful in this project.) |
Hi @nlohmann and other mainteners,
First of all, I must say that I love your work on this librairy.
It feels really easy to use, and to read code using this library ! ❤️
I have created this issue to talk about the warnings that cppcheck found on this project.
I'm currently experimenting with both this library and cppcheck on some little side projects. And doing so, I've ended up with cppcheck warnings me about some elements inside the json library.
So the purpose of this issue is to talk about the warnings from cppcheck, to address them when they are relevant, so that other people which are going to have both this library and cppcheck] in their project, as little as warnings as possible.
Here is the list of the warnings I've got for now:
Some of them may be false positive, but others can be relevant, so this is why I've made this issue. The good news, is that all the warnings I have got are flagged as "style", not as error or warning, so their are less likely to bother most of people using cppcheck. 😄
If we successly correct all the warnings (and silence the false positive), we may even imagine adding cppcheck to the CI of the library. 🤞
Let me know what you think about this idea. If you agree with the purpose of this issue, I'll gladly help to reach it.
For technical information, I've used the version 1.87 of cppcheck on the version 3.7.0 of the json library, on Windows, with Visual Studio 2017. You can find the repository on which I'm currently running this here
In a few minutes, I will also add a Pull Request which handles the warnings
6
and29
. 🔜The text was updated successfully, but these errors were encountered: