-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #13345: Enable examples tests for StringLiteralEqualityCheck
- Loading branch information
1 parent
aadc377
commit 3015216
Showing
5 changed files
with
53 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...sources/com/puppycrawl/tools/checkstyle/checks/coding/stringliteralequality/Example1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="StringLiteralEquality"/> | ||
</module> | ||
</module> | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.stringliteralequality; | ||
|
||
// xdoc section -- start | ||
class Example1 { | ||
String getName(){ | ||
return "Y"; | ||
} | ||
void InvalidExample(){ | ||
String status = "pending"; | ||
// violation below, 'Literal Strings should be compared using equals(), not '=='' | ||
if (status == "done") {} | ||
// violation below, 'Literal Strings should be compared using equals(), not '!='' | ||
while (status != "done") {} | ||
// violation below, 'Literal Strings should be compared using equals(), not '=='' | ||
boolean flag = (status == "done"); | ||
boolean flag1 = (status.equals("done")); | ||
String name = "X"; | ||
if (name == getName()) {} | ||
// OK, limitation that check cannot tell runtime type returned from method call | ||
} | ||
} | ||
// xdoc section -- end |
24 changes: 0 additions & 24 deletions
24
...esources/com/puppycrawl/tools/checkstyle/checks/coding/stringliteralequality/Example1.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters