File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
java-checks-common/src/main/java/org/sonar/java/checks/helpers
java-checks-test-sources/default/src/main/java/checks Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 3636import org .sonar .plugins .java .api .tree .ClassTree ;
3737import org .sonar .plugins .java .api .tree .ExpressionTree ;
3838import org .sonar .plugins .java .api .tree .IdentifierTree ;
39+ import org .sonar .plugins .java .api .tree .LiteralTree ;
3940import org .sonar .plugins .java .api .tree .MemberSelectExpressionTree ;
4041import org .sonar .plugins .java .api .tree .MethodInvocationTree ;
4142import org .sonar .plugins .java .api .tree .NewArrayTree ;
@@ -80,6 +81,9 @@ public static String concatenate(@Nullable ExpressionTree tree) {
8081 IdentifierTree idt = (IdentifierTree ) expr ;
8182 pieces .push (idt .name ());
8283 }
84+ if (expr instanceof LiteralTree literal ) {
85+ pieces .push (literal .token ().text ());
86+ }
8387
8488 StringBuilder sb = new StringBuilder ();
8589 for (String piece : pieces ) {
Original file line number Diff line number Diff line change @@ -358,6 +358,11 @@ void quickFixes(List<String> strings) {
358358// ^^
359359 // fix@qf_cast2 {{Replace with "TestA[][].class::cast"}}
360360 // edit@qf_cast2 [[sc=10;ec=40]] {{TestA[][].class::cast}}
361+
362+ strings .stream ().allMatch (it -> "x1" .equals (it )); // Noncompliant {{Replace this lambda with method reference '"x1"::equals'.}} [[quickfixes=qf_str_lit]]
363+ // ^^
364+ // fix@qf_str_lit {{Replace with ""x1"::equals"}}
365+ // edit@qf_str_lit [[sc=31;ec=52]] {{"x1"::equals}}
361366 }
362367
363368 int notStatic (int x ) {
You can’t perform that action at this time.
0 commit comments