Inspectopedia Help

Class naming convention

Reports classes whose names are too short, too long, or do not follow the specified regular expression pattern.

Example: if the inspection is enabled for tests, and the specified length for the minimum class name is 8 (the default), the following test class produces a warning because the length of its name is 6, which is less than 8: public class MyTest{}.

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

Configure the inspection:

Use the list in the Options section to specify which classes should be checked. Deselect the checkboxes for the classes for which you want to skip the check.

For each class type, specify the minimum length, maximum length, and the regular expression expected for class names using the provided input fields. Specify 0 in the length fields to skip corresponding checks.

Regular expressions should be specified in the standard java.util.regex format.

Inspection options

Option

Type

Default

CheckboxPanel

None

Class

Checkbox

false

Pattern

String

[A-Z][A-Za-z\d]*

Min length

Number

8

Max length

Number

64

Abstract class

Checkbox

false

Use custom settings

Checkbox

true

Pattern

String

[A-Z][A-Za-z\d]*

Min length

Number

8

Max length

Number

64

Interface

Checkbox

false

Use custom settings

Checkbox

true

Pattern

String

[A-Z][A-Za-z\d]*

Min length

Number

8

Max length

Number

64

Enum class

Checkbox

false

Use custom settings

Checkbox

true

Pattern

String

[A-Z][A-Za-z\d]*

Min length

Number

8

Max length

Number

64

Annotation interface

Checkbox

false

Use custom settings

Checkbox

true

Pattern

String

[A-Z][A-Za-z\d]*

Min length

Number

8

Max length

Number

64

Type parameter

Checkbox

false

Pattern

String

[A-Z][A-Za-z\d]*

Min length

Number

1

Max length

Number

1

Test class

Checkbox

true

Pattern

String

[A-Z][A-Za-z\d]*Test(s|Case)?|Test[A-Z][A-Za-z\d]*|IT(.*)|(.*)IT(Case)?

Min length

Number

5

Max length

Number

255

Test suite

Checkbox

false

Pattern

String

[A-Z][A-Za-z\d]*Suite

Min length

Number

8

Max length

Number

64

Abstract test class

Checkbox

false

Pattern

String

[A-Z][A-Za-z\d]*TestCase

Min length

Number

12

Max length

Number

64

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023