CQM-IncorrectNameLength

The names of artifacts shall not be too short or too long

Required inputs: IR, RFG

Any data member whose name does not have between 2 and 50 characters, is a violation.

Motivation

Designators of software artefacts must be expressive on the one hand and allow conclusions to be drawn about their purpose, but on the other hand they must still be legible and memorable. Artifact names chosen in this way increase the readability of the code and thus its maintainability. It is counterproductive with regard to naming,

  • if the length of the artefact name becomes too great, i.e. can only be read and perceived with increased effort, and
  • if the length of the artefact name is too small, i.e. hardly conveys any content and there is a great risk of having artifacts with the same name in the system (which may then cause an unconscious attribute overlap, for example).

This rule is based on the CQM Quality Indicator: falsche Namenslänge (p. 186-188).

Reference

Simon, Frank/ Seng, Olaf/ Mohaupt, Thomas (2006): Code-Quality-Management: Technische Qualität industrieller Softwaresysteme transparent und vergleichbar gemacht, 1st ed., Heidelberg, Germany: dpunkt.verlag GmbH.

Possible Messages

Key

Text

Severity

Disabled

name_to_long

The name of this member has {val} characters, it should have no more than {max_length}.

None

False

name_to_short

The name of this member has only {val} characters, it should have at least {min_length}.

None

False

Options

examined_types

examined_types

Type: set[ExaminableTypes]

Default: {'Class', 'Constant', 'Member', 'Namespace', 'Routine', 'Variable'}

Artifact types for which this metric is applied. This includes subtypes of the given types.
 

include_anonymous_artifacts

include_anonymous_artifacts : bool = False

Determines whether anonymous artifacts are considered by the metric.
 

max_length

max_length : int | None = 50

Maximal allowed length of an artifact name.
 

min_length

min_length : int | None = 2

Minimal allowed length of an artifact name.
 

Option Types

These types are used by options listed above:

ExaminableTypes

An enumeration.
 
  • Macro

  • Namespace

  • Package

  • Class

  • Interface

  • Routine

  • Member

  • Constant

  • Variable

  • Class_Template

  • Routine_Template