[java-inspections] RedundantStringOperation: suggest using 'String#contentEquals' to compare strings with StringBuilder

IDEA-273162

GitOrigin-RevId: 89c0c2d697cec22b8d5c661f2063e35ccab9e9aa
This commit is contained in:
Andrey Cherkasov
2022-12-12 21:47:48 +04:00
committed by intellij-monorepo-bot
parent f88fdf391c
commit f0efafd51c
6 changed files with 87 additions and 16 deletions

View File

@@ -0,0 +1,6 @@
// "Use 'contentEquals()' and remove redundant 'toString()' call" "true-preview"
class Main {
boolean foo(String s, StringBuffer sb) {
return ((s)).contentEquals(((((sb)))));
}
}

View File

@@ -0,0 +1,6 @@
// "Use 'contentEquals()' and remove redundant 'toString()' call" "true-preview"
class Main {
boolean foo(String s, StringBuilder sb) {
return s.contentEquals(sb);
}
}

View File

@@ -0,0 +1,6 @@
// "Use 'contentEquals()' and remove redundant 'toString()' call" "true-preview"
class Main {
boolean foo(String s, StringBuffer sb) {
return ((s)).equals(((((sb)).toString<caret>())));
}
}

View File

@@ -0,0 +1,6 @@
// "Use 'contentEquals()' and remove redundant 'toString()' call" "true-preview"
class Main {
boolean foo(String s, StringBuilder sb) {
return s.equals(sb.toString<caret>());
}
}