-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
JUnitMethodDeclaration
check
Implemented changes: - Ignore method overrides even if not annotated `@Override`. - Don't rename methods to `true`, `false` or `null`. - Don't rename methods to a name declared in a super type. This prevents e.g. renaming `testToString` to `toString`.
- Loading branch information
1 parent
0153c14
commit 33ac331
Showing
4 changed files
with
153 additions
and
32 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
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
32 changes: 32 additions & 0 deletions
32
...prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/util/JavaKeywordsTest.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,32 @@ | ||
package tech.picnic.errorprone.bugpatterns.util; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
final class JavaKeywordsTest { | ||
private static Stream<Arguments> isValidIdentifierTestCases() { | ||
return Stream.of( | ||
arguments("", false), | ||
arguments("public", false), | ||
arguments("true", false), | ||
arguments("false", false), | ||
arguments("null", false), | ||
arguments("0", false), | ||
arguments("\0", false), | ||
arguments("a%\0", false), | ||
arguments("a", true), | ||
arguments("a0", true), | ||
arguments("test", true)); | ||
} | ||
|
||
@MethodSource("isValidIdentifierTestCases") | ||
@ParameterizedTest | ||
void isValidIdentifier(String str, boolean expected) { | ||
assertThat(JavaKeywords.isValidIdentifier(str)).isEqualTo(expected); | ||
} | ||
} |