Skip to content

Commit

Permalink
Checker report: Update premium checkers info
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Apr 28, 2024
1 parent b3f3606 commit 03d482d
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ void CheckClass::operatorEqMissingReturnStatementError(const Token *tok, bool er

void CheckClass::operatorEqToSelf()
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("operatorEqToSelf"))
return;

logChecker("CheckClass::operatorEqToSelf"); // warning
Expand Down Expand Up @@ -2953,7 +2953,7 @@ void CheckClass::pureVirtualFunctionCallInConstructorError(

void CheckClass::checkDuplInheritedMembers()
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("duplInheritedMember"))
return;

logChecker("CheckClass::checkDuplInheritedMembers"); // warning
Expand Down
10 changes: 6 additions & 4 deletions lib/checkio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,11 @@ void CheckIO::incompatibleFileOpenError(const Token *tok, const std::string &fil
//---------------------------------------------------------------------------
void CheckIO::invalidScanf()
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("invalidscanf"))
return;

logChecker("CheckIO::invalidScanf");

const SymbolDatabase * const symbolDatabase = mTokenizer->getSymbolDatabase();
for (const Scope * scope : symbolDatabase->functionScopes) {
for (const Token *tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
Expand Down Expand Up @@ -1710,7 +1712,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok,
nonneg int numFunction)
{
const Severity severity = numFormat > numFunction ? Severity::error : Severity::warning;
if (severity != Severity::error && !mSettings->severity.isEnabled(Severity::warning))
if (severity != Severity::error && !mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("wrongPrintfScanfArgNum"))
return;

std::ostringstream errmsg;
Expand All @@ -1729,7 +1731,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok,
void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, const std::string& functionName,
nonneg int index, nonneg int numFunction)
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("wrongPrintfScanfParameterPositionError"))
return;
std::ostringstream errmsg;
errmsg << functionName << ": ";
Expand Down Expand Up @@ -1992,7 +1994,7 @@ void CheckIO::argumentType(std::ostream& os, const ArgumentInfo * argInfo)

