mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
substring(x, x+y.length()).equals(y) -> startsWith(y, x) (IDEA-226148, case#1)
GitOrigin-RevId: 04fe1be3e9f48783ad8d95897497ea55109453f5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7f8d9a2372
commit
476b3ff5bb
@@ -0,0 +1,13 @@
|
||||
// "Fix all 'Redundant String operation' problems in file" "true"
|
||||
class X {
|
||||
void test(String s, int pos, String s2) {
|
||||
if (s.startsWith("xyzt", pos)) { }
|
||||
if (s.substring(pos, pos + 5).equals("xyzt")) { }
|
||||
if (s.startsWith(s2, pos)) { }
|
||||
if (s.startsWith(s2, pos)) { }
|
||||
if (s.substring(pos, pos + pos).equals(s2)) { }
|
||||
if (s.startsWith("xyzt")) { }
|
||||
if (s.startsWith("xyzt", 1)) { }
|
||||
if (s.startsWith("xyzt", 1)) { }
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,6 @@ class X {
|
||||
int posBounded = s.substring(10, 20).indexOf("foo");
|
||||
int posChar = s.indexOf('f', 10);
|
||||
int posIdx = s.substring(10).indexOf('f', 2);
|
||||
int posFromZero = s.indexOf("xyzt") > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Fix all 'Redundant String operation' problems in file" "true"
|
||||
class X {
|
||||
void test(String s, int pos, String s2) {
|
||||
if (s.sub<caret>string(pos, pos + 4).equals("xyzt")) { }
|
||||
if (s.substring(pos, pos + 5).equals("xyzt")) { }
|
||||
if (s.substring(pos, pos + s2.length()).equals(s2)) { }
|
||||
if (s.substring(pos, s2.length() + pos).equals(s2)) { }
|
||||
if (s.substring(pos, pos + pos).equals(s2)) { }
|
||||
if (s.substring(0, 4).equals("xyzt")) { }
|
||||
if (s.substring(1, 5).equals("xyzt")) { }
|
||||
if (s.substring(1, 1+"xyzt".length()).equals("xyzt")) { }
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,6 @@ class X {
|
||||
int posBounded = s.substring(10, 20).indexOf("foo");
|
||||
int posChar = s.substring(10).indexOf('f');
|
||||
int posIdx = s.substring(10).indexOf('f', 2);
|
||||
int posFromZero = s.substring(0).indexOf("xyzt") > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user