Setting up cppcheck

Hi. I’ve just started using cppcheck on a c++ project and I can’t find any documentation on how to configure it for codacy.

There are macros in the project that do things along the lines of

#define check(expr) if (!(expr)) return;

these are in header files

however when cppcheck is running, it doesn’t seem to be expanding the macro, and something like this

    if (ptr->member != 0)

generates a message along the lines of

Either the condition 'ptr!=0' is redundant or there is possible null pointer dereference: ptr.

On stackoverflow it suggests I need to tell cppcheck where to find the headers with a -I, but I can’t see how to do that with codacy.

What can I do about this?

Project is here: pan - Codacy - Files

Hi @ThosRTanner , thanks for the question!

Right now Codacy does not support configuration files for cppcheck. Instead, you will have to define which patterns you want running on your analysis using our UI. You can do it by going to your repo and clicking on the tab Code Patterns on the left. Here you can select cppcheck and configure the patterns that you want active.

Please let me know if you have any trouble configuring this.

Is any configuration planned? While I can certainly switch off the code pattern, or ignore it in certain circumstances (there’s a bunch of places where it’s actually showing a potential problem), it’s a bit of extra hunting when it appears. Also it’s not entirely clear how to stop ignoring an error on a particular line of code.