Menu

How can I tell if cppcheckgui ran clang-tidy?

David
2019-02-04
2019-03-29
  • David

    David - 2019-02-04

    Hi, my first post got caught in the spam filter so hopefully this one goes through.
    I'm trying to get cppcheckgui to run clang-tidy on my codebase but I don't think it's working.

    My setup:
    - Win7, Cppcheck 1.86, LLVM 7.0.1
    - Tried both filled and blank Clang path in Preferences
    - Clang-tidy enabled in project settings

    On an unrelated note, every time I click on "Reanalyze all files", the results would be different.
    Sometimes it gets stuck reporting "No errors found" follow by "No errors found, nothing to save" but restarting the GUI seems to help.
    Is this the intended behaviour?

    Thanks in advance.

     
  • Daniel Marjamäki

    Make sure that you have a build dir setup in the project settings.

    In the build dir there will be files created during analysis. If I remember correctly you should get files with the name *clang-tidy-cmd that will contain the exact command the GUI uses for each file. And *clang-tidy-results that will contain the results. Do you see any such files?

    Is this the intended behaviour?

    hmm I do not think so.

     
  • David

    David - 2019-02-04

    No I don't see those files in the build dir. I tried running cppcheck and clang on a Win10 machine and got the same results.

     
  • Daniel Marjamäki

    hmm.. I can reproduce such problem when I do not import any project.

    If you click on the "Edit project..." then the first setting you see is "Import project". Is this empty? Otherwise, what kind of project do you import?

     
  • David

    David - 2019-02-06

    Yes that setting is empty because I set up the project from scratch. The "Analyze all Visual Studio configurations" option is checked but grayed out. Is it required to import a project?

     
  • Daniel Marjamäki

    I believe that importing a project should be required to allow that clang-tidy is run. It requires the proper compilation flags. So I need to update the project settings dialog somehow, it should not happily accept such configuration.

     
  • Daniel Marjamäki

    The "Analyze all Visual Studio configurations"

    that is not used unless you import a visual studio project. it does not matter.

     
  • David

    David - 2019-02-06

    I might be missing something because I'm not very familiar with clang-tidy but why can't those compilations flags be set without a project file? What about projects that uses other IDEs or none at all?

     
  • Daniel Marjamäki

    To clarify:

    "It requires the proper compilation flags."

    =>

    "clang-tidy requires the proper compilation flags."

     
  • Daniel Marjamäki

    You are not limited to visual studio. CMake / Makefile / etc build files can be used indirectly if you are able to generate a compilation database from it.

     
  • David

    David - 2019-02-06

    Ohh ok I can look into generating a database file, thanks.
    Any ideas with regard to the weird "Reanalyze all files" behavior I'm seeing?
    Is it also related to not importing from a project file?

     
  • Daniel Marjamäki

    why can't those compilations flags be set without a project file?

    hmm.. in theory you could specify all the compilation flags in the project settings. but that does not seem very practical to me.
    do you have some mismatching project that can't be imported?

    Generating the compilation database in Windows is not as easy as in Linux.

     
  • Daniel Marjamäki

    Any ideas with regard to the weird "Reanalyze all files" behavior I'm seeing? Is it also related to not importing from a project file?

    no ideas right now. But I do not think it is related.

    I gotta go now. Thanks for the chat :-)

     
  • David

    David - 2019-02-06

    Thanks a lot for your help.

     
  • David

    David - 2019-02-06

    PS.

    hmm.. in theory you could specify all the compilation flags in the project settings. but that does not seem very practical to me.
    

    Ya I didn't think about file specific compilation flags so having a project file to import from is certainly the easiest solution.

    do you have some mismatching project that can't be imported?
    

    I'm working with embedded code and the IDE can change from time to time. I'm currently using an eclipse-based IDE. The projects aren't very big so I think generating the compilation database is fine even if I have to write and maintain it manually. Nice to have it in json format :)

     
  • Mark Donkers

    Mark Donkers - 2019-03-27

    Hi David,

    Did you get any further with the two issues that you presented in this thread? I'm also new to Cppcheck and clang-tidy and am having the exact issues that you're having.

    The code that I'm trying to 'lint' comes from an Eclipse based IDE and so there is no make file (as far as I know), so importing is not an option.

    Thanks for any insight that you can share, no matter how little.

    Mark

     
    • David

      David - 2019-03-28

      Hi Mark,

      Unfortunately I had just accepted the random results problem for what it is and basically did what you outlined in your "Output changes on each analysis" post. As for clang-tidy, it took a bit of time to set up but I'm just running it separately with a script.

      David

       
  • Daniel Marjamäki

    It's a shame this hasn't been fixed yet - I was hopeful that this would be a great a static analysis tool for our team. We will have to accept the workaround for now.

    Yes it is. This is a hobby project and time is limited. :-(

    Would you be willing to sponsor this fix?

     
  • Daniel Marjamäki

    Also .. feel free to look into making a fix for this. All you need to install is Qt SDK including Qt Creator..
    A patch for this would be very welcome!

     
  • Mark Donkers

    Mark Donkers - 2019-03-29

    Hi Daniel. Thanks for the invitation to participate. I will seriously consider it!

     

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.