Cppcheck: Reduction of False Positives: Manual Approach

Maarten Hoes hoes.maarten at gmail.com
Thu Sep 27 14:26:34 UTC 2018


Hi,


If, by specifying (additional ?) include files/directories and adding
defines, you managed to bring down the massive zillions of warnings back to
just 30, it seems to me that you managed to do what the script should have
been doing all along to begin with.
;-)

Just a small remark (and you probably intend to do so already anyway):
besides changing the way cppcheck itself is called, you also make use of a
'inc.txt' file (which I assume contains the names of directories that
contain include files). I would personally re-create that file dynamically
from within the script (instead of providing a static version) on each run,
so that if in the future additional similar directories are added (or the
directory names change) these will get picked up automatically by the
script, instead of someone having to manually re-recreate the 'inc.txt' file
by hand (which people might/will forget to do). Yes, this will mean that the
script will take slightly longer to complete it's run (my personal
measurements based on the example included below are an added 15 seconds or
so currently), but since it is run automatically without any live human
being waiting for the output as it is running (and it is only run once a
week anyway as I recall) this does not really matter.

How about something like the thing below ? It would find all header files in
the libreoffice source tree, regardless of what directory they are located
in, and then use 'dirname' to get just the directory names they are located
in, and 'sort -u' to mention each directory just once. Would that be
sufficient for your suggested modifications ?


- Maarten Hoes



#!/bin/sh

TMPFILE=/tmp/tmpfile.txt
INCLUDEFILE=/tmp/incfile.txt


rm -f "$TMPFILE"


find . -type f \( -name \*.hxx -o -name \*.h \) | \
while read FILE
do
        DIRNAME=$(dirname "$FILE")
        echo "$DIRNAME" >> "$TMPFILE"
done

sort -u "$TMPFILE" > "$INCLUDEFILE"

cppcheck --includes-file="$INCLUDEFILE"




--
Sent from: http://document-foundation-mail-archive.969070.n3.nabble.com/Dev-f1639786.html


More information about the LibreOffice mailing list