Inspectopedia Help

Redundant 'requires' directive in module-info

Reports redundant requires directives in Java Platform Module System module-info.java files. A requires directive is redundant when a module A requires a module B, but the code in module A doesn't import any packages or classes from B. Furthermore, all modules have an implicitly declared dependence on the java.base module, therefore a requires java.base; directive is always redundant.

The quick-fix deletes the redundant requires directive. If the deleted dependency re-exported modules that are actually used, the fix adds a requires directives for these modules.

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.

Java9RedundantRequiresStatement
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.

Settings or Preferences | Editor | Inspections | Java | Declaration redundancy

This inspection only reports if the language level of the project or module is 9 or higher.

New in 2017.1

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.2, Qodana for JVM 2024.2,

Can be installed with plugin:

Java, 242.22892

Last modified: 11 September 2024