Menu

How to make cppcheck stop on error

jonyre
2018-01-03
2018-01-07
  • jonyre

    jonyre - 2018-01-03

    I use cppcheck to look for errors.
    now I'm looking for a way the stop the cppcheck run after he found the first error.

    didnt found any in the manual.

    Thanks for your help.

     
  • Daniel Marjamäki

    I have not got that feature request before. There is no builtin functionality right now.

    I assume you want to stop because a full analysis takes too much time? Do you use --cppcheck-build-dir to make the analysis quicker?

    Technically it would be possible to add some command line flag. But well I try to be a bit restrictive about it. As far as I know there is only 1 user that wants this currently.

    It is possible for you to achieve this anyway without a flag. Check 1 file at a time from a script and terminate when the exit code is non-zero.

     

    Last edit: Daniel Marjamäki 2018-01-04
  • jonyre

    jonyre - 2018-01-04

    Thanks.
    I think ill make a script.

    can you explain/link this "--cppcheck-build-dir" ?

     
  • Daniel Marjamäki

    The build dir is a folder with arbitrary name.. Example:

    mkdir jonyre
    cppcheck --cppcheck-build-dir=jonyre --enable=style path
    cppcheck --cppcheck-build-dir=jonyre --enable=style path

    In the folder "jonyre" cppcheck will store analyzer info.

    The first time you execute cppcheck, you will not see any big difference.

    The second time you execute cppcheck, the analysis should go much faster. Because this time only changed files are re-analyzed. If no files are changed the analysis should quit in a few seconds. You still get the full report.

    Please note you need to use the same command line flags when you execute cppcheck the second time, otherwise cppcheck will not reuse the analyzer info in the jonyre folder.

     

    Last edit: Daniel Marjamäki 2018-01-04
    • jonyre

      jonyre - 2018-01-07

      thanks !

       
  • raynebc

    raynebc - 2018-01-05

    That's interesting. Is there a way to store it in the GUI program's project file or will it just be for command line?

     
  • Daniel Marjamäki

    sure. It is configured in the project dialog.

     
  • raynebc

    raynebc - 2018-01-07

    I haven't edited the project file in a while, it seems to have some stuff I hadn't noticed. I went to add some excluded directories for third party results I ignore, but I'm seeing two instances where Cppcheck returns error level results for two different header files in MinGW's include directory even though I have added that directory as an excluded path in the project. Did I do it wrong or is this a bug/limitation with Cppcheck?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.