<li> False negatives: when a loop condition is based on an element of an array or object. </li>
</ul>
<h2>Noncompliant Code Example</h2>
-<pre class="diff-id-1 diff-noncompliant">for (;;) { // Noncompliant; end condition omitted
+<pre data-diff-id="example-1" data-diff-type="noncompliant">for (;;) { // Noncompliant; end condition omitted
// ...
}
}
</pre>
<h2>Compliant Solution</h2>
-<pre class="diff-id-1 diff-noncompliant">while (true) { // break will potentially allow leaving the loop
+<pre data-diff-id="example-1" data-diff-type="compliant">while (true) { // break will potentially allow leaving the loop
if (someCondition) {
break;
}
Example with 2 completely different code snippets
<h2>Noncompliant Code Example</h2>
-<pre class="diff-id-1 diff-noncompliant">
+<pre data-diff-id="1" data-diff-type="noncompliant">
while (true) { // Noncompliant; constant end condition
j++;
}
}
</pre>
<h2>Compliant Solution</h2>
-<pre class="diff-id-1 diff-compliant">while (true) { // break will potentially allow leaving the loop
+<pre data-diff-id="1" data-diff-type="compliant">while (true) { // break will potentially allow leaving the loop
var x = 3;
for(let i=2; i<4; i++) {
console.log("Hello there");
it bubble up automatically, but with more code and the additional detriment of leaving maintainers scratching their heads.</p>
<p>Such clauses should either be eliminated or populated with the appropriate logic.</p>
<h2>Noncompliant Code Example</h2>
-<pre class="diff-id-1 diff-noncompliant">try {
+<pre data-diff-id="1" data-diff-type="noncompliant">try {
doSomething();
} catch (ex) { // Noncompliant
throw ex;
}
</pre>
<h2>Compliant Solution</h2>
-<pre class="diff-id-1 diff-compliant">try {
+<pre data-diff-id="1" data-diff-type="compliant">try {
doSomething();
} catch (ex) {
console.err(ex);
</pre>
<h2>Noncompliant Code Example</h2>
-<pre class="diff-id-2 diff-noncompliant">try {
+<pre data-diff-id="2" data-diff-type="noncompliant">try {
doSomethingElse();
} catch (ex) { // Noncompliant
throw ex;
}
</pre>
<h2>Compliant Solution</h2>
-<pre class="diff-id-2 diff-compliant">try {
+<pre data-diff-id="2" data-diff-type="compliant">try {
doSomethingElse();
} catch (ex) {
console.err(ex);