Classes should not have too many fields

Description

A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain, and having a lot of fields is an indication that a class has grown too large.

Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

Message

Refactor this class so it has no more than {0} [public] fields, rather than the {1} it currently has.

Highlighting

None

List of parameters

Key: maximumFieldThreshold
Description: The maximum number of fields
Default Value: 20

Key: countNonpublicFields
Description: Whether or not to include non-public fields in the count
Default Value: true

0% Done
Loading...

Activity

Show:

Ann Campbell November 19, 2015 at 4:13 PM

I confirm

Evgeny Mandrikov November 19, 2015 at 4:01 PM

I guess that count doesn't include inherited fields. Do you confirm?

Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Labels

Default Severity

Major

Targeted languages

ABAP
C#
Cobol
JavaScript
Python
VB.Net

Covered Languages

C
C++
Flex
Java
Objective-C
PHP

Remediation Function

Constant/Issue

Constant Cost

Analysis Scope

Main Sources

Sentry

Created June 24, 2014 at 5:46 PM
Updated March 22, 2021 at 4:47 PM