RedundantStringOperation: append("") (IDEA-180178), intern()

ConstantStringInternInspection removed
This commit is contained in:
Tagir Valeev
2017-10-11 14:32:26 +07:00
parent 454efb3280
commit 31b328cdca
18 changed files with 99 additions and 175 deletions

View File

@@ -0,0 +1,8 @@
// "Fix all 'Redundant String operation' problems in file" "true"
class Foo {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb = new StringBuilder();
sb.append("x");
}
}

View File

@@ -0,0 +1,7 @@
// "Remove redundant 'append' call" "true"
class Foo {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb.append("foo").append("bar");
}
}

View File

@@ -0,0 +1,4 @@
// "Remove redundant 'intern' call" "true"
class Foo {
private static final String x = ("Hello "+"World"+'!');
}

View File

@@ -1,4 +1,4 @@
// "Remove 'toString'" "true"
// "Remove redundant 'toString' call" "true"
class Foo {
public static void main(String[] args) {
/*valuable comment!!!*/

View File

@@ -1,4 +1,4 @@
// "Remove 'toString'" "false"
// "Remove redundant 'toString' call" "false"
class Foo {
public static void main(String[] args) {
Object[] a = args;

View File

@@ -0,0 +1,9 @@
// "Fix all 'Redundant String operation' problems in file" "true"
class Foo {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb.appe<caret>nd("");
(sb = new StringBuilder()).append("");
(sb.append("x")).append("");
}
}

View File

@@ -0,0 +1,7 @@
// "Remove redundant 'append' call" "true"
class Foo {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
sb.append("foo").ap<caret>pend(("")).append("bar");
}
}

View File

@@ -0,0 +1,4 @@
// "Remove redundant 'intern' call" "true"
class Foo {
private static final String x = ("Hello "+"World"+'!').inte<caret>rn();
}

View File

@@ -0,0 +1,4 @@
// "Remove redundant 'intern' call" "false"
class Foo {
private static final String x = ("Hello "+"World".trim()+'!').inte<caret>rn();
}

View File

@@ -1,4 +1,4 @@
// "Remove 'toString'" "true"
// "Remove redundant 'toString' call" "true"
class Foo {
public static void main(String[] args) {
String s = args[0].toString<caret>(/*valuable comment!!!*/);