Menu

False positive!

Absol
2021-09-05
2021-09-06
  • Absol

    Absol - 2021-09-05

    Where to place the code that produces a false positive with a high probability?

    I tried to put it in 'mSettings->certainty.isEnabled(Certainty::inconclusive)' but this cause tests fails.

     
  • Paul Fultz

    Paul Fultz - 2021-09-05

    Where to place the code that produces a false positive with a high probability?

    It should go into an addon. The goal of cppcheck is to always have low false positives. Inconclusive doesnt mean we lots of FPs either. This is meant for code that we make assumption about because it is incomplete(ie missing a variable, function, or class definition).

     
    • Absol

      Absol - 2021-09-06

      Thank you for answer!

      If part of code produce only true detects (with ~100% probability) but another part print all detects even with high rate false detection.

      I can place first part code in cppcheck, another as addon ? how to add addon, has docs ?

      Something like :

      bool printFalseDetections = std::find(std::begin(mSettings->addons), std::end(mSettings->addons), "mismatchingFalse") != std::end(mSettings->addons);
      

      ??

       

      Last edit: Absol 2021-09-06
      • Daniel Marjamäki

        I suggest that you look at some existing addon. the cppcheck/addons/findcasts.py is small and simple.

        it is executed like so:

        cppcheck --addon=findcasts.py file.c
        

        All datastructures are implemented in cppcheck/addons/cppcheckdata.py ... see class Token, class ValueType, etc.. by intention we use a similar interface in Python as in C++ Cppcheck. You should be able to run doxygen or something on cppcheckdata.py to get a nice documentation for the whole API but I don't remember how.

         

        Last edit: Daniel Marjamäki 2021-09-06
  • Absol

    Absol - 2021-09-06

    what is python? i don't know about this language. possible to write add-on in c++?

     
    • Daniel Marjamäki

      It is possible to write addons in c++. But that is so much more difficult. We don't have the infrastructure for that yet.

       
      • Absol

        Absol - 2021-09-06
         
        • Daniel Marjamäki

          no that is the quick hack solution. Static linking is not dynamic.

          I envision two possible solutions:
          1. write a c++ tool that imports the cppcheck data (xml data) and checks for mismatching variable name in assignment. that would work just like the python addons but is written in C++ instead.
          2. create a dll/so dynamic link library that provides the extra checking.

          The idea is that addons provide flexibility. In theory users can implement whatever checks they want in addons. they do not have to be merged/distributed with cppcheck repo if we don't like it for some reason.

          The problem with the dynamic link library interface is that it requires that the addon source code is GPL. I implemented option 1 so far because that can allow commercial addons with extra checks.

           

          Last edit: Daniel Marjamäki 2021-09-06
  • Absol

    Absol - 2021-09-06

    it look very hard in use, then better to not using any addons :( :( :(

     

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.