Skip to content

Commit 7097876

Browse files
committed
CheckersReport: added workaround for "always active" checkers with UNUSEDFUNCTION_ONLY hack
1 parent 2b9048f commit 7097876

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/checkersreport.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ void CheckersReport::countCheckers()
143143
++mAllCheckersCount;
144144
}
145145
if (mSettings.premiumArgs.find("misra-c-") != std::string::npos || mSettings.addons.count("misra")) {
146+
const bool doUnusedFunctionOnly = Settings::unusedFunctionOnly();
146147
for (const checkers::MisraInfo& info: checkers::misraC2012Rules) {
147148
const std::string rule = std::to_string(info.a) + "." + std::to_string(info.b);
148-
const bool active = isMisraRuleActive(mActiveCheckers, rule);
149+
// this will return some rules as always active even if they are not in the active checkers.
150+
// this leads to a difference in the shown count and in the checkers stored in the builddir
151+
// TODO: fix this?
152+
const bool active = !doUnusedFunctionOnly && isMisraRuleActive(mActiveCheckers, rule);
149153
if (active)
150154
++mActiveCheckersCount;
151155
++mAllCheckersCount;

test/cli/other_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,14 +4044,11 @@ def test_active_unusedfunction_only_builddir(tmp_path):
40444044

40454045

40464046
def test_active_unusedfunction_only_misra(tmp_path):
4047-
# TODO: should only report a single active check
4048-
__test_active_checkers(tmp_path, 7, 1166, use_unusedfunction_only=True, use_misra=True)
4047+
__test_active_checkers(tmp_path, 1, 1166, use_unusedfunction_only=True, use_misra=True)
40494048

40504049

4051-
@pytest.mark.xfail(strict=True) # TODO: active count and checkers.txt differ
40524050
def test_active_unusedfunction_only_misra_builddir(tmp_path):
4053-
# TODO: should only report a single active check
40544051
checkers_exp = [
40554052
'CheckUnusedFunctions::check'
40564053
]
4057-
__test_active_checkers(tmp_path, 7, 1166, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp)
4054+
__test_active_checkers(tmp_path, 1, 1166, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp)

0 commit comments

Comments
 (0)