Inspectopedia 2024.3 Help

Boolean method name must start with question word

Reports boolean methods whose names do not start with a question word.

Boolean methods that override library methods are ignored by this inspection.

Example:

boolean empty(List<String> list) { return list.isEmpty(); }

A quick-fix that renames such methods is available only in the editor.

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.

BooleanMethodNameMustStartWithQuestion
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 | Naming conventions | Method

Configure the inspection:

  • Use the Boolean method name prefixes list to specify acceptable question words to start boolean method names with.

  • Use the Ignore methods with 'java.lang.Boolean' return type option to ignore methods with the java.lang.Boolean return type.

  • Use the Ignore boolean methods in an @interface option to ignore boolean methods in annotation types (@interface).

  • Use the Ignore methods overriding/implementing a super method to ignore methods the have supers.

Inspection options

Here you can find the description of settings available for the Boolean method name must start with question word inspection, and the reference of their default values.

Boolean method name prefixes

[are, can, check, contains, could, endsWith, equals, has, is, matches, must, shall, should, startsWith, was, were, will, would]

Ignore methods with 'java.lang.Boolean' return type

Not selected

Ignore methods overriding/implementing a super method

Default: Selected

Ignore boolean methods in an @interface

Default: Selected

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.3, Qodana for JVM 2024.3,

Can be installed with plugin:

Java, 243.23126

Last modified: 03 December 2024