open-policy-agent / open-policy-agent/java-opa-sdk
Relax Checkstyle MethodName for test sources
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 16
- Forks
- 24
- Avg merge
- 8h 17m
- Merged PRs (30d)
- 15
Description
383 of the 399 MethodName warnings are JUnit tests using the widely-adopted methodName_describesScenario convention, e.g.
findPropertyName_readsSerializedNameOnFieldfindPropertyName_ignoresAnnotationOnGetterfindPropertyName_returnsNullWhenUnannotated
The default Checkstyle pattern ^[a-z][a-zA-Z0-9]*$ rejects underscores. Renaming 383 tests would lose readable scenario labels for no benefit.
Proposed fix
Configure a separate, more permissive MethodName pattern for test sources. Simplest path is per-task configFile in the root build.gradle.kts:
```kotlin
tasks.named("checkstyleTest") {
configFile = rootProject.file("config/checkstyle/checkstyle-test.xml")
}
```
with checkstyle-test.xml overriding only MethodName:
```xml
```
This drops the count from 399 to 16 (the production offenders tracked in the rename issue) and means the test-naming convention is allowed by policy, not just by neglect.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the root build.gradle.kts and inspect the existing Checkstyle configuration, then compare it with the test sources and config/checkstyle/checkstyle-test.xml. Run the checkstyleTest task and verify that the test naming convention is accepted while the remaining production MethodName warnings stay reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100