Inspectopedia Help

Non-boolean method name must not start with question word

Reports non-boolean methods whose names start with a question word. Such method names may be confusing.

Non-boolean methods that override library methods are ignored by this inspection.

Example:

public void hasName(String name) { assert names.contains(name); }

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

Configure the inspection:

  • Use the Boolean method name prefixes list to specify the question words that should be used only for boolean methods.

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

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

Inspection options

Option

Type

Default

Boolean method name prefixes

StringList

[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

Checkbox

false

Ignore methods overriding/implementing a super method

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023