Skip to main content

Removed redundant static flag on enum (Sonar)

sonar:java/remove-redundant-static-s2786

ImportanceReview GuidanceRequires Scanning Tool
LOWMerge Without ReviewYes (Sonar)

This change removes redundant (and possibly misleading) static keywords on enum types defined within classes. All enum types that are nested within another type are automatically static, and so listing the flag this clutters the code, and may cause confusion when reasoning about it.

Our changes look something like this:

  @RestController
final class CheckStatusController {

- static enum ResponseType {
+ enum ResponseType {
SUCCESS,
FAILURE,
ERROR
}

F.A.Q.

Why is this codemod marked as Merge Without Review?

There are no functional changes after this change, but the code will be easier to understand.

References