Menu

Checking a single file with compile commands from --project

2017-05-17
2020-09-13
  • Mathias Buhr

    Mathias Buhr - 2017-05-17

    Hi,

    I have a large cmake project and I'd like to integrate cppcheck into my IDE/editor. From cmake it's easy to generate all required compiler flags into compile_commands.json. This is then easliy loaded into cppcheck (on commandline) but this also automatically scans all files defined in the json file. Ideally, I'd like to run cppcheck on a single file but using the compiler flags from compile_commands.json on the command line. Is this somehow possible? I could find a way yet.

    Additionally, is it possible to load the compile_commands.json in the cppcheck-gui?

    I'm using the linux version.

     
    👍
    1
  • Daniel Marjamäki

    I'd like to run cppcheck on a single file but using the compiler flags from compile_commands.json

    yes that is a feature we should have. make it possible to scan specific files using settings from compile database.

    Additionally, is it possible to load the compile_commands.json in the cppcheck-gui?

    yes. in the project settings.

     
  • Bryan Bennetts

    Bryan Bennetts - 2019-04-17

    I'd like to run cppcheck on a single file but using the compiler flags from compile_commands.json

    yes that is a feature we should have. make it possible to scan specific files using settings from compile database.

    Hi,

    Was anything done for this? It is something I'd like too :)

     
    👍
    1
    • alfred

      alfred - 2020-09-12

      Hi,
      I would like this feature too !

       

      Last edit: alfred 2020-09-12
      • Daniel Marjamäki

        On the command line you now have that feature. See --file-filter.

         
        👍
        1
  • Daniel Marjamäki

    do you feel that this feature is needed in the GUI also? I envision that this is something you would only use for quick tests of some file. So configuration in a GUI project file would seem overkill. Or what do you say..

     
    • alfred

      alfred - 2020-09-13

      Thanks Daniel,
      yeah i found the solution yesterday while I was reading the code to try to implement it myself.

      I actually use it with ALE(Asynchronus Linting Engine) https://github.com/dense-analysis/ale, a plugin for VIM, so I only need it a file at a time, and it would give me the results fairly quickly, instead of waiting for some time each time the command is ran, but I had to modify the plugin to incorporate the --file-filter into it.
      I am not familiar with gui tools in general, but if they do have something similar, --live cheching the code-- , instead of a report style, then it would be useful.

       

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.