Fix and test syntaxError suppression
This commit is contained in:
parent
f3167865ef
commit
b3a46e72dc
|
@ -219,11 +219,9 @@ script:
|
||||||
# building gui generates some more files that cppcheck can check, so check the repo *after* building gui
|
# building gui generates some more files that cppcheck can check, so check the repo *after* building gui
|
||||||
- cd ../
|
- cd ../
|
||||||
# self check
|
# self check
|
||||||
- touch /tmp/cppcheck.cppcheck
|
- ${CPPCHECK} --template=gcc -D__CPPCHECK__ -f --error-exitcode=1 --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling --inline-suppr --suppressions-list=.travis_suppressions -itest/cli -itest/synthetic -itest/testsuites -iaddons -igui . -j 2
|
||||||
- ${CPPCHECK} --template=gcc -D__CPPCHECK__ -f --error-exitcode=1 --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling --inline-suppr --suppressions-list=.travis_suppressions -itest/cli -itest/synthetic -itest/testsuites -iaddons -igui . -j 2 |& tee /tmp/cppcheck.cppcheck
|
|
||||||
# check gui with qt settings
|
# check gui with qt settings
|
||||||
- ${CPPCHECK} --template=gcc --library=qt --error-exitcode=1 -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling -j 2 gui --suppressions-list=.travis_suppressions -igui/test |& tee --append /tmp/cppcheck.cppcheck
|
- ${CPPCHECK} --template=gcc --library=qt --error-exitcode=1 -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling -j 2 gui --suppressions-list=.travis_suppressions -igui/test
|
||||||
- sh -c "! grep '\]$' /tmp/cppcheck.cppcheck"
|
|
||||||
# check naming conventions
|
# check naming conventions
|
||||||
- ${CPPCHECK} -i gui/test -j 2 --dump -q gui lib
|
- ${CPPCHECK} -i gui/test -j 2 --dump -q gui lib
|
||||||
- find lib gui -maxdepth 1 -name "*.dump" | xargs -n 1 -P 4 python addons/naming.py --private-member-variable='m[A-Z].*'
|
- find lib gui -maxdepth 1 -name "*.dump" | xargs -n 1 -P 4 python addons/naming.py --private-member-variable='m[A-Z].*'
|
||||||
|
|
|
@ -215,7 +215,6 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
|
|
||||||
CheckUnusedFunctions checkUnusedFunctions(nullptr, nullptr, nullptr);
|
CheckUnusedFunctions checkUnusedFunctions(nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
bool internalErrorFound(false);
|
|
||||||
try {
|
try {
|
||||||
Preprocessor preprocessor(mSettings, this);
|
Preprocessor preprocessor(mSettings, this);
|
||||||
std::set<std::string> configurations;
|
std::set<std::string> configurations;
|
||||||
|
@ -538,11 +537,8 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
e.id,
|
e.id,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
if (errmsg._severity == Severity::error || mSettings.isEnabled(errmsg._severity)) {
|
if (errmsg._severity == Severity::error || mSettings.isEnabled(errmsg._severity))
|
||||||
reportErr(errmsg);
|
reportErr(errmsg);
|
||||||
if (!mSuppressInternalErrorFound)
|
|
||||||
internalErrorFound = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,9 +664,6 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
mErrorList.clear();
|
mErrorList.clear();
|
||||||
if (internalErrorFound && (mExitCode==0)) {
|
|
||||||
mExitCode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mExitCode;
|
return mExitCode;
|
||||||
}
|
}
|
||||||
|
@ -1122,8 +1115,9 @@ void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSettings.nofail.isSuppressed(errorMessage) && (mUseGlobalSuppressions || !mSettings.nomsg.isSuppressed(errorMessage)))
|
if (!mSettings.nofail.isSuppressed(errorMessage) && !mSettings.nomsg.isSuppressed(errorMessage)) {
|
||||||
mExitCode = 1;
|
mExitCode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
mErrorList.push_back(errmsg);
|
mErrorList.push_back(errmsg);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
|
||||||
|
void validCode(int argInt)
|
||||||
|
{
|
||||||
|
// if G_UNLIKELY is not defined this results in a syntax error
|
||||||
|
if G_UNLIKELY(argInt == 1) {
|
||||||
|
} else if (G_UNLIKELY(argInt == 2)) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
void f1();
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
void f2();
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
# python -m pytest test-suppress-syntaxError.py
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from testutils import cppcheck
|
||||||
|
|
||||||
|
def test_j2():
|
||||||
|
ret, stdout, stderr = cppcheck('--error-exitcode=1 -j2 -q proj-suppress-syntaxError')
|
||||||
|
assert ret == 1
|
||||||
|
assert len(stderr) > 0
|
||||||
|
|
||||||
|
def test_j2_suppress():
|
||||||
|
ret, stdout, stderr = cppcheck('--error-exitcode=1 --suppress=*:proj-suppress-syntaxError/* -j2 -q proj-suppress-syntaxError')
|
||||||
|
assert ret == 0
|
||||||
|
assert len(stderr) == 0
|
||||||
|
|
Loading…
Reference in New Issue