This commit is contained in:
parent
96c6276ce7
commit
6b9fac41f4
|
@ -47,5 +47,5 @@ jobs:
|
||||||
cd %GITHUB_WORKSPACE%\addons\test
|
cd %GITHUB_WORKSPACE%\addons\test
|
||||||
..\..\cppcheck.exe --dump -DDUMMY --suppress=uninitvar --inline-suppr misra\misra-test.c --std=c89 --platform=unix64
|
..\..\cppcheck.exe --dump -DDUMMY --suppress=uninitvar --inline-suppr misra\misra-test.c --std=c89 --platform=unix64
|
||||||
python3 ..\misra.py -verify misra\misra-test.c.dump
|
python3 ..\misra.py -verify misra\misra-test.c.dump
|
||||||
..\..\cppcheck.exe --addon=misra --inline-suppr --enable=information --error-exitcode=1 misra\misra-ctu-1-test.c misra\misra-ctu-2-test.c
|
..\..\cppcheck.exe --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 misra\misra-ctu-1-test.c misra\misra-ctu-2-test.c
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
./cppcheck --addon=threadsafety addons/test/threadsafety
|
./cppcheck --addon=threadsafety addons/test/threadsafety
|
||||||
./cppcheck --addon=threadsafety --std=c++03 addons/test/threadsafety
|
./cppcheck --addon=threadsafety --std=c++03 addons/test/threadsafety
|
||||||
./cppcheck --addon=misra --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
|
./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
|
||||||
pushd addons/test
|
pushd addons/test
|
||||||
# We'll force C89 standard to enable an additional verification for
|
# We'll force C89 standard to enable an additional verification for
|
||||||
# rules 5.4 and 5.5 which have standard-dependent options.
|
# rules 5.4 and 5.5 which have standard-dependent options.
|
||||||
|
@ -393,7 +393,7 @@ jobs:
|
||||||
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_ascii.txt -verify misra/misra-test.cpp.dump
|
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_ascii.txt -verify misra/misra-test.cpp.dump
|
||||||
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_utf8.txt -verify misra/misra-test.cpp.dump
|
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_utf8.txt -verify misra/misra-test.cpp.dump
|
||||||
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_windows1250.txt -verify misra/misra-test.cpp.dump
|
python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_windows1250.txt -verify misra/misra-test.cpp.dump
|
||||||
../../cppcheck --addon=misra --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c
|
../../cppcheck --addon=misra --enable=style --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c
|
||||||
../../cppcheck --dump misc-test.cpp
|
../../cppcheck --dump misc-test.cpp
|
||||||
python3 ../misc.py -verify misc-test.cpp.dump
|
python3 ../misc.py -verify misc-test.cpp.dump
|
||||||
../../cppcheck --dump naming_test.c
|
../../cppcheck --dump naming_test.c
|
||||||
|
|
|
@ -179,7 +179,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
.\cppcheck --addon=threadsafety addons\test\threadsafety || exit /b !errorlevel!
|
.\cppcheck --addon=threadsafety addons\test\threadsafety || exit /b !errorlevel!
|
||||||
.\cppcheck --addon=threadsafety --std=c++03 addons\test\threadsafety || exit /b !errorlevel!
|
.\cppcheck --addon=threadsafety --std=c++03 addons\test\threadsafety || exit /b !errorlevel!
|
||||||
.\cppcheck --addon=misra --inline-suppr --enable=information --error-exitcode=1 addons\test\misra\misra-ctu-*-test.c || exit /b !errorlevel!
|
.\cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons\test\misra\misra-ctu-*-test.c || exit /b !errorlevel!
|
||||||
cd addons\test
|
cd addons\test
|
||||||
rem We'll force C89 standard to enable an additional verification for
|
rem We'll force C89 standard to enable an additional verification for
|
||||||
rem rules 5.4 and 5.5 which have standard-dependent options.
|
rem rules 5.4 and 5.5 which have standard-dependent options.
|
||||||
|
@ -192,7 +192,7 @@ jobs:
|
||||||
python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_ascii.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel!
|
python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_ascii.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel!
|
||||||
python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_utf8.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel!
|
python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_utf8.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel!
|
||||||
python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_windows1250.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel!
|
python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_windows1250.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel!
|
||||||
..\..\cppcheck --addon=misra --platform=avr8 --error-exitcode=1 misra\misra-test-avr8.c || exit /b !errorlevel!
|
..\..\cppcheck --addon=misra --enable=style --platform=avr8 --error-exitcode=1 misra\misra-test-avr8.c || exit /b !errorlevel!
|
||||||
..\..\cppcheck --dump misc-test.cpp || exit /b !errorlevel!
|
..\..\cppcheck --dump misc-test.cpp || exit /b !errorlevel!
|
||||||
python3 ..\misc.py -verify misc-test.cpp.dump || exit /b !errorlevel!
|
python3 ..\misc.py -verify misc-test.cpp.dump || exit /b !errorlevel!
|
||||||
..\..\cppcheck --dump naming_test.c || exit /b !errorlevel!
|
..\..\cppcheck --dump naming_test.c || exit /b !errorlevel!
|
||||||
|
|
|
@ -13,14 +13,14 @@ typedef int MISRA_5_6_VIOLATION;
|
||||||
|
|
||||||
// cppcheck-suppress misra-c2012-5.7
|
// cppcheck-suppress misra-c2012-5.7
|
||||||
struct misra_5_7_violation_t {
|
struct misra_5_7_violation_t {
|
||||||
int x;
|
int x; // cppcheck-suppress unusedStructMember
|
||||||
};
|
};
|
||||||
static misra_5_7_violation_t misra_5_7_use_type_1;
|
static misra_5_7_violation_t misra_5_7_use_type_1;
|
||||||
|
|
||||||
// #11443 - FP
|
// #11443 - FP
|
||||||
static struct
|
static struct
|
||||||
{ // no warning
|
{ // no warning
|
||||||
uint16_t x;
|
uint16_t x; // cppcheck-suppress unusedStructMember
|
||||||
} misra_5_7_false_positive_1;
|
} misra_5_7_false_positive_1;
|
||||||
|
|
||||||
// cppcheck-suppress misra-c2012-8.4
|
// cppcheck-suppress misra-c2012-8.4
|
||||||
|
|
|
@ -13,14 +13,14 @@ static MISRA_5_6_VIOLATION misra_5_6_x;
|
||||||
|
|
||||||
// cppcheck-suppress misra-c2012-5.7
|
// cppcheck-suppress misra-c2012-5.7
|
||||||
struct misra_5_7_violation_t {
|
struct misra_5_7_violation_t {
|
||||||
int x;
|
int x; // cppcheck-suppress unusedStructMember
|
||||||
};
|
};
|
||||||
static misra_5_7_violation_t misra_5_7_use_type_2;
|
static misra_5_7_violation_t misra_5_7_use_type_2;
|
||||||
|
|
||||||
// #11443 - FP
|
// #11443 - FP
|
||||||
static struct
|
static struct
|
||||||
{ // no warning
|
{ // no warning
|
||||||
uint16_t x;
|
uint16_t x; // cppcheck-suppress unusedStructMember
|
||||||
} misra_5_7_false_positive_2;
|
} misra_5_7_false_positive_2;
|
||||||
|
|
||||||
// cppcheck-suppress misra-c2012-5.8
|
// cppcheck-suppress misra-c2012-5.8
|
||||||
|
@ -28,7 +28,7 @@ static int misra_5_8_var1;
|
||||||
// cppcheck-suppress misra-c2012-8.4
|
// cppcheck-suppress misra-c2012-8.4
|
||||||
// cppcheck-suppress misra-c2012-5.8
|
// cppcheck-suppress misra-c2012-5.8
|
||||||
void misra_5_8_f(void) {
|
void misra_5_8_f(void) {
|
||||||
// cppcheck-suppress misra-c2012-5.8
|
// cppcheck-suppress [misra-c2012-5.8, unusedVariable]
|
||||||
char misra_5_8_var2;
|
char misra_5_8_var2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
static void misra_10_4(void)
|
static void misra_10_4(void)
|
||||||
{
|
{
|
||||||
// #10480
|
// #10480
|
||||||
char buf[1] = {'f'};
|
const char buf[1] = {'f'};
|
||||||
const char c = '0';
|
const char c = '0';
|
||||||
signed int x = buf[0] - c;
|
x = buf[0] - c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void misra_12_2(void) {
|
static void misra_12_2(void) {
|
||||||
|
|
|
@ -1489,6 +1489,8 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
|
||||||
errmsg.severity = Severity::fromString(severity);
|
errmsg.severity = Severity::fromString(severity);
|
||||||
if (errmsg.severity == Severity::SeverityType::none)
|
if (errmsg.severity == Severity::SeverityType::none)
|
||||||
continue;
|
continue;
|
||||||
|
if (!mSettings.severity.isEnabled(errmsg.severity))
|
||||||
|
continue;
|
||||||
errmsg.file0 = ((files.size() == 1) ? files[0] : "");
|
errmsg.file0 = ((files.size() == 1) ? files[0] : "");
|
||||||
|
|
||||||
reportErr(errmsg);
|
reportErr(errmsg);
|
||||||
|
|
|
@ -58,14 +58,19 @@ def test_absolute_path():
|
||||||
assert stderr == '[%s:5]: (error) Division by zero.\n' % filename
|
assert stderr == '[%s:5]: (error) Division by zero.\n' % filename
|
||||||
|
|
||||||
def test_addon_local_path():
|
def test_addon_local_path():
|
||||||
ret, stdout, stderr = cppcheck_local(['--addon=misra', '--template=cppcheck1', '.'])
|
ret, stdout, stderr = cppcheck_local(['--addon=misra', '--enable=style', '--template=cppcheck1', '.'])
|
||||||
assert ret == 0, stdout
|
assert ret == 0, stdout
|
||||||
assert stderr == ('[main.c:5]: (error) Division by zero.\n'
|
assert stderr == ('[main.c:5]: (error) Division by zero.\n'
|
||||||
'[main.c:1]: (style) misra violation (use --rule-texts=<file> to get proper output)\n')
|
'[main.c:1]: (style) misra violation (use --rule-texts=<file> to get proper output)\n')
|
||||||
|
|
||||||
|
def test_addon_local_path_not_enable():
|
||||||
|
ret, stdout, stderr = cppcheck_local(['--addon=misra', '--template=cppcheck1', '.'])
|
||||||
|
assert ret == 0, stdout
|
||||||
|
assert stderr == '[main.c:5]: (error) Division by zero.\n'
|
||||||
|
|
||||||
def test_addon_absolute_path():
|
def test_addon_absolute_path():
|
||||||
prjpath = getAbsoluteProjectPath()
|
prjpath = getAbsoluteProjectPath()
|
||||||
ret, stdout, stderr = cppcheck(['--addon=misra', '--template=cppcheck1', prjpath])
|
ret, stdout, stderr = cppcheck(['--addon=misra', '--enable=style', '--template=cppcheck1', prjpath])
|
||||||
filename = os.path.join(prjpath, 'main.c')
|
filename = os.path.join(prjpath, 'main.c')
|
||||||
assert ret == 0, stdout
|
assert ret == 0, stdout
|
||||||
assert stderr == ('[%s:5]: (error) Division by zero.\n'
|
assert stderr == ('[%s:5]: (error) Division by zero.\n'
|
||||||
|
@ -73,7 +78,7 @@ def test_addon_absolute_path():
|
||||||
|
|
||||||
def test_addon_relative_path():
|
def test_addon_relative_path():
|
||||||
prjpath = getRelativeProjectPath()
|
prjpath = getRelativeProjectPath()
|
||||||
ret, stdout, stderr = cppcheck(['--platform=native', '--addon=misra', '--template=cppcheck1', prjpath])
|
ret, stdout, stderr = cppcheck(['--platform=native', '--addon=misra', '--enable=style', '--template=cppcheck1', prjpath])
|
||||||
filename = os.path.join(prjpath, 'main.c')
|
filename = os.path.join(prjpath, 'main.c')
|
||||||
assert ret == 0, stdout
|
assert ret == 0, stdout
|
||||||
assert stdout == ('Checking %s ...\n'
|
assert stdout == ('Checking %s ...\n'
|
||||||
|
@ -84,7 +89,7 @@ def test_addon_relative_path():
|
||||||
def test_addon_with_gui_project():
|
def test_addon_with_gui_project():
|
||||||
project_file = 'helloworld/test.cppcheck'
|
project_file = 'helloworld/test.cppcheck'
|
||||||
create_gui_project_file(project_file, paths=['.'], addon='misra')
|
create_gui_project_file(project_file, paths=['.'], addon='misra')
|
||||||
ret, stdout, stderr = cppcheck(['--platform=native', '--template=cppcheck1', '--project=' + project_file])
|
ret, stdout, stderr = cppcheck(['--platform=native', '--template=cppcheck1', '--enable=style', '--project=' + project_file])
|
||||||
filename = os.path.join('helloworld', 'main.c')
|
filename = os.path.join('helloworld', 'main.c')
|
||||||
assert ret == 0, stdout
|
assert ret == 0, stdout
|
||||||
assert stdout == 'Checking %s ...\n' % filename
|
assert stdout == 'Checking %s ...\n' % filename
|
||||||
|
|
Loading…
Reference in New Issue