File tree Expand file tree Collapse file tree 3 files changed +9
-14
lines changed
main/java/org/sonar/javascript/checks
java/org/sonar/javascript/checks Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 4444@ SqaleConstantRemediation ("5min" )
4545public class ForInCheck extends BaseTreeVisitor {
4646
47- private static final String MESSAGE = "Insert an if statement at the beginning of this loop to filter items ." ;
47+ private static final String MESSAGE = "Restrict what this loop acts on by testing each property ." ;
4848
4949 @ Override
5050 public void visitForInStatement (ForInStatementTree tree ) {
Original file line number Diff line number Diff line change 1919 */
2020package org .sonar .javascript .checks ;
2121
22+ import java .io .File ;
2223import org .junit .Test ;
24+ import org .sonar .javascript .checks .utils .JavaScriptCheckVerifier ;
2325import org .sonar .plugins .javascript .api .tests .TreeCheckTest ;
24- import org .sonar .squidbridge .checks .CheckMessagesVerifier ;
2526
2627public class ForInCheckTest extends TreeCheckTest {
2728
2829 @ Test
2930 public void test () {
30-
31- CheckMessagesVerifier .verify (getIssues ("src/test/resources/checks/forIn.js" , new ForInCheck ()))
32- .next ().atLine (1 ).withMessage ("Insert an if statement at the beginning of this loop to filter items." )
33- .next ().atLine (21 )
34- .next ().atLine (33 )
35- .next ().atLine (37 )
36- .noMore ();
31+ JavaScriptCheckVerifier .verify (new ForInCheck (), new File ("src/test/resources/checks/forIn.js" ));
3732 }
3833
3934}
Original file line number Diff line number Diff line change 1- for ( key in arr ) { // NOK
1+ for ( key in arr ) { // Noncompliant {{Restrict what this loop acts on by testing each property.}}
22 print ( arr [ key ] ) ;
33 print ( arr [ key ] ) ;
44}
@@ -18,7 +18,7 @@ for (name in object) { // OK
1818 print ( object [ name ] ) ;
1919}
2020
21- for ( key in arr ) { // NOK
21+ for ( key in arr ) { // Noncompliant
2222 function f ( ) { }
2323 print ( arr [ key ] ) ;
2424}
@@ -30,12 +30,12 @@ for (key in obj) { // OK
3030 a [ key ] = b [ key ] ;
3131}
3232
33- for ( key in obj ) { // NOK
33+ for ( key in obj ) { // Noncompliant
3434 val = b [ key ] ;
3535}
3636
37- for ( key in obj ) {
38- a . b = key ; // NOK
37+ for ( key in obj ) { // Noncompliant
38+ a . b = key ;
3939}
4040
4141
You can’t perform that action at this time.
0 commit comments