]> source.dussan.org Git - sonarqube.git/blob
ef08cfed3acd2c11941d2df4f7e0a318c7172f01
[sonarqube.git] /
1 Example with 2 completely different code snippets
2
3 <h2>Noncompliant Code Example</h2>
4 <pre class="diff-id-1 diff-noncompliant">
5 while (true) { // Noncompliant; constant end condition
6   j++;
7 }
8
9 var k;
10 var b = true;
11 while (b) { // Noncompliant; constant end condition
12   k++;
13 }
14 </pre>
15 <h2>Compliant Solution</h2>
16 <pre class="diff-id-1 diff-compliant">while (true) { // break will potentially allow leaving the loop
17 var x = 3;
18 for(let i=2; i<4; i++) {
19     console.log("Hello there");
20 }
21 alert('Click here');
22 thisIsNiceFunction();
23 </pre>