Skip to content

Commit aa09401

Browse files
committed
CheckersReport: added workaround for "always active" checkers with UNUSEDFUNCTION_ONLY hack
1 parent bbd1334 commit aa09401

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
@@ -4111,14 +4111,11 @@ def test_active_unusedfunction_only_builddir(tmp_path):
41114111

41124112

41134113
def test_active_unusedfunction_only_misra(tmp_path):
4114-
# TODO: should only report a single active check
4115-
__test_active_checkers(tmp_path, 7, 1166, use_unusedfunction_only=True, use_misra=True)
4114+
__test_active_checkers(tmp_path, 1, 1166, use_unusedfunction_only=True, use_misra=True)
41164115

41174116

4118-
@pytest.mark.xfail(strict=True) # TODO: active count and checkers.txt differ
41194117
def test_active_unusedfunction_only_misra_builddir(tmp_path):
4120-
# TODO: should only report a single active check
41214118
checkers_exp = [
41224119
'CheckUnusedFunctions::check'
41234120
]
4124-
__test_active_checkers(tmp_path, 7, 1166, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp)
4121+
__test_active_checkers(tmp_path, 1, 1166, use_unusedfunction_only=True, use_misra=True, checkers_exp=checkers_exp)

0 commit comments

Comments
 (0)