Skip to content

Commit

Permalink
Disable UnnecessaryAnonymousClass Error Prone pattern
Browse files Browse the repository at this point in the history
Is disabled by default as well.

It seems what this pattern does is suggest to replace anonymous classes
stored in constants with a corresponding method (with the intention that
the developer then uses a method reference to that method). But it even
does this when the anonymous class implements a custom functional type,
and not a generic type such as `Function`.

For example it suggested to replace
```
private static final FieldNamingStrategy CUSTOM_FIELD_NAMING_STRATEGY =
  new FieldNamingStrategy() {
    @OverRide
    public String translateName(Field f) {
      return "foo";
    }
  };
```

with a method
```
private static String customFieldNamingStrategy(Field f) {
  return "foo";
}
```

Which is probably not that helpful, and might not actually increase
readability.
  • Loading branch information
Marcono1234 committed Sep 23, 2024
1 parent 9ff1617 commit 029d528
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
-Xep:UngroupedOverloads:WARN <!-- required by style guide -->
-Xep:UnnecessarilyFullyQualified
-Xep:UnnecessarilyUsedValue
-Xep:UnnecessaryAnonymousClass
-Xep:UnnecessaryBoxedVariable:WARN
-Xep:UnnecessaryDefaultInEnumSwitch
-Xep:UnnecessaryFinal
Expand Down

0 comments on commit 029d528

Please sign in to comment.