-
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 (#406)
Implemented changes: - Ignore method overrides even if not annotated with `@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
5665470
commit 6313bd5
Showing
4 changed files
with
155 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
34 changes: 34 additions & 0 deletions
34
...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,34 @@ | ||
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() { | ||
/* { str, expected } */ | ||
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("_a0", true), | ||
arguments("test", true)); | ||
} | ||
|
||
@MethodSource("isValidIdentifierTestCases") | ||
@ParameterizedTest | ||
void isValidIdentifier(String str, boolean expected) { | ||
assertThat(JavaKeywords.isValidIdentifier(str)).isEqualTo(expected); | ||
} | ||
} |