void CheckIO::invalidLengthModifierError(const Token* tok, nonneg int numFormat, const std::string& modifier)
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("invalidLengthModifierError"))
return;
std::ostringstream errmsg;
errmsg << "'" << modifier << "' in format string (no. " << numFormat << ") is a length modifier and cannot be used without a conversion specifier.";
Expand Down
7 changes: 6 additions & 1 deletion lib/checkmemoryleak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,14 @@ void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
void CheckMemoryLeakNoVar::checkForUnsafeArgAlloc(const Scope *scope)
{
// This test only applies to C++ source
if (!mTokenizer->isCPP() || !mSettings->certainty.isEnabled(Certainty::inconclusive) || !mSettings->severity.isEnabled(Severity::warning))
if (!mTokenizer->isCPP())
return;

if (!mSettings->isPremiumEnabled("leakUnsafeArgAlloc") && (!mSettings->certainty.isEnabled(Certainty::inconclusive) || !mSettings->severity.isEnabled(Severity::warning)))
return;

logChecker("CheckMemoryLeakNoVar::checkForUnsafeArgAlloc");

for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
if (Token::Match(tok, "%name% (")) {
const Token *endParamToken = tok->next()->link();
Expand Down
2 changes: 1 addition & 1 deletion lib/checknullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
return;
}

if (!mSettings->isEnabled(value, inconclusive))
if (!mSettings->isEnabled(value, inconclusive) && !mSettings->isPremiumEnabled("nullPointer"))
return;

const ErrorPath errorPath = getErrorPath(tok, value, "Null pointer dereference");
Expand Down
8 changes: 6 additions & 2 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,9 +1326,11 @@ static bool isVariableMutableInInitializer(const Token* start, const Token * end

void CheckOther::checkConstVariable()
{
if (!mSettings->severity.isEnabled(Severity::style) || mTokenizer->isC())
if ((!mSettings->severity.isEnabled(Severity::style) || mTokenizer->isC()) && !mSettings->isPremiumEnabled("constVariable"))
return;

logChecker("CheckOther::checkConstVariable"); // style,c++

const SymbolDatabase *const symbolDatabase = mTokenizer->getSymbolDatabase();

for (const Variable *var : symbolDatabase->variableList()) {
Expand Down Expand Up @@ -3344,7 +3346,9 @@ void CheckOther::unknownEvaluationOrder(const Token* tok)

void CheckOther::checkAccessOfMovedVariable()
{
if (!mTokenizer->isCPP() || mSettings->standards.cpp < Standards::CPP11 || !mSettings->severity.isEnabled(Severity::warning))
if (!mTokenizer->isCPP())
return;
if (!mSettings->isPremiumEnabled("accessMoved") && (!mSettings->standards.cpp < Standards::CPP11 || !mSettings->severity.isEnabled(Severity::warning)))
return;
logChecker("CheckOther::checkAccessOfMovedVariable"); // c++11,warning
const bool reportInconclusive = mSettings->certainty.isEnabled(Certainty::inconclusive);
Expand Down
2 changes: 1 addition & 1 deletion lib/checksizeof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void CheckSizeof::sizeofCalculationError(const Token *tok, bool inconclusive)

void CheckSizeof::sizeofFunction()
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("sizeofFunctionCall"))
return;

logChecker("CheckSizeof::sizeofFunction"); // warning
Expand Down
43 changes: 27 additions & 16 deletions lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,11 @@ static const std::set<std::string> autosarCheckers{
"comparePointers",
"constParameter",
"cstyleCast",
"ctuOneDefinitionViolation",
"ctuOneDefinitionRuleViolation",
"doubleFree",
"duplInheritedMember",
"duplicateBreak",
"exceptThrowInDestructor",
"funcArgNamesDifferent",
"functionConst",
"functionStatic",
Expand All @@ -340,9 +341,11 @@ static const std::set<std::string> autosarCheckers{
"redundantAssignment",
"redundantInitialization",
"returnDanglingLifetime",
"shadowArgument",
"shadowFunction",
"shadowVariable",
"shiftTooManyBits",
"sizeofSideEffects",
"throwInDestructor",
"sizeofFunctionCall",
"throwInNoexceptFunction",
"uninitData",
"uninitMember",
Expand All @@ -353,7 +356,7 @@ static const std::set<std::string> autosarCheckers{
"unusedStructMember",
"unusedValue",
"unusedVariable",
"useInitializerList",
"useInitializationList",
"variableScope",
"virtualCallInConstructor",
"zerodiv",
Expand Down Expand Up @@ -405,20 +408,24 @@ static const std::set<std::string> certCppCheckers{
"accessMoved",
"comparePointers",
"containerOutOfBounds",
"ctuOneDefinitionViolation",
"deallocMismatch",
"ctuOneDefinitionRuleViolation",
"danglingLifetime",
"danglingReference",
"danglingTempReference",
"danglingTemporaryLifetime",
"deallocThrow",
"deallocuse",
"doubleFree",
"eraseDereference",
"exceptThrowInDestructor",
"initializerList",
"invalidContainer",
"lifetime",
"memleak",
"mismatchAllocDealloc",
"missingReturn",
"nullPointer",
"operatorEqToSelf",
"returnDanglingLifetime",
"sizeofCalculation",
"uninitvar",
"virtualCallInConstructor",
Expand All @@ -433,10 +440,10 @@ static const std::set<std::string> misrac2012Checkers{
"bufferAccessOutOfBounds",
"comparePointers",
"compareValueOutOfTypeRangeError",
"constPointer",
"constParameterPointer",
"danglingLifetime",
"danglingTemporaryLifetime",
"duplicateBreak",
"error",
"funcArgNamesDifferent",
"incompatibleFileOpen",
"invalidFunctionArg",
Expand All @@ -454,11 +461,14 @@ static const std::set<std::string> misrac2012Checkers{
"redundantAssignment",
"redundantCondition",
"resourceLeak",
"returnDanglingLifetime",
"shadowVariable",
"sizeofCalculation",
"sizeofwithsilentarraypointer",
"syntaxError",
"uninitvar",
"unknownEvaluationOrder",
"unreachableCode",
"unreadVariable",
"unusedLabel",
"unusedVariable",
Expand All @@ -474,10 +484,10 @@ static const std::set<std::string> misrac2023Checkers{
"bufferAccessOutOfBounds",
"comparePointers",
"compareValueOutOfTypeRangeError",
"constPointer",
"constParameterPointer",
"danglingLifetime",
"danglingTemporaryLifetime",
"duplicateBreak",
"error",
"funcArgNamesDifferent",
"incompatibleFileOpen",
"invalidFunctionArg",
Expand All @@ -495,11 +505,14 @@ static const std::set<std::string> misrac2023Checkers{
"redundantAssignment",
"redundantCondition",
"resourceLeak",
"returnDanglingLifetime",
"shadowVariable",
"sizeofCalculation",
"sizeofwithsilentarraypointer",
"syntaxError",
"uninitvar",
"unknownEvaluationOrder",
"unreachableCode",
"unreadVariable",
"unusedLabel",
"unusedVariable",
Expand All @@ -513,7 +526,7 @@ static const std::set<std::string> misracpp2008Checkers{
"constParameter",
"constVariable",
"cstyleCast",
"ctuOneDefinitionViolation",
"ctuOneDefinitionRuleViolation",
"danglingLifetime",
"duplInheritedMember",
"duplicateBreak",
Expand All @@ -522,7 +535,7 @@ static const std::set<std::string> misracpp2008Checkers{
"functionConst",
"functionStatic",
"missingReturn",
"noExplicit",
"noExplicitConstructor",
"overlappingWriteFunction",
"overlappingWriteUnion",
"pointerOutOfBounds",
Expand All @@ -533,8 +546,7 @@ static const std::set<std::string> misracpp2008Checkers{
"returnTempReference",
"shadowVariable",
"shiftTooManyBits",
"sizeofSideEffects",
"throwInDestructor",
"sizeofFunctionCall",
"uninitDerivedMemberVar",
"uninitDerivedMemberVarPrivate",
"uninitMemberVar",
Expand All @@ -549,7 +561,6 @@ static const std::set<std::string> misracpp2008Checkers{
"unusedFunction",
"unusedStructMember",
"unusedVariable",
"varScope",
"variableScope",
"virtualCallInConstructor"
};
Expand Down

0 comments on commit 03d482d

Please sign in to comment.