Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantStringOperation/beforeSubstringOneCharInEquals.java
Nikita Eshkeev 0aa2e160b0 [codeInsight] IDEA-219640 Inspection to detect some pointless String.substring
This patch fixes the notes from the review, it includes:

- restoring annotation.naming.convention.display.name
- using com.intellij.openapi.util.Pair instead of custom private objects
- using EquivalenceChecker.expressionsMatch in order to extract
difference between two PsiBinaryExpression
- using BoolUtils.findNegation to properly deduce the sign of the equals
clause
- restoring comments while replacing substring with charAt
- properly handling special characters (e.g. '\\', '\n', '\"', etc.) in
equals clause when it is converted to charAt + "=="
- eliminating the imperative form of a message for the inspection of
substring + equals

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: be1dfd53a6af10979485cd172af39653faafb744
2020-04-17 22:57:24 +00:00

12 lines
392 B
Java

// "Fix all 'Redundant String operation' problems in file" "true"
class Foo {
public static void main(String[] args) {
boolean value = args[0].substring(4, 5).equals("_");
if(args[0].sub<caret>string(4, 5).equals("_")) { }
if(!args[0].substring(4, 5).equals("_")) { }
if(!!args[0].substring(4, 5).equals("_")) { }
if(!!!!!args[0].substring(4, 5).equals("_")) { }
}
}