From 877f688fb54e6b9ff439ca219af3ba9a3a63c9c2 Mon Sep 17 00:00:00 2001 From: michael-jabbour-sonarsource Date: Mon, 27 Oct 2025 08:30:33 +0000 Subject: [PATCH 1/2] Create rule S8230 --- rules/S8230/cfamily/metadata.json | 25 ++++++++++++++++++ rules/S8230/cfamily/rule.adoc | 44 +++++++++++++++++++++++++++++++ rules/S8230/metadata.json | 2 ++ 3 files changed, 71 insertions(+) create mode 100644 rules/S8230/cfamily/metadata.json create mode 100644 rules/S8230/cfamily/rule.adoc create mode 100644 rules/S8230/metadata.json diff --git a/rules/S8230/cfamily/metadata.json b/rules/S8230/cfamily/metadata.json new file mode 100644 index 00000000000..d4e318dcec9 --- /dev/null +++ b/rules/S8230/cfamily/metadata.json @@ -0,0 +1,25 @@ +{ + "title": "FIXME", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "5min" + }, + "tags": [ + ], + "defaultSeverity": "Major", + "ruleSpecification": "RSPEC-8230", + "sqKey": "S8230", + "scope": "All", + "defaultQualityProfiles": ["Sonar way"], + "quickfix": "unknown", + "code": { + "impacts": { + "MAINTAINABILITY": "HIGH", + "RELIABILITY": "MEDIUM", + "SECURITY": "LOW" + }, + "attribute": "CONVENTIONAL" + } +} diff --git a/rules/S8230/cfamily/rule.adoc b/rules/S8230/cfamily/rule.adoc new file mode 100644 index 00000000000..69c2a03a830 --- /dev/null +++ b/rules/S8230/cfamily/rule.adoc @@ -0,0 +1,44 @@ +FIXME: add a description + +// If you want to factorize the description uncomment the following line and create the file. +//include::../description.adoc[] + +== Why is this an issue? + +FIXME: remove the unused optional headers (that are commented out) + +//=== What is the potential impact? + +== How to fix it +//== How to fix it in FRAMEWORK NAME + +=== Code examples + +==== Noncompliant code example + +[source,cpp,diff-id=1,diff-type=noncompliant] +---- +FIXME +---- + +==== Compliant solution + +[source,cpp,diff-id=1,diff-type=compliant] +---- +FIXME +---- + +//=== How does this work? + +//=== Pitfalls + +//=== Going the extra mile + + +//== Resources +//=== Documentation +//=== Articles & blog posts +//=== Conference presentations +//=== Standards +//=== External coding guidelines +//=== Benchmarks diff --git a/rules/S8230/metadata.json b/rules/S8230/metadata.json new file mode 100644 index 00000000000..2c63c085104 --- /dev/null +++ b/rules/S8230/metadata.json @@ -0,0 +1,2 @@ +{ +} From ba88cdea7f6190fd431c34b230052d7ced25f012 Mon Sep 17 00:00:00 2001 From: Michael Jabbour Date: Thu, 30 Oct 2025 14:44:52 +0100 Subject: [PATCH 2/2] WIP --- rules/S8230/cfamily/metadata.json | 13 ++++----- rules/S8230/cfamily/rule.adoc | 47 +++++++++---------------------- 2 files changed, 19 insertions(+), 41 deletions(-) diff --git a/rules/S8230/cfamily/metadata.json b/rules/S8230/cfamily/metadata.json index d4e318dcec9..ada735a4a23 100644 --- a/rules/S8230/cfamily/metadata.json +++ b/rules/S8230/cfamily/metadata.json @@ -1,5 +1,5 @@ { - "title": "FIXME", + "title": "MSVC-specific extensions should not be used", "type": "CODE_SMELL", "status": "ready", "remediation": { @@ -7,18 +7,17 @@ "constantCost": "5min" }, "tags": [ + "lock-in" ], - "defaultSeverity": "Major", + "defaultSeverity": "Minor", "ruleSpecification": "RSPEC-8230", "sqKey": "S8230", "scope": "All", - "defaultQualityProfiles": ["Sonar way"], - "quickfix": "unknown", + "defaultQualityProfiles": [], + "quickfix": "infeasible", "code": { "impacts": { - "MAINTAINABILITY": "HIGH", - "RELIABILITY": "MEDIUM", - "SECURITY": "LOW" + "MAINTAINABILITY": "LOW" }, "attribute": "CONVENTIONAL" } diff --git a/rules/S8230/cfamily/rule.adoc b/rules/S8230/cfamily/rule.adoc index 69c2a03a830..dfa109273fe 100644 --- a/rules/S8230/cfamily/rule.adoc +++ b/rules/S8230/cfamily/rule.adoc @@ -1,44 +1,23 @@ -FIXME: add a description - -// If you want to factorize the description uncomment the following line and create the file. -//include::../description.adoc[] +MSVC-specific extensions should not be used == Why is this an issue? -FIXME: remove the unused optional headers (that are commented out) - -//=== What is the potential impact? +Proprietary compiler extensions can be handy, but they commit you to always using that compiler. This rule raises an issue when MSVC-specific extensions are used. Other compilers will reject such code, making it non-portable. Keeping code standard-conforming ensures consistency across different compilers and platforms. == How to fix it -//== How to fix it in FRAMEWORK NAME - -=== Code examples - -==== Noncompliant code example - -[source,cpp,diff-id=1,diff-type=noncompliant] ----- -FIXME ----- - -==== Compliant solution - -[source,cpp,diff-id=1,diff-type=compliant] ----- -FIXME ----- -//=== How does this work? +Replace MSVC-specific extensions with standard-conforming alternatives. -//=== Pitfalls +//=== Code examples +// +//Code examples will be added here. -//=== Going the extra mile +== Resources +=== Related rules -//== Resources -//=== Documentation -//=== Articles & blog posts -//=== Conference presentations -//=== Standards -//=== External coding guidelines -//=== Benchmarks +* S8216 - Code should not rely on features beyond the configured {cpp} standard +* S3715 - GNU extensions should not be used +* S8231 - Non-standard attributes should not be used +* S4263 reports uses of MSVC-specific include file search strategy +* S2260 tracks parsing failures and can help identify compiler-specific extensions that the analyzer fails to recognize