-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The following codes is validated correctly:
@SuppressWarnings({"StringEquality"})
@Incorrect
public class Lint{
public static void main(String[] args){
String formatString = "--format";
if (args[0] == formatString) {
System.out.println("match");
}
}
}This code, which adds a suppression and has a comparison to a string literal, fails:
@SuppressWarnings({"StringEquality", "StringLiteralEqualityCheck"})
@Incorrect
public class Lint{
public static void main(String[] args) {
if (args[0] == "--format") {
System.out.println("match");
}
}
}I understand the error message that was displayed:
java.lang.IllegalStateException: Invalid error: edu.illinois.cs.cs125.questioner.lib.IncorrectFailedLinting: Incorrect code failed linting with checkstyle
Literal Strings should be compared using equals(), not '=='.
I do not understand how to suppress the error. From searching online, it appears I should disable StringLiteralEqualityCheck; however, doing so had no effect.
How do I know which warning to suppress?
This is low priority, because I can easily work around it.
Metadata
Metadata
Assignees
Labels
No labels