Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ target/

#Ignore vscode AI rules
.github/copilot-instructions.md


#Ignore vscode AI rules
.github/instructions/codacy.instructions.md
60 changes: 0 additions & 60 deletions addons/description/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,6 @@
"title" : "Locate for threadsafety issues",
"timeToFix" : 5
},
{
"patternId" : "cert-EXP05-C",
"title" : "Do not attempt to cast away const",
"timeToFix" : 5
},
{
"patternId" : "cert-EXP42-C",
"title" : "Do not compare padding data",
"timeToFix" : 5
},
{
"patternId" : "cert-EXP15-C",
"title" : "Do not place a semicolon on the same line as an if, for or while statement",
"timeToFix" : 5
},
{
"patternId" : "cert-EXP46-c",
"title" : "Do not use a bitwise operator with a Boolean-like operand",
"timeToFix" : 5
},
{
"patternId" : "cert-INT31-c",
"title" : "Ensure that integer conversions do not result in lost or misinterpreted data",
"timeToFix" : 5
},
{
"patternId" : "cert-MSC24-C",
"title" : "Do not use deprecated or obsolescent functions",
"timeToFix" : 5
},
{
"patternId" : "cert-MSC30-c",
"title" : "Do not use the rand() function for generating pseudorandom numbers",
"timeToFix" : 5
},
{
"patternId" : "cert-STR03-C",
"title" : "Do not inadvertently truncate a string",
"timeToFix" : 5
},
{
"patternId" : "cert-STR05-C",
"title" : "Use pointers to const when referring to string literals",
"timeToFix" : 5
},
{
"patternId" : "cert-STR07-C",
"title" : "Use the bounds-checking interfaces for string manipulation",
"timeToFix" : 5
},
{
"patternId" : "cert-STR11-C",
"title" : "Do not specify the bound of a character array initialized with a string literal",
"timeToFix" : 5
},
{
"patternId" : "cert-API01-C",
"title" : "Avoid laying out strings in memory directly before sensitive data",
"timeToFix" : 5
},
{
"patternId" : "y2038-type-bits-not-64",
"title" : "_TIME_BITS must be defined equal to 64",
Expand Down
62 changes: 0 additions & 62 deletions addons/patterns.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,6 @@
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-EXP05-C",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-EXP42-C",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-EXP15-C",
"level" : "Info",
"category" : "CodeStyle"
},
{
"patternId" : "cert-EXP46-c",
"level" : "Warning",
"category" : "CodeStyle"
},
{
"patternId" : "cert-INT31-c",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-MSC24-C",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-MSC30-c",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-STR03-C",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-STR05-C",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-STR07-C",
"level" : "Warning",
"category" : "Security",
"subCategory" : "InsecureModulesLibraries"
},
{
"patternId" : "cert-STR11-C",
"level" : "Warning",
"category" : "ErrorProne"
},
{
"patternId" : "cert-API01-C",
"level" : "Warning",
"category" : "Security",
"subCategory" : "UnexpectedBehaviour"
},
{
"patternId" : "y2038-type-bits-not-64",
"level" : "Error",
Expand Down
48 changes: 0 additions & 48 deletions docs/description/description.json
Original file line number Diff line number Diff line change
Expand Up @@ -1612,54 +1612,6 @@
"patternId" : "threadsafety-threadsafety",
"title" : "Locate for threadsafety issues",
"timeToFix" : 5
}, {
"patternId" : "cert-EXP05-C",
"title" : "Do not attempt to cast away const",
"timeToFix" : 5
}, {
"patternId" : "cert-EXP42-C",
"title" : "Do not compare padding data",
"timeToFix" : 5
}, {
"patternId" : "cert-EXP15-C",
"title" : "Do not place a semicolon on the same line as an if, for or while statement",
"timeToFix" : 5
}, {
"patternId" : "cert-EXP46-c",
"title" : "Do not use a bitwise operator with a Boolean-like operand",
"timeToFix" : 5
}, {
"patternId" : "cert-INT31-c",
"title" : "Ensure that integer conversions do not result in lost or misinterpreted data",
"timeToFix" : 5
}, {
"patternId" : "cert-MSC24-C",
"title" : "Do not use deprecated or obsolescent functions",
"timeToFix" : 5
}, {
"patternId" : "cert-MSC30-c",
"title" : "Do not use the rand() function for generating pseudorandom numbers",
"timeToFix" : 5
}, {
"patternId" : "cert-STR03-C",
"title" : "Do not inadvertently truncate a string",
"timeToFix" : 5
}, {
"patternId" : "cert-STR05-C",
"title" : "Use pointers to const when referring to string literals",
"timeToFix" : 5
}, {
"patternId" : "cert-STR07-C",
"title" : "Use the bounds-checking interfaces for string manipulation",
"timeToFix" : 5
}, {
"patternId" : "cert-STR11-C",
"title" : "Do not specify the bound of a character array initialized with a string literal",
"timeToFix" : 5
}, {
"patternId" : "cert-API01-C",
"title" : "Avoid laying out strings in memory directly before sensitive data",
"timeToFix" : 5
}, {
"patternId" : "y2038-type-bits-not-64",
"title" : "_TIME_BITS must be defined equal to 64",
Expand Down
13 changes: 12 additions & 1 deletion docs/multiple-tests/without-config-file/patterns.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<module name="root">
<module name="unreadVariable" />
<module name="invalidIterator1" />
<module name="unusedLabel" />
<module name="invalidIterator1" />
<module name="nullPointer" />
<module name="nullPointerDefaultArg" />
<module name="nullPointerRedundantCheck" />
<module name="nullPointerOutOfMemory" />
<module name="nullPointerOutOfResources" />
<module name="nullPointerArithmetic" />
<module name="nullPointerArithmeticRedundantCheck" />
<module name="threadsafety-threadsafety" />
<module name="y2038-type-bits-not-64" />
<module name="y2038-type-bits-undef" />
<module name="y2038-unsafe-call" />
</module>
5 changes: 5 additions & 0 deletions docs/multiple-tests/without-config-file/results.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
<file name="unusedLabel.cpp">
<error source="unusedLabel" line="8" message="Label 'Test2' is not used." severity="info" />
</file>
<file name="test.cpp">
<error source="nullPointer" line="9" message="Null pointer dereference: ptr" severity="error" />
<error source="nullPointer" line="11" message="Null pointer dereference: ptr" severity="error" />
<error source="nullPointerRedundantCheck" line="16" message="Either the condition 'x==nullptr' is redundant or there is possible null pointer dereference: x." severity="warning" />
</file>
</checkstyle>
30 changes: 30 additions & 0 deletions docs/multiple-tests/without-config-file/src/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>

void causeNullPointerError() {
int* ptr = nullptr; // 1. Pointer is explicitly set to NULL

// ... some other logic ...

// 2. ERROR: Dereferencing the null pointer
*ptr = 42;

std::cout << "Value: " << *ptr << std::endl;
}

void checkAfterDereference(int* x) {
// 3. ERROR: Dereferencing 'x' before checking if it is null
*x = 10;

if (x == nullptr) {
return;
}
}

int main() {
causeNullPointerError();

int* val = nullptr;
checkAfterDereference(val);

return 0;
}
50 changes: 0 additions & 50 deletions docs/patterns.json
Original file line number Diff line number Diff line change
Expand Up @@ -1615,56 +1615,6 @@
"patternId" : "threadsafety-threadsafety",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-EXP05-C",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-EXP42-C",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-EXP15-C",
"level" : "Info",
"category" : "CodeStyle"
}, {
"patternId" : "cert-EXP46-c",
"level" : "Warning",
"category" : "CodeStyle"
}, {
"patternId" : "cert-INT31-c",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-MSC24-C",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-MSC30-c",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-STR03-C",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-STR05-C",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-STR07-C",
"level" : "Warning",
"category" : "Security",
"subCategory" : "InsecureModulesLibraries"
}, {
"patternId" : "cert-STR11-C",
"level" : "Warning",
"category" : "ErrorProne"
}, {
"patternId" : "cert-API01-C",
"level" : "Warning",
"category" : "Security",
"subCategory" : "UnexpectedBehaviour"
}, {
"patternId" : "y2038-type-bits-not-64",
"level" : "Error",
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/codacy/cppcheck/CPPCheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object CPPCheck extends Tool {
}

val command: List[String] = List("cppcheck", "--enable=all") ++
addonIfNeeded("cert") ++
//addonIfNeeded("cert") ++
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having addonIfNeeded("cert") left in as a commented-out call makes it unclear whether this add-on is intentionally and permanently disabled or just temporarily turned off. To improve maintainability, consider either removing the dead code entirely or replacing it with a short comment that explicitly states that the CERT add-on is a premium-only feature and therefore intentionally not enabled here.

Suggested change
//addonIfNeeded("cert") ++
// CERT add-on is a premium-only feature and is intentionally not enabled here.

Copilot uses AI. Check for mistakes.
addonIfNeeded("y2038") ++
addonIfNeeded("threadsafety") ++
addonIfNeeded("misra", Some("addons/misra.json")) ++
Expand All @@ -68,7 +68,6 @@ object CPPCheck extends Tool {
"""--template={"patternId":"{id}","file":"{file}","line":"{line}","message":"{message}"}"""
) ++
filesToLint

CommandRunner.exec(command) match {
case Right(resultFromTool) =>
val output = resultFromTool.stdout ++ resultFromTool.stderr
Expand Down