Inspectopedia Help

Class with too many fields

Reports classes whose number of fields exceeds the specified maximum.

Classes with a large number of fields are often trying to do too much. Consider splitting such a class into multiple smaller classes.

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.

ClassWithTooManyFields
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 | Class metrics

Configure the inspection:

  • Use the Field count limit field to specify the maximum allowed number of fields in a class.

  • Use the Include constant fields in count option to indicate whether constant fields should be counted.

  • By default only immutable static final objects are counted as constants. Use the 'static final' fields count as constant option to count any static final field as constant.

  • Use the Include enum constants in count option to specify whether enum constants in enum classes should be counted.

Inspection options

Here you can find the description of settings available for the Class with too many fields inspection, and the reference of their default values.

Field count limit

10

Include constant fields in count

Not selected

'static final' fields count as constant

Not selected

Include enum constants in count

Not selected

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