File tree Expand file tree Collapse file tree
main/java/org/sonar/java/checks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818
1919import java .util .Arrays ;
2020import java .util .HashSet ;
21+ import java .util .Iterator ;
2122import java .util .List ;
2223import java .util .Set ;
2324import org .sonar .check .Rule ;
@@ -58,8 +59,8 @@ private void checkBlock(Block block) {
5859 && !isSwitchCaseChild (terminator )) {
5960
6061 successorWithoutJump = nonEmptySuccessor (successorWithoutJump );
61- Block successor = nonEmptySuccessor ( block .successors ().iterator (). next () );
62- if (successorWithoutJump . equals (successor )) {
62+ Iterator < Block > successors = block .successors ().iterator ();
63+ if (successors . hasNext () && nonEmptySuccessor ( successors . next ()). equals (successorWithoutJump )) {
6364 reportIssue (terminator , "Remove this redundant jump." );
6465 }
6566 }
Original file line number Diff line number Diff line change @@ -120,4 +120,11 @@ public void throwing_exception() {
120120
121121 public abstract void abstract_method ();
122122
123+ void undefinedLabel (int values []) {
124+ for (int v : values ) {
125+ if (v == 2 ) {
126+ continue label ; // this should be a compiler error, but we want to test that the check does not crash
127+ }
128+ }
129+ }
123130}
You can’t perform that action at this time.
0 commit comments