From: Wouter Admiraal Date: Tue, 23 Aug 2022 14:30:15 +0000 (+0200) Subject: SONAR-17206 Update code snippets to use new data attributes X-Git-Tag: 9.7.0.61563~335 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0ef79cc3e2fbedce2e6209ed05e9cbf5ceabdda6;p=sonarqube.git SONAR-17206 Update code snippets to use new data attributes --- diff --git a/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2codeSnippets.html b/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2codeSnippets.html index f54da216cb9..9889cbc5ebd 100644 --- a/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2codeSnippets.html +++ b/plugins/sonar-education-plugin/src/main/resources/org/sonar/education/2codeSnippets.html @@ -7,7 +7,7 @@
  • False negatives: when a loop condition is based on an element of an array or object.
  • 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.

    Noncompliant Code Example

    -
    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);