C#

C# Metrics

Constant Data

  • Mnemonic ACST

  • Description Number of constant data

Internal Data

  • Mnemonic AINT

  • Description Number of internal data (only applicable to C#)

Number of Attributes

  • Mnemonic ANBR

  • Description Number of attributes

Number of data without accessibility

  • Mnemonic ANON

  • Description Number of data without accessibility

Andthen Operators

  • Mnemonic ANTH

  • Description Number of 'andthen' operators

Public Data

  • Mnemonic APBL

  • Description Number of public data

Protected Internal Data

  • Mnemonic APIN

  • Description Number of protected internal data (only applicable to C#)

Protected Data

  • Mnemonic APRT

  • Description Number of protected data

Private data

  • Mnemonic APRV

  • Description Number of private data

Assignment Operators

  • Mnemonic ASOP

  • Description Number of assignment operators used in the source file

Static Data

  • Mnemonic ASTA

  • Description Number of static data

Number of comment blocks

  • Mnemonic BCOM

  • Description Number of comment blocks.

Header Blocks Of Comment

  • Mnemonic BHCO

  • Description Number block of comment placed before the beginning of the artefact.

Blank Lines

  • Mnemonic BLAN

  • Description Number of blank lines of code in the source file(s).

Brace Lines

  • Mnemonic BRAC

  • Description Number of lines of code containing only a brace in the source file(s).

Break in Loop

  • Mnemonic BRKL

  • Description Number of 'break' statements in loop in the function

Break in Switch

  • Mnemonic BRKS

  • Description Number of 'break' statements in 'switch' in the function

Case Blocks

  • Mnemonic CABL

  • Description Number of 'case' blocks in 'switch' in the function

Case Labels

  • Mnemonic CASE

  • Description Number of 'case' labels in the function

Catch Statements

  • Mnemonic CATC

  • Description Number of 'catch' statements in the function

Cyclomatic Complexity

  • Mnemonic CCN

  • Description Number of linearly independent paths in the function control graph.

Control Flow Token

  • Mnemonic CFT

  • Description Number of tokens in the control flow of functions

Call Graph Depth

  • Mnemonic CGDM

  • Description Maximum depth of the call graph.

Comment Lines

  • Mnemonic CLOC

  • Description Number of lines of comments in the source file(s).

Continue Statements

  • Mnemonic CONT

  • Description Number of 'continue' statements in the function

Comparison Operators

  • Mnemonic CPOP

  • Description Number of comparison operators used in the source file

Commented Statements

  • Mnemonic CSTAT

  • Description Number of Commented Statements.

Minimum Number of Cycles

  • Mnemonic CYCL

  • Description Minimum number of call graph cycles in which the function is involved (including recursivity).

Depth of Descendant Tree

  • Mnemonic DDT

  • Description Maximun depth of the inheritance tree from the class

Default Statement

  • Mnemonic DEFT

  • Description Number of 'default' blocks in 'switch' in the function

Depth of Inheritance Tree

  • Mnemonic DIT

  • Description Maximun depth of the class inheritance tree

Distinct Operands

  • Mnemonic DOPD

  • Description Number of distinct operands: variables and constants ([Halstead,76]: n2)

Distinct Operators

  • Mnemonic DOPT

  • Description Number of distinct operators: language keywords ([Halstead,76]: n1)

Do While Statements

  • Mnemonic DOWH

  • Description Number of 'do...while' statements in the function

Else Statements

  • Mnemonic ELSE

  • Description Number of 'else' statements

For Statements

  • Mnemonic FOR

  • Description Number of 'for' statements in the function

Foreach Statements

  • Mnemonic FORE

  • Description Number of 'foreach' statements in the function

Structures Added

  • Mnemonic SADD

  • Description Number of control structures added since the previous version.

Structures Modified

  • Mnemonic SMOD

  • Description Number of control structures modified since the previous version.

Structures Removed

  • Mnemonic SREM

  • Description Number of control structures removed since the previous version.

Number of Structures

  • Mnemonic SSIZ

  • Description Number of control structures: iterations, selections, sequences

Goto Statements

  • Mnemonic GOTO

  • Description Number of 'goto' statements

Header Lines Of Comment

  • Mnemonic HCOM

  • Description Number of comment lines placed before the beginning of the artefact.

Header Lines Of Code

  • Mnemonic HLOC

  • Description Number of lines between the function or class definition and the first opening brace.

Cloned Code

  • Mnemonic ICC

  • Description Duplicated code in this artefact

Cloned Control Flow Tokens

  • Mnemonic ICFTC

  • Description Number of duplicated tokens in control flow of functions

If Statements

  • Mnemonic IF

  • Description Number of 'if' statements

Line Count

  • Mnemonic LC

  • Description Number of lines.

Loop Statements

  • Mnemonic LOOP

  • Description Number of loop statements in the function

Multiple Inheritance Indicator

  • Mnemonic MII

  • Description Number of classes from which the class inherits directly

Internal Methods

  • Mnemonic MINT

  • Description Number of internal methods (only applicable to C#)

Mixed Lines

  • Mnemonic MLOC

  • Description Number of lines containing both code and comment in the source files.

Methods without Accessibility

  • Mnemonic MNON

  • Description Number of methods without any accessibility specifier

Public Methods

  • Mnemonic MPBL

  • Description Number of public methods

Protected Internal Methods

  • Mnemonic MPIN

  • Description Number of protected internal methods(only applicable to C#)

Protected Methods

  • Mnemonic MPRT

  • Description Number of protected methods

Private Methods

  • Mnemonic MPRV

  • Description Number of private methods

Static Methods

  • Mnemonic MSTA

  • Description Number of static methods

Number of Ancestors

  • Mnemonic NAC

  • Description Number of classes from which the class inherits directly or indirectly

Number of Descendants

  • Mnemonic NDC

  • Description Number of classes which inherit from the class directly or indirectly

Maximum Nested Structures

  • Mnemonic NEST

  • Description Maximum number of nested structures

Number Of Children

  • Mnemonic NOC

  • Description Number of classes which inherit directly from the class

Number of Parameters

  • Mnemonic NOP

  • Description Number of formal parameters in the function

Non-Cyclic Paths

  • Mnemonic PATH

  • Description Number of non-cyclic paths in the function.

Orelse operators

  • Mnemonic OREL

  • Description Number of 'orelse' operators

Constant Properties

  • Mnemonic PCST

  • Description Number of constant properties

Properties with Get

  • Mnemonic PGET

  • Description Number of properties with a setter (only applicable to C#)

Internal Properties

  • Mnemonic PINT

  • Description Number of internal properties (only applicable to C#)

Properties

  • Mnemonic PNBR

  • Description Total number of properties

Properties without Accessibility

  • Mnemonic PNON

  • Description Number of properties without accessibility specifier

Public Properties

  • Mnemonic PPBL

  • Description Number of public properties

Protected Internal Properties

  • Mnemonic PPIN

  • Description Number of protected internal properties (only applicable to C#)

Protected Properties

  • Mnemonic PPRT

  • Description Number of protected properties

Private Properties

  • Mnemonic PPRV

  • Description Number of private properties

Properties with Set

  • Mnemonic PSET

  • Description Number of properties with a getter (only applicable to C#)

Static Properties

  • Mnemonic PSTA

  • Description Number of static properties in the class

Number of #DEFINE

  • Mnemonic P_DEFINE

  • Description Number of #DEFINE

Number of #ELIF

  • Mnemonic P_ELIF

  • Description Number of #ELIF

Number of #ELSE

  • Mnemonic P_ELSE

  • Description Number of #ELSE

Number of #ENDIF

  • Mnemonic P_ENDIF

  • Description Number of #ENDIF

Number of #ENDREGION

  • Mnemonic P_ENDREGION

  • Description Number of #ENDREGION

Number of #ERROR

  • Mnemonic P_ERROR

  • Description Number of #ERROR

Number of #IF

  • Mnemonic P_IF

  • Description Number of #IF

Number of #IFDEF

  • Mnemonic P_IFDEF

  • Description Number of #IFDEF

Number of #IFNDEF

  • Mnemonic P_IFNDEF

  • Description Number of #IFNDEF

Compiler FLAG Nested Level

  • Mnemonic P_NEST

  • Description Compiler FLAG Nested Level

Number of #PRAGMA

  • Mnemonic P_PRAGMA

  • Description Number of #PRAGMA

Number of #REGION

  • Mnemonic P_REGION

  • Description Number of #REGION

Number of #UNDEF

  • Mnemonic P_UNDEF

  • Description Number of #UNDEF

Number of #WARNING

  • Mnemonic P_WARNING

  • Description Number of #WARNING

Return Statements

  • Mnemonic RETURN

  • Description Number of 'return' statements in the function

Repeated Code Blocks

  • Mnemonic RS

  • Description Duplicated blocks in the function

Skipped Lines of Comment code

  • Mnemonic SKLC

  • Description Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.

Source Lines Of Code

  • Mnemonic SLOC

  • Description Number of lines of source code in the source file(s).

Special Operators

  • Mnemonic SPOP

  • Description Number of special operators used in the source file

Executable Statements

  • Mnemonic STAT

  • Description Total number of executable statements.

Switch Statements

  • Mnemonic SWIT

  • Description Number of 'switch' statements in the function

Ternary operators

  • Mnemonic TERN

  • Description Number of ternary operators i.e. ?:

Throw Statements

  • Mnemonic THRO

  • Description Number of 'throw' statements in the function

Operand Occurrences

  • Mnemonic TOPD

  • Description Number of occurrences of operands: variables and constants ([Halstead,76]: N2)

Operator Occurrences

  • Mnemonic TOPT

  • Description Number of occurrences of operators: language keywords ([Halstead,76]: N1)

Try Statements

  • Mnemonic TRY

  • Description Number of 'try' statements in the function

Lines Added

  • Mnemonic LADD

  • Description Number of lines added since the previous version.

Lines Modified

  • Mnemonic LMOD

  • Description Number of lines modified since the previous version.

Lines Removed

  • Mnemonic LREM

  • Description Number of lines removed since the previous version.

While Statements

  • Mnemonic WHIL

  • Description Number of 'while' statements in the function

C# Ruleset

Backward Goto shall not be used

  • Mnemonic BWGOTO

  • Description Backward gotos shall not be used.

Missing compound statement

  • Mnemonic COMPOUND

  • Description The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement (see [MISRA-C:2004]: RULE 14.8).

Missing compound if

  • Mnemonic COMPOUNDIF

  • Description An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement (see [MISRA-C:2004]: RULE 14.9).

Commented-out Source Code is not allowed

  • Mnemonic R_CSTAT

  • Description Commented-out Source Code is not allowed

Missing Default

  • Mnemonic DEFAULT

  • Description The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).

Missing final else

  • Mnemonic ELSEFINAL

  • Description All if ... else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).

Assignment in Boolean

  • Mnemonic NOASGCOND

  • Description Assignment operators shall not be used in expressions that yield a boolean value

Assignment without Comparison

  • Mnemonic NOASGINBOOL

  • Description Assignment operators shall not be used in expressions that do not contain comparison operators.

Factorizable Classes

  • Mnemonic CAC_CL

  • Description Consider classes refactorization

Factorizable Files

  • Mnemonic CAC_FI

  • Description Consider files refactorization

Factorizable Functions

  • Mnemonic CAC_FN

  • Description Consider functions refactorization

Factorizable Packages

  • Mnemonic CAC_PKG

  • Description Consider packages refactorization

Cloned Classes

  • Mnemonic CC_CL

  • Description There shall be no duplicated classes

Cloned Files

  • Mnemonic CC_FI

  • Description There shall be no duplicated files

Cloned Functions

  • Mnemonic CC_FN

  • Description There shall be no duplicated functions

Cloned Algorithmic

  • Mnemonic CFTC_FN

  • Description There shall be no algorithmic cloning

There shall be a no code before first case

  • Mnemonic NOCODEBEFORECASE

  • Description There shall be a no code before the first case of a switch statement.

Continue shall not be used

  • Mnemonic NOCONT

  • Description The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).

Fallthrough shall be avoided

  • Mnemonic NOFALLTHROUGH

  • Description There shall be no fallthrough the next case in a switch statement.

FIXME shall not be commited in sources code

  • Mnemonic R_NOFIXME

  • Description FIXME shall not be commited in sources code as it brings confusion regarding code reliability.

GOTO shall not be used

  • Mnemonic NOGOTO

  • Description A unconditional GOTO shall not be used to jump outside the paragraph.

Label out a switch

  • Mnemonic NOLABEL

  • Description A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement (see [MISRA-C:2004]: RULE 15.1).

Avoid Duplicated Blocks in Function

  • Mnemonic RS_FN

  • Description There shall be no duplicated parts in functions

TODO shall not be commited in sources code

  • Mnemonic R_NOTODO

  • Description TODO shall not be commited in sources code as it brings confusion regarding code reliability.

Missing case in switch

  • Mnemonic ONECASE

  • Description Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).

Relaxed violation

  • Mnemonic RELAX

  • Description A rule violation is relaxed and justified.

Multiple exits are not allowed

  • Mnemonic RETURN

  • Description A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).

Risky Empty Statement

  • Mnemonic RISKYEMPTY

  • Description Risky Empty Statement

Multiple break in loop are not allowed

  • Mnemonic SGLBRK

  • Description For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).