[QGIS-Developer] cppcheck false positive

Even Rouault even.rouault at spatialys.com
Tue Sep 29 03:30:30 PDT 2020


On mardi 29 septembre 2020 12:15:41 CEST Alessandro Pasotti wrote:
> Hi Even,
> 
> Thank you, I knew how to fix it but I was wondering if it is possible
> to reduce the false positives (see my other thread about spellchek on
> testdata), life is too short to be wasted in fighting with a dumb
> software :)
> Maybe a more recent version of cppcheck does nor have this issue?

I'm afraid not. my latest attempts with recent cppcheck HEAD lead to number of  new false 
positives on GDAL that weren't reported before.
The cppcheck version of ubuntu18.04 is not so bad actually.

When things go bad you can add a suppression

// cppcheck-suppress {name_of_cppcheck_diagnostic}

Or we can disable a category in scripts/cppcheck.sh if it is too unreliable

Even

> 
> 
> On Tue, Sep 29, 2020 at 12:11 PM Even Rouault
> 
> <even.rouault at spatialys.com> wrote:
> > On mardi 29 septembre 2020 11:55:40 CEST Alessandro Pasotti wrote:
> > > Looks like cppcheck is not smart enough...
> > 
> > Yeah, it hardly understands C++ (it doesn't need to be able to fully
> > compile a file to analyze it, if I remember correctly)> 
> > > const double factor { std::pow( 10, - mPrecisionSpinBox->value() ) };
> > 
> > I noticed this too. It is easily confused by curly initializer list, when
> > used in a method body. It might also have sometimes issues with lambdas
> > and variable scope.> 
> > > const double factor { std::pow( 10, - mPrecisionSpinBox->value() ) };
> > 
> > Using ( ) or = should fix it
> > 
> > 
> > 
> > const double factor (std::pow( 10, - mPrecisionSpinBox->value() ));
> > 
> > const double factor = std::pow( 10, - mPrecisionSpinBox->value() );
> > 
> > 
> > 
> > Even
> > 
> > 
> > 
> > --
> > 
> > Spatialys - Geospatial professional services
> > 
> > http://www.spatialys.com


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200929/1f14a550/attachment-0001.html>


More information about the QGIS-Developer mailing list