google / google/error-prone

`ConstantNaming` not applied

Open
#5,277 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

It seems that [`RedundantStringConversion`](https://github.com/Pankraz76/spring-boot/pull/1) somehow is one of the few one always to be applied, but non of the others root checks.

- https://github.com/Pankraz76/spring-boot/pull/1
- https://github.com/Pankraz76/spring-framework/pull/2

Others like `UnusedMethod`, `UnusedVariable` and many more does not get applied despite it, the log shoes a `Did you mean` message, considering its patchable.

I can also confirm that sometimes the plugin like methods and stuff apply a lot by patching, until it fails to patch giving not the considered fix upfront.

config:
```
import static java.lang.System.getenv

apply plugin: 'net.ltgt.errorprone'

dependencies {
errorprone('com.google.errorprone:error_prone_core:2.42.0')
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.25.0')
constraints {
errorprone('com.google.guava:guava') {
version {
require('33.4.8-jre')
}
because('Older versions use deprecated methods in sun.misc.Unsafe')
// https://github.com/junit-team/junit-framework/pull/5039#discussion_r2414490581
}
}
}

tasks.withType(JavaCompile).configureEach {
options.errorprone {
disableAllChecks = true // consider removal to avoid error prone error´s, following convention over configuration.
error('RedundantStringConversion')
error('UnusedMethod')
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
errorproneArgs.addAll(
'-XepPatchLocation:IN_PLACE',
'-XepPatchChecks:UnusedMethod'
)
}
}
}
```

```
> Compilation failed; see the compiler output below.
/Users/vincent.potucek/IdeaProjects/spring-boot/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/ExportedImageTar.java:273: warning: [UnusedVariable] The parameter 'tarFile' is never read.
ManifestLayerArchiveFactory(Path tarFile, ImageArchiveManifest manifest) {
^
(see https://errorprone.info/bugpattern/UnusedVariable)
Did you mean 'ManifestLayerArchiveFactory(ImageArchiveManifest manifest) {'?
```

- https://github.com/spring-projects/spring-boot/pull/47694

### Describe the bug

- [ ] I have verified that the issue is reproducible against the latest version
of the project.
- [ ] I have searched through existing issues to verify that this issue is not
already known.

### Minimal Reproducible Example

- https://github.com/diffplug/spotless/pull/2687
- https://github.com/Pankraz76/junit5/pull/12
- https://github.com/PicnicSupermarket/error-prone-support/issues/1923

Its just the same code but does not apply on junit.

```java
If applicable and possible, please replace this section with the code that
triggered the isue.
```

Logs

```sh
Please replace this sentence with log output, if applicable.
```

### Expected behavior

### Setup

- Operating system (e.g. MacOS Monterey).
- Java version (i.e. `java --version`, e.g. `17.0.16`).
- Error Prone version (e.g. `2.41.0`).
- Error Prone Support version (e.g. `0.24.0`).

### Additional context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.