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:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
WeakerAccess- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Use the inspection's options to define the rules for the modifier change suggestions.
Inspection ID: WeakerAccess
Inspection options
Here you can find the description of settings available for the Declaration access can be weaker inspection, and the reference of their default values.
- Suggest package-private visibility level for class members
Option ID:
SUGGEST_PACKAGE_LOCAL_FOR_MEMBERSDefault value:
Selected- Suggest package-private visibility level for top-level classes
Option ID:
SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSESDefault value:
Selected- Suggest 'private' for inner class members when referenced from outer class only
Option ID:
SUGGEST_PRIVATE_FOR_INNERSDefault value:
Not selected- Suggest weaker visibility for constants
Option ID:
SUGGEST_FOR_CONSTANTSDefault value:
Selected- Suggest package-private visibility level for classes in exported packages (Java 9+)
Option ID:
ep.moduleInfoDefault value:
Selected- Suggest package-private visibility level for junit 5 tests
Option ID:
ep.junitDefault value:
Selected
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |