Inspectopedia 2025.2 Help

'public' method with 'boolean' parameter

Reports public methods that accept a boolean parameter.

It's almost always bad practice to add a boolean parameter to a public method (part of an API) if that method is not a setter. When reading code using such a method, it can be difficult to decipher what the boolean stands for without looking at the source or documentation.

This problem is also known as the boolean trap. The boolean parameter can often be replaced with an enum.

Example:

// Warning: it's hard to understand what the // boolean parameters mean when looking at // a call to this method public boolean setPermission(File f, int access, boolean enable, boolean ownerOnly) { // ... }

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.

BooleanParameter
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 | Abstraction issues

Use the Only report methods with multiple boolean parameters option to warn only when a method contains more than one boolean parameter.

Inspection options

Here you can find the description of settings available for the 'public' method with 'boolean' parameter inspection, and the reference of their default values.

Only report methods with multiple boolean parameters

Default value:

Not 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:

//noinspection BooleanParameter

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:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025