Skip to content

Commit 5477130

Browse files
authored
selfcheck : cleaned up some suppressions, fixed warnings and some cleanups (#4436)
* cleaned up triage.pro and pass all triage files to selfcheck * CI-unixish.yml: factored out redundant selfcheck flags * CI-unixish.yml: cleaned up selfcheck suppressions and fixed warnings * added explicit `missingInclude` checks to selfcheck to work around current issues/limitations / fixed selfcheck includes / added some unit tests for `missingInclude` * applied the selfcheck changes to the sanitizer jobs * only fail TSAN CI build in case of TSAN error / updated sanitizer CI build TODOs
1 parent 6960332 commit 5477130

14 files changed

Lines changed: 122 additions & 46 deletions

.github/workflows/CI-unixish.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,36 @@ jobs:
451451
qmake CONFIG+=debug HAVE_QCHART=yes
452452
make -j$(nproc) compiler_uic_make_all mocables
453453
454+
- name: Generate triage UI files
455+
run: |
456+
pushd tools/triage
457+
qmake CONFIG+=debug
458+
make -j$(nproc) compiler_uic_make_all mocables
459+
454460
- name: Self check
455461
run: |
462+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
456463
ec=0
464+
465+
# work around missingInclude not being reported with -j and the --check-config requirement for detailed warnings
466+
./cppcheck $selfcheck_options cli lib --check-config --suppress=missingIncludeSystem --suppress=unmatchedSuppression || ec=1
467+
./cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp --check-config --suppress=missingIncludeSystem --suppress=unmatchedSuppression || ec=1
468+
./cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp --check-config --suppress=missingIncludeSystem --suppress=unmatchedSuppression || ec=1
469+
./cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp --check-config --suppress=missingIncludeSystem --suppress=unmatchedSuppression || ec=1
470+
471+
# early exit
472+
if [ $ec -eq 1 ]; then
473+
exit $ec
474+
fi
475+
457476
# self check lib/cli
458477
mkdir b1
459-
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 --cppcheck-build-dir=b1 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings cli lib || ec=1
478+
./cppcheck $selfcheck_options --cppcheck-build-dir=b1 --addon=naming.json cli lib || ec=1
460479
# check gui with qt settings
461480
mkdir b2
462-
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 --cppcheck-build-dir=b2 -D__CPPCHECK__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --library=qt --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings gui/*.cpp gui/temp/*.cpp || ec=1
481+
./cppcheck $selfcheck_options --cppcheck-build-dir=b2 -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
463482
# self check test and tools
464-
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings test/*.cpp tools/*.cpp || ec=1
483+
./cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
465484
# triage
466-
./cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --library=qt -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings tools/triage || ec=1
485+
./cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
467486
exit $ec

.github/workflows/CI-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ jobs:
175175
python -m pytest test-helloworld.py || exit /b !errorlevel!
176176
python -m pytest test-inline-suppress.py || exit /b !errorlevel!
177177
python -m pytest test-more-projects.py || exit /b !errorlevel!
178+
python -m pytest test-other.py || exit /b !errorlevel!
178179
python -m pytest test-proj2.py || exit /b !errorlevel!
179180
python -m pytest test-suppress-syntaxError.py || exit /b !errorlevel!
180181

.github/workflows/asan.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ jobs:
5252
- name: Run tests
5353
run: ./cmake.output/bin/testrunner
5454

55-
# TODO: re-enable - was being killed because of incresaed memory usage
56-
# TODO: no gui/temp/*.cpp files available
55+
# TODO: re-enable - was being killed because of increased memory usage
56+
# TODO: only fail the step on sanitizer issues
5757
- name: Self check
5858
if: false
5959
run: |
60+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
6061
ec=0
61-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings cli lib || ec=1
62-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=qt --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings gui/*.cpp gui/temp/*.cpp || ec=1
63-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli -Igui --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings test/*.cpp tools/*.cpp || ec=1
64-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --library=qt -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings tools/triage || ec=1
62+
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json cli lib || ec=1
63+
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
64+
./cmake.output/bin/cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
65+
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
6566
exit $ec

.github/workflows/tsan.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ jobs:
5353
run: ./cmake.output/bin/testrunner
5454

5555
# TODO: disabled for now as it takes around 40 minutes to finish
56-
# TODO: no gui/temp/*.cpp files available
56+
# set --error-exitcode=0 so we only fail on sanitizer issues - since it uses threads for execution it will exit the whole process on the first issue
5757
- name: Self check
5858
if: false
5959
run: |
60+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
6061
ec=0
61-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings cli lib || ec=1
62-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=qt --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings gui/*.cpp gui/temp/*.cpp || ec=1
63-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli -Igui --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings test/*.cpp tools/*.cpp || ec=1
64-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --library=qt -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings tools/triage || ec=1
62+
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json cli lib || ec=1
63+
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
64+
./cmake.output/bin/cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
65+
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
6566
exit $ec

.github/workflows/ubsan.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ jobs:
5252
- name: Run tests
5353
run: ./cmake.output/bin/testrunner
5454

55-
# TODO: no gui/temp/*.cpp files available
55+
# TODO: only fail the step on sanitizer issues
5656
- name: Self check
5757
run: |
58+
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings"
5859
ec=0
59-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings cli lib || ec=1
60-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=qt --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings gui/*.cpp gui/temp/*.cpp || ec=1
61-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Icli -Igui --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --debug-warnings test/*.cpp tools/*.cpp || ec=1
62-
./cmake.output/bin/cppcheck -q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DQ_MOC_OUTPUT_REVISION=67 --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib --library=qt -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ -Igui --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings tools/triage || ec=1
60+
./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json cli lib || ec=1
61+
./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --library=qt --addon=naming.json -Igui/temp -Igui gui/*.cpp gui/temp/*.cpp || ec=1
62+
./cmake.output/bin/cppcheck $selfcheck_options -Icli test/*.cpp tools/*.cpp || ec=1
63+
./cmake.output/bin/cppcheck $selfcheck_options -DQ_MOC_OUTPUT_REVISION=67 --library=qt -Itools/triage/temp -Igui tools/triage/*.cpp tools/triage/temp/*.cpp || ec=1
6364
exit $ec

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ build/
5555
/gui/debug/
5656
/gui/release/
5757
/gui/temp/
58+
/triage/temp
5859

5960
# Other (generated) GUI files
6061
/gui/*.qm

.selfcheck_suppressions

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
unusedPrivateFunction:test/testbufferoverrun.cpp
2-
unusedPrivateFunction:test/testcmdlineparser.cpp
31
shadowFunction
42
bitwiseOnBoolean
53

64
# temporary suppressions - fix the warnings!
7-
unusedPrivateFunction:test/test*.cpp
85
useStlAlgorithm
96
simplifyUsing:lib/valueptr.h
7+
varid0:gui/projectfile.cpp
8+
9+
# warnings in Qt generated code we cannot fix
1010
symbolDatabaseWarning:gui/temp/moc_*.cpp
1111
simplifyUsing:gui/temp/moc_*.cpp
12-
symbolDatabaseWarning:tools/triage/moc_*.cpp
12+
funcArgNamesDifferent:gui/temp/moc_*.cpp
13+
symbolDatabaseWarning:tools/triage/temp/moc_*.cpp
14+
naming-varname:gui/temp/ui_*.h
15+
functionStatic:gui/temp/ui_fileview.h
1316

1417
# --debug-warnings suppressions
1518
valueFlowBailout
1619
valueFlowBailoutIncompleteVar
1720
autoNoType
1821
bailoutUninitVar
1922

20-
*:gui/test/*
21-
*:test/test.cxx
22-
*:test/cfg/*
2323
*:externals/*/*

test/cli/test-helloworld.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import os
55
import re
66
import tempfile
7+
import pytest
8+
79
from testutils import create_gui_project_file, cppcheck
810

911
# Run Cppcheck from project path
@@ -189,6 +191,17 @@ def test_build_dir_dump_output():
189191
dump = f.read()
190192
assert '</dump>' in dump, 'invalid dump data: ...' + dump[-100:]
191193

194+
def __test_missing_include_system(use_j):
195+
args = '--enable=missingInclude --suppress=zerodiv helloworld'
196+
if use_j:
197+
args = '-j2 ' + args
192198

199+
_, _, stderr = cppcheck(args.split())
200+
assert stderr == 'nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingIncludeSystem]\n\n'
193201

202+
def test_missing_include_system():
203+
__test_missing_include_system(False)
194204

205+
@pytest.mark.xfail
206+
def test_missing_include_system_j(): #11283
207+
__test_missing_include_system(True)

test/cli/test-other.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
# python -m pytest test-other.py
3+
4+
import os
5+
import pytest
6+
7+
from testutils import cppcheck
8+
9+
def __test_missing_include(tmpdir, use_j):
10+
test_file = os.path.join(tmpdir, 'test.c')
11+
with open(test_file, 'wt') as f:
12+
f.write("""
13+
#include "test.h"
14+
""")
15+
16+
args = '--enable=missingInclude {}'.format(test_file)
17+
if use_j:
18+
args = '-j2 ' + args
19+
20+
_, _, stderr = cppcheck(args.split())
21+
assert stderr == 'nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingInclude]\n\n'
22+
23+
def test_missing_include(tmpdir):
24+
__test_missing_include(tmpdir, False)
25+
26+
@pytest.mark.xfail
27+
def test_missing_include_j(tmpdir): #11283
28+
__test_missing_include(tmpdir, True)
29+
30+
def __test_missing_include_check_config(tmpdir, use_j):
31+
test_file = os.path.join(tmpdir, 'test.c')
32+
with open(test_file, 'wt') as f:
33+
f.write("""
34+
#include "test.h"
35+
""")
36+
37+
# TODO: -rp is not working requiring the full path in the assert
38+
args = '--check-config -rp={} {}'.format(tmpdir, test_file)
39+
if use_j:
40+
args = '-j2 ' + args
41+
42+
_, _, stderr = cppcheck(args.split())
43+
assert stderr == '{}:2:0: information: Include file: "test.h" not found. [missingInclude]\n\n^\n'.format(test_file)
44+
45+
def test_missing_include_check_config(tmpdir):
46+
__test_missing_include_check_config(tmpdir, False)
47+
48+
def test_missing_include_check_config_j(tmpdir):
49+
__test_missing_include_check_config(tmpdir, True)

test/testbool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class TestBool : public TestFixture {
5757
TEST_CASE(comparisonOfBoolWithInt7); // #4846 - (!x == true)
5858
TEST_CASE(comparisonOfBoolWithInt8); // #9165
5959
TEST_CASE(comparisonOfBoolWithInt9); // #9304
60+
TEST_CASE(comparisonOfBoolWithInt10); // #10935
6061

6162
TEST_CASE(checkComparisonOfFuncReturningBool1);
6263
TEST_CASE(checkComparisonOfFuncReturningBool2);

0 commit comments

Comments
 (0)