Coverity

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

New report from build 0.19.22366 has been created...

PS: If you get an error in Coverity when opening the "View Defects" window, just try to close it and open it again...
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

I am sharing my current build recipe for the Coverity build on Ubuntu 16.04. Mostly it is basically just a normal build with a few commands to set up and run the scanner. I will continue to make the builds as I did in the past, so this is mostly for the purpose if it can maybe be of some use and help for some other projects...

sudo add-apt-repository ppa:freecad-maintainers/freecad-daily

sudo apt-get update -qq

sudo apt-get install -y libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-thread-dev libboost-python-dev libcoin-dev libdouble-conversion-dev liblz4-dev libglew-dev libopencv-dev libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libmetis-dev libocct-data-exchange-dev libocct-ocaf-dev libocct-visualization-dev libproj-dev libpyside-dev libqt4-dev libqt4-opengl-dev libqtwebkit-dev libshiboken-dev libspnav-dev libvtk6-dev libx11-dev libxerces-c-dev libzipios++-dev lsb-release netgen netgen-headers occt-draw pybind11-dev pyside-tools python3-pyside.qtcore python3-pyside.qtgui python3-pyside.qtsvg python3-pyside.qtuitools python3-pyside.qtxml python3-dev python3-ply swig doxygen

sudo apt-get install -y git curl cmake

sudo apt-get clean

git clone --depth=1600 --branch=master https://github.com/FreeCAD/FreeCAD.git FreeCAD

cd FreeCAD/

git checkout

mkdir build

cd build

cmake -DBUILD_FEM_NETGEN=ON -DFREECAD_USE_PYBIND11=ON ../

cd ..

cd ..

wget https://scan.coverity.com/download/linux64 --post-data "<<<TOKEN>>>" -O coverity_tool.tgz

tar xvzf coverity_tool.tgz

rm coverity_tool.tgz

export PATH=$PATH:/home/user/cov-analysis-linux64-2019.03/bin

echo $PATH

cd FreeCAD/build/

make clean

cov-build --dir cov-int --fs-capture-search ../src make -j4

tar czvf FreeCAD.tgz cov-int

A small note on the command that runs the scan, Coverity supports the analysis of both C++ and python code (and others) and in the above example the command that runs the scan does both at the same time. For running the scanner just on C++ code the command would be... (where --dir cov-int is the output directory for the results)

cov-build --dir cov-int make -j4

And for running it only on the python code the command would be... (where --fs-capture-search ../src is the place of the code to be scanned)

cov-build --dir cov-int --no-command --fs-capture-search ../src
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

New report from build 0.19.23754 has been created...

PS: If you get an error in Coverity when opening the "View Defects" window, just try to close it and open it again...
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

New report from build 0.20.25220 has been created...
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

New report from build 0.20.28030 has been created...
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

New report from build 0.21.30257 has been created...
User avatar
chennes
Veteran
Posts: 3879
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Coverity

Post by chennes »

A lot of good reminders in this one about the dangers of blindly using auto without considering whether you really want a reference (or a constant, for that matter).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
berniev
Posts: 247
Joined: Wed Apr 13, 2022 10:45 pm
Location: Oz

Re: Coverity

Post by berniev »

chennes wrote: Sat Sep 03, 2022 8:22 pm A lot of good reminders in this one about the dangers of blindly using auto without considering whether you really want a reference (or a constant, for that matter).
Any chance you could expand on that? Perhaps in a new thread would be appropriate?
User avatar
chennes
Veteran
Posts: 3879
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Coverity

Post by chennes »

There are a lot of warnings in this latest report about auto creating unintended copies, because auto only resolves the base type, not whether it is a reference or a const. So if you wanted to avoid a copy you needed to explicitly say auto &.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Coverity

Post by saso »

New report from build 0.21.32049 has been created...
Post Reply