Skip to content

Gendarme.Rules.Maintainability.AvoidLackOfCohesionOfMethodsRule(git)

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

AvoidLackOfCohesionOfMethodsRule

Assembly: Gendarme.Rules.Maintainability
Version: git

Description

This rule checks every type for lack of cohesion between the fields and the methods. Low cohesion is often a sign that a type is doing too many, different and unrelated things. The cohesion score is given for each defect (higher is better). Automatic properties (e.g. available in C# 3) are considered as fields since their 'backing field' cannot be directly used and the getter/setter is only used to update a single field.

Examples

Notes

  • This rule is available since Gendarme 2.0

Configuration

Some elements of this rule can be customized to better fit your needs.

LowSeverityLowerLimit

Defects with cohesion values greater than this will be reported at low severity.

MediumSeverityLowerLimit

Defects with cohesion values greater than (but less than LowSeverityLowerLimit) this will be reported at medium severity.

MinimumFieldCount

The minimum number of fields a class must have to be checked.

MinimumMethodCount

The minimum number of methods a class must have to be checked.

SuccessLowerLimit

Cohesion values lower than this will result in a defect.

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally