RedundantStringOperation: refactored to CallMapper; indexOf/startsWith/lastIndexOf scenarios

Fixes IDEA-191536 More redundant string operations with indexOf lastIndexOf startsWith
This commit is contained in:
Tagir Valeev
2018-05-10 12:01:59 +07:00
parent 098944f489
commit 4861c7cc17
10 changed files with 216 additions and 116 deletions
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
int test(String foo) {
return foo.indexOf("bar");
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
int test(String foo) {
return foo.lastIndexOf("bar");
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
int test(String foo) {
return foo.lastIndexOf("bar");
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
boolean test(String foo) {
return foo.startsWith("bar");
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
int test(String foo) {
return foo.indexOf("bar", <caret>0);
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
int test(String foo) {
return foo.lastIndexOf("bar", <caret>foo.length());
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
int test(String foo) {
return foo.lastIndexOf("bar", <caret>((foo.length())-1));
}
}
@@ -0,0 +1,6 @@
// "Remove argument" "true"
class Foo {
boolean test(String foo) {
return foo.startsWith("bar", (<caret>0));
}
}