Declaration access can be weaker
Reports fields, methods or classes that may have their access modifier narrowed down.
Example:
After the quick-fix is applied:
Use the inspection's options to define the rules for the modifier change suggestions.
Inspection options
Option | Type | Default |
---|---|---|
Suggest package-private visibility level for class members | Checkbox | true |
Suggest package-private visibility level for top-level classes | Checkbox | true |
Suggest 'private' for inner class members when referenced from outer class only | Checkbox | false |
Suggest weaker visibility for constants | Checkbox | true |
Suggest package-private visibility level for classes in exported packages (Java 9+) | Checkbox | true |
Suggest package-private visibility level for junit 5 tests | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |