From: Wouter Admiraal Noncompliant Code Example
-for (;;) { // Noncompliant; end condition omitted
+
for (;;) { // Noncompliant; end condition omitted
// ...
}
@@ -23,7 +23,7 @@ while (b) { // Noncompliant; constant end condition
}
Compliant Solution
-while (true) { // break will potentially allow leaving the loop
+
while (true) { // break will potentially allow leaving the loop
if (someCondition) {
break;
}
diff --git a/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2completelyDifferentSnippets.html b/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2completelyDifferentSnippets.html
index ef08cfed3ac..d251f4723c2 100644
--- a/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2completelyDifferentSnippets.html
+++ b/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2completelyDifferentSnippets.html
@@ -1,7 +1,7 @@
Example with 2 completely different code snippets
Noncompliant Code Example
-
+
while (true) { // Noncompliant; constant end condition
j++;
}
@@ -13,7 +13,7 @@ while (b) { // Noncompliant; constant end condition
}
Compliant Solution
-while (true) { // break will potentially allow leaving the loop
+
while (true) { // break will potentially allow leaving the loop
var x = 3;
for(let i=2; i<4; i++) {
console.log("Hello there");
diff --git a/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/4codeSnippets.html b/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/4codeSnippets.html
index b14c53f8602..1dba5b4431b 100644
--- a/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/4codeSnippets.html
+++ b/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/4codeSnippets.html
@@ -2,14 +2,14 @@
it bubble up automatically, but with more code and the additional detriment of leaving maintainers scratching their heads.
Such clauses should either be eliminated or populated with the appropriate logic.
try { +try { doSomething(); } catch (ex) { // Noncompliant throw ex; }Compliant Solution
-try { +try { doSomething(); } catch (ex) { console.err(ex); @@ -18,14 +18,14 @@Noncompliant Code Example
-try { +try { doSomethingElse(); } catch (ex) { // Noncompliant throw ex; }Compliant Solution
-try { +try { doSomethingElse(); } catch (ex) { console.err(ex);