Inspectopedia Help

Declaration access can be weaker

Reports fields, methods or classes that may have their access modifier narrowed down.

Example:

class Sample { void foo() { bar("foo", "foo"); } void bar(String x, String y) { } // can be private }

After the quick-fix is applied:

class Sample { void foo() { bar("foo", "foo"); } private void bar(String x, String y) { } }

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

Last modified: 13 July 2023