From e07b01fd047d3702e70057cd4be9f2616997f5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lio=20Rocha?= Date: Wed, 28 Jan 2026 11:43:35 +0000 Subject: [PATCH] Removing cert from addons due to premium feature --- .gitignore | 4 ++ addons/description/description.json | 60 ------------------ addons/patterns.json | 62 ------------------- docs/description/description.json | 48 -------------- .../without-config-file/patterns.xml | 13 +++- .../without-config-file/results.xml | 5 ++ .../without-config-file/src/test.cpp | 30 +++++++++ docs/patterns.json | 50 --------------- src/main/scala/codacy/cppcheck/CPPCheck.scala | 3 +- 9 files changed, 52 insertions(+), 223 deletions(-) create mode 100644 docs/multiple-tests/without-config-file/src/test.cpp diff --git a/.gitignore b/.gitignore index fa60b13..dc842b4 100755 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ target/ #Ignore vscode AI rules .github/copilot-instructions.md + + +#Ignore vscode AI rules +.github/instructions/codacy.instructions.md diff --git a/addons/description/description.json b/addons/description/description.json index e55c61a..be7574f 100644 --- a/addons/description/description.json +++ b/addons/description/description.json @@ -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", diff --git a/addons/patterns.json b/addons/patterns.json index 53e42e4..aacf294 100644 --- a/addons/patterns.json +++ b/addons/patterns.json @@ -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", diff --git a/docs/description/description.json b/docs/description/description.json index af73f87..46b4bd1 100644 --- a/docs/description/description.json +++ b/docs/description/description.json @@ -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", diff --git a/docs/multiple-tests/without-config-file/patterns.xml b/docs/multiple-tests/without-config-file/patterns.xml index 89ce706..4579fa7 100644 --- a/docs/multiple-tests/without-config-file/patterns.xml +++ b/docs/multiple-tests/without-config-file/patterns.xml @@ -1,5 +1,16 @@ - + + + + + + + + + + + + diff --git a/docs/multiple-tests/without-config-file/results.xml b/docs/multiple-tests/without-config-file/results.xml index 4be2e03..4af31f6 100644 --- a/docs/multiple-tests/without-config-file/results.xml +++ b/docs/multiple-tests/without-config-file/results.xml @@ -8,4 +8,9 @@ + + + + + diff --git a/docs/multiple-tests/without-config-file/src/test.cpp b/docs/multiple-tests/without-config-file/src/test.cpp new file mode 100644 index 0000000..135c481 --- /dev/null +++ b/docs/multiple-tests/without-config-file/src/test.cpp @@ -0,0 +1,30 @@ +#include + +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; +} \ No newline at end of file diff --git a/docs/patterns.json b/docs/patterns.json index fc5bc1e..8f8f233 100644 --- a/docs/patterns.json +++ b/docs/patterns.json @@ -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", diff --git a/src/main/scala/codacy/cppcheck/CPPCheck.scala b/src/main/scala/codacy/cppcheck/CPPCheck.scala index 95ff854..7af39f6 100755 --- a/src/main/scala/codacy/cppcheck/CPPCheck.scala +++ b/src/main/scala/codacy/cppcheck/CPPCheck.scala @@ -54,7 +54,7 @@ object CPPCheck extends Tool { } val command: List[String] = List("cppcheck", "--enable=all") ++ - addonIfNeeded("cert") ++ + //addonIfNeeded("cert") ++ addonIfNeeded("y2038") ++ addonIfNeeded("threadsafety") ++ addonIfNeeded("misra", Some("addons/misra.json")) ++ @@ -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