skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.7k stars 185 forks source link

Should Cppcheck be added as a new tool? #19

Closed skeeto closed 1 year ago

skeeto commented 2 years ago

Cppcheck is a static analysis tool that is easy to build and include in w64devkit (C++, no dependencies), and so I am currently evaluating its CLI program for inclusion in future releases. I'm using this pull request to solicit feedback from anyone following along who's interested in trying it out, particularly within w64devkit. Check out this branch, build the kit, and try out the new cppcheck command. Is it useful in this context and worth including? Replies are also welcome in my public inbox.

Cppcheck defaults to the appropriate platform (--platform), so you don't need to set it. (I mention it since its documentation on this point is incorrect.) However, you may want to consider using --library=windows to enable extra checks for programs using Win32 directly. I've decided to always use the --quiet option myself, and I'm surprised this behavior isn't the default.

I've excluded all "addons" since they depend on Python, and I have no plans to ever include Python in w64devkit. I've also excluded the "platforms" since none of the non-built-in platforms are related to Windows. The goal is to include only the parts useful in a Windows development kit.

It even works in Windows XP, which is currently one of my requirements for included tools.

So far my reasons to not include it:

skeeto commented 2 years ago

Update: Now that I've gotten a feel for its configuration, I'm leaning towards including Cppcheck in future releases. This has been the most useful "default" check configuration for me, and I'll probably capture it in a shell alias/function:

cppcheck --quiet -j$(nproc) --library=windows --enable=portability,performance --suppress=uninitvar .

And this configuration is a good "strict" check — more thorough, but more false positives:

cppcheck --quiet -j$(nproc) --enable=portability,performance,style \
    --suppress=uninitvar --suppress=unusedStructMember \
    --suppress=constVariable --suppress=shadowVariable \
    --suppress=variableScope --suppress=constParameter \
    --suppress=shadowArgument --suppress=knownConditionTrueFalse .
skeeto commented 1 year ago

Over the past month Cppcheck has had some insightful findings, so I've merged it as b854d36.