Coding Standards
ABAP
ABAP Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Number of Check instruction (CHECK)
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Public Constant (CPBL)
Protected Constant (CPRT)
Private Constant (CPRV)
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Else Statements (ELSE)
Number of 'else' statements
Call to exit (EXIT)
Number of calls to the exit function
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
File Type Count (FTYP)
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
ABAP Ruleset
Avoid using APPEND statements in loops (AVOIDAPPENDINLOOP)
Avoid using COMMIT WORK statements in loops.
Avoid using APPEND in SQL SELECT statements (AVOIDAPPENDINSELECT)
Avoid using APPEND in SQL SELECT statements.
Avoid using BREAK-POINT (AVOIDBREAKPOINT)
Avoid using CHECK in SQL SELECT statements (AVOIDCHECKINSELECT)
Avoid using COMMIT WORK statements in loops (AVOIDCOMMITWORKINLOOP)
Avoid using COMMIT WORK statements in loops.
Avoid obsolete DATA BEGIN OF OCCURS statement (AVOIDDATAOCCURS)
Avoid using INSERT statements in loops (AVOIDINSERTINLOOP)
Avoid using INSERT statements in loops. Querying in a loop can lead to performance issues.
Avoid using INSERT in SQL SELECT statements (AVOIDINSERTINSELECT)
Avoid using SQL INTO statements in loops (AVOIDINTOINLOOP)
Avoid using SQL INTO statements in loops.
Avoid using SELECT * (AVOIDSELECTALL)
SELECT * should be avoided as it does not enable to keep control on the flow return and could therefore be error prone and potentially lead to performance issues.
Avoid using the SQL "BYPASSING BUFFER" clause (AVOIDSELECTBYPASS)
The BYPASSING BUFFER clause causes the SELECT statement to avoid the SAP buffering and to read directly from the database and not from the buffer on the application server.
Avoid using SELECT DISTINCT Statement (AVOIDSELECTDISTINCT)
The SQL DISTINCT clause causes the SELECT statement to avoid the SAP buffering and to read directly from the database and not from the buffer on the application server.
Avoid SELECT SQL statement without a WHERE clause (AVOIDSELECTNOWHERE)
Avoid SELECT SQL statement with a WHERE clause containing the NOT EQUAL operator (AVOIDSELECTWHERENOTEQ)
Avoid SELECT SQL statement with a WHERE clause containing the NOT EQUAL operator.
Avoid using SQL Aggregate Functions (AVOIDSQLAGGREGATEFUNC)
SQL COUNT(..) , MIN(..), MAX(..), SUM(..), AVG(..) functions cause the SAP table buffer to be bypassed and so usage of such functions can lead to some performance issues.
Avoid using SUBMIT statements in loops (AVOIDSUBMITINLOOP)
Avoid using SUBMIT statements in loops.
Avoid using UPDATE, MODIFY, DELETE statements in loops (AVOIDUPDELINLOOP)
Avoid using UPDATE, MODIFY, DELETE statements in loops. Querying in a loop can lead to performance issues.
Avoid UPDATE or DELETE SQL Statement without a WHERE clause (AVOIDUPDELNOWHERE)
Avoid using GROUP BY in queries (AVOIDUSINGSQLGROUPBY)
Using GROUP BY in SQL queries can lead to performance issues.
Avoid using the JOIN SQL clause (AVOIDUSINGSQLJOIN)
Using the SQL JOIN clause leads to bypass the SAP table buffer.
Avoid using LIKE in SQL queries (AVOIDUSINGSQLLIKE)
Using LIKE in SQL queries can lead to performance issues.
Avoid using the WAIT statement (AVOIDWAIT)
Avoid using the WAIT statement.
The class name should conform to the defined standard (CLASSNAMINGCONVENTION)
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Forbid call to a system function (FORBIDCALLCFUNC)
Call of a System Function: CALL 'cfunc' is only intended for internal usage. Incompatible changes and further development is possible at any time and without warning or notice.
Forbid calls to dialog transactions (FORBIDCALLDIALTRANS)
Forbid calls to dialog transactions.
Forbid use of GENERATE REPORT / SUBROUTINE POOL / DYNPRO (FORBIDGENERATEPROG)
This statement is exclusively for internal use within SAP Technology Development. Incompatible changes or developments are possible at any time without prior warning or notes.
Forbid calls to GET RUN TIME. (FORBIDGETRUNTIME)
Forbid use of INSERT/DELETE REPORT/TEXTPOOL (FORBIDINSERTPROG)
This statement is exclusively for internal use within SAP Technology Development. Incompatible changes or developments are possible at any time without prior warning or notice.
Forbid uses of OFFSET in ASSIGN (FORBIDOFFSETINASSIGN)
Forbid uses of OFFSET in ASSIGN.
Forbid use of SYSTEM-CALL (FORBIDSYSTEMCALL)
This statement is only for !Internal use in SAP Basis development!. Its use is subject to various restrictions, not all of which may be listed in the documentation. Changes and further development, which may be incompatible, may occur at any time, without warning or notice!
The form name should conform to the defined standard (FORMNAMINGCONVENTION)
The function name should conform to the defined standard (FUNCTIONNAMINGCONVENTION)
Avoid calling a function module without handling exceptions (HANDLEERRORCALLFUNC)
Handling the exceptions when calling a function module is optional but should be mandatory to correctly handle errors in production.
The macro name should conform to the defined standard (MACRONAMINGCONVENTION)
The method name should conform to the defined standard (METHODNAMINGCONVENTION)
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Do not use "Native SQL" instructions (NONATIVESQL)
Native SQL should not be used.
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Prevent use of EDITOR-CALLS (PREVENTEDITORCALL)
This statement bypasses the authority checks that are performed when calling the ABAP editor via transaction code.
The program or report name should conform to the defined standard (PROGREPORTNAMINGCONVENTION)
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
ADA
ADA Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Commented Statements (CSTAT)
Number of Commented Statements.
Declare operators (DECBL)
Number of Declare operators
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Else Statements (ELSE)
Number of 'else' statements
Entry Statements (ENTRY)
Number of Entry statements
Exception When blocks (EXBL)
Number of 'when' blocks in 'exception handler'.
Exception handlers (EXGR)
Number of Exception handlers
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Generic object (ISGEN)
The object is declared generic
Label Statements (LABEL)
Number of Label statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
AND operators (NBAND)
Number of AND operators
Constants (NBCONST)
Number of Constants
Private constant (NBCONSTPRIV)
Number of Private constants
Public constants (NBCONSTPUB)
Number of Public constants
Declared functions (NBDFUNC)
Number of Declared functions/procedures
Private functions/Procedures (NBDFUNCPRIV)
Number of Private function/Procedure
Public functions (NBDFUNCPUB)
Number of Public functions/procedures
Exceptions (NBEXCEPT)
Number of Declared Exceptions
Private exceptions (NBEXCEPTPRIV)
Number of Private exceptions
Public exceptions (NBEXCEPTPUB)
Number of Public exceptions
Separate functions/procedures (NBFUNCDSEP)
Number of Separate functions/procedures
OR operators (NBOR)
Number of OR operators
Separate packages (NBPACKDSEP)
Number of package declared Separate
Protected objects (NBPROTOBJDSEP)
Number of Declred Protected objects
Renamed objects (NBRENA)
Number of Renamed object
Subtypes (NBSTYP)
Number of Subtypes
Separate tasks (NBTASKDSEP)
Number of task declared Separate
Types (NBTYP)
Number of Types
Derived types (NBTYPDRV)
Number of Derived types
Private types (NBTYPPRIV)
Number of Private types
Public types (NBTYPPUB)
Number of Public types
Variables (NBVAR)
Number of Variables
Private variables (NBVARPRIV)
Number of Private variables
Public variables (NBVARPUB)
Number of Public variables
With statements (NBWITH)
Number of With statements
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Raise statements (RAISE)
Number of Raise statementts
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
ADA Ruleset
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Exit Label shall be named (EXTLABEL)
Each exit label shall be named.
Use 'exit when' instead of if… exit syntax (EXTWHEN)
Use 'exit when' instead of if… exit syntax.
Each loop shall be named (LOOPNAMED)
Each loop shall be named.
Abort shall not be used (NOABORT)
Use of 'abort'
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Delay shall not be used (NODELAY)
Use of 'delay'
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
There shall be no 'when others' in exception handler (NOWHEN_OTHERS)
There shall be no 'when others' in exception handler.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Parameters shall be ordered: 'IN', 'OUT', 'IN OUT'. (PARAMORDER)
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Multiple Exit in loop (SGLEXT)
There shall be a single exit by loop.
C
C Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Calls to the Function (CAL2)
Number of calls to the function (including direct recursive calls).
Calls to Distinct Functions (CALD)
Number of calls to distinct functions defined in the project source files (including recursive call).
Calls from the Function (CALF)
Number of call statements in the function.
Distinct Calling Functions (CALI)
Number of distinct functions calling the function (including recursice call).
Calls to Distinct External Functions (CALX)
Number of distinct call to external functions (not present in project’s source files).
Case Labels (CASE)
Number of 'case' labels in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Recursive Calls (CDRI)
Number of direct recursive call in the function.
Called External Functions (CEXT)
Number of calls to external functions (not present in project’s source files).
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Number of Indirect Call Cycles (CIRI)
Number of call graph cycles in which the function is involved (excluding direct recursive calls).
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Comparison Operators (CPOP)
Number of comparison operators used in the source file
Commented Statements (CSTAT)
Number of Commented Statements.
Number of Call Cycles (CYCL)
Number of call graph cycles in which the function is involved (including recursivity).
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Use of longjump (LONGJMP)
Loop Statements (LOOP)
Number of loop statements in the function
Memory Allocation (MEMALLOC)
Memory Freeing (MEMFREE)
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Use of offsetof (OFFSETOF)
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Number of #DEFINE (P_DEFINE)
Number of #ELIF (P_ELIF)
Number of #ELSE (P_ELSE)
Number of #ENDIF (P_ENDIF)
Number of #ERROR (P_ERROR)
Number of #IF (P_IF)
Number of #IFDEF (P_IFDEF)
Number of #IFNDEF (P_IFNDEF)
Number of Include (P_INCLUDE)
Compiler FLAG Nested Level (P_NEST)
Number of #PRAGMA (P_PRAGMA)
Number of #UNDEF (P_UNDEF)
Number of #WARNING (P_WARNING)
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Use of setjump (SETJMP)
Signal Functions (SIGNAL)
Use of signal Functions
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Special Operators (SPOP)
Number of special operators used in the source file
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
IO Functions (STDIO)
Use IO Functions
String Conversions (STRINGCONV)
Use of String Conversions
Switch Statements (SWIT)
Number of 'switch' statements in the function
System Functions (SYSCOM)
Use of system Functions
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Time Handling (TIMEHDL)
Use of Time Handling
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
C Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Dynamic Memory Allocation shall not be used (DYNMEMALLOC)
Dynamic heap memory allocation shall not used. This precludes the use of the functions calloc, malloc, realloc and free (see [MISRA-C:2004]: RULE 20.4)
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Macro longjmp or setjmp shall not be used (JUMP)
(The setjmp macro and the longjmp function shall not be used (see [MISRA-C:2004]: RULE 20.7).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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).
Recursion are not allowed (NORECURSION)
Functions shall not called themselves either directly or indirectly (see [MISRA-C:2004]: RULE 16.2).
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Macro offsetof shall not be used (OFFSETOF)
The macro offsetof, in library <stddef.h>, shall not be used (see [MISRA-C:2004]: RULE 20.6).
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Signal or Raise shall not be used (SIGNAL)
The signal handling facilities of <signal.h> shall not be used (see [MISRA-C:2004]: RULE 20.8).
IO Functions shall not be used (STDIO)
The input/output library <stdio.h> shall not be used in production code (see [MISRA-C:2004]: RULE 20.9).
'atof, atoi or atol' shall not be used (STRINGCONV)
The library functions atof, atoi and atol from library <stdlib.h> shall not be used (see [MISRA-C:2004]: RULE 20.10).
'abort, exit, getenv or system' shall not be used (SYSCOM)
The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used (see [MISRA-C:2004]: RULE 20.11).
Time Handling Functions shall not be used (TIMEHDL)
The time handling functions of library <time.h> shall not be used: time, strftime, clock, difftime, mktime (see [MISRA-C:2004]: RULE 20.12).
COBOL
COBOL Metrics
Arithmetic Operators (AROP)
Number of arithmetic operators
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
CALL Statements (CALL)
Number of CALL statements
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Comment lines with code (CLOC_CODE)
Number of lines of comments in the source file(s) whose first word is a keyword.
Comment lines without alphabetic characters (CLOC_NULL)
Number of lines of comments in the source file(s) without alphabetic character.
Real comment lines with alphabetic characters (CLOC_REAL)
Number of real lines of comments in the source file(s) with alphabetic characters.
Clones Number (CN)
Number of cloned artefacts
Conditions (COND)
Number of conditions
Commented Statements (CSTAT)
Number of Commented Statements.
Debug lines (DBUG)
Number of lines of debug in the source file(s).
DISPLAY statements (DISPLAY)
Number of DISPLAY statements
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operands in Data Div. (DOPD_DD)
Number of distinct operands in Data Division: variables and constants ([Halstead,76]: n2)
Distinct Operands in Procedure Div. (DOPD_PD)
Number of distinct operands in Procedure Division: variables and constants ([Halstead,76]: n2)
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Distinct Operators in Data Div. (DOPT_DD)
Number of distinct operators in Data Division: language keywords ([Halstead,76]: n1)
Distinct Operators in Procedure Div. (DOPT_PD)
Number of distinct operators in Procedure Division: language keywords ([Halstead,76]: n1)
Else Statements (ELSE)
Number of 'else' statements
EVALUATE Statements (EVAL)
Number of EVALUATE statements
Call to exit (EXIT)
Number of calls to the exit function
File Declarations (FD)
Number of file declarations
Files Used (FDUS)
Number of references to files
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
Goto Statements (GOTO)
Number of 'goto' statements
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
Is IDMS active (IDMS_ACTIVE)
Is IDMS active in program
IDMS instructions called (IDMS_CALLBD)
Number of IDMS instructions called
IDMS records called (IDMS_CALLREC)
Number of IDMS records called
IDMS calls for modification (IDMS_MOD)
Number of calls for modification
IDMS calls for reading/searching (IDMS_READ)
Number of calls for reading/searching
IDMS subschema definition (IDMS_SSCH)
Number of IDMS subschema definition
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Number of paragraphs (PARA)
Number of paragraphs.
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
PERFORM Statements (PERF)
Number of PERFORM statements
Repeated Code Blocks (RS)
Duplicated blocks in the function
Data Declarations (SD)
Number of data declarations
Data Used (SDUS)
Number of used data
Number of Sections (SECT)
Number of sections.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
STOP Statements (STOP)
Number of STOP statements
TIMES Clauses (TIME)
Number of TIMES clauses in PERFORM statements
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operand Occurrences in Data Div. (TOPD_DD)
Number of occurrences of operands in Data Division: variables and constants ([Halstead,76]: N2)
Operand Occurrences in Procedure Div. (TOPD_PD)
Number of occurrences of operands in Procedure Division: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Operator Occurrences in Data Div. (TOPT_DD)
Number of occurrences of operators in Data Division: language keywords ([Halstead,76]: N1)
Operator Occurrences in Procedure Div. (TOPT_PD)
Number of occurrences of operators in Procedure Division: language keywords ([Halstead,76]: N1)
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
UNTIL Clauses (UNTL)
Number of UNTIL clauses in PERFORM statements
VARYING Clauses (VARY)
Number of VARYING clauses in PERFORM statements
WHEN Clauses (WHEN)
Number of WHEN and WHENOTHER clauses in EVALUATE Statements
COBOL Ruleset
BLOCK Clause (BLOCKSIZE)
In the FILE-DESCRIPTION section, each file description shall always use the BLOCK CONTAINS 0 RECORDS clause. The system will assign the BLOCK-SIZE automatically when allocating the file.
Column 7 for * and D Only (COLUMN7)
Only * and D shall be used in column 7.
Comment Division (COMMENT_DIVISION)
A comment is recommended before each division.
Comment FD (COMMENT_FD)
A comment is recommended before each file description.
Comment First Level (COMMENT_FIRST_LEVEL)
A comment is recommended before each first level of IF or PERFORM.
Comment Variable 01 and 77 (COMMENT_FIRST_VARIABLE)
A comment is recommended before each variable 01 and 77.
Empty lines around DIVISION (CPRS_DIVISION)
An empty line shall precede and follow a DIVISION.
Empty line after EXIT (CPRS_EXIT)
An empty line shall follow an EXIT statement.
Bad statement indentation (CPRS_INDENT)
The nested statements shall be indented.
Bad indentation of scope terminator (CPRS_SCOPE_TERMINATOR)
Scope terminators must be on the same column as the beginning of the block to facilitate program readability.
Empty line after SECTION (CPRS_SECTION)
An empty line shall follow a SECTION.
Variable declaration format (DCLWS)
A variable shall be declared in the WORKING STORAGE using the format ^W
Paragraphs having exact same name (R_DUPPARA)
Paragraphs having exact same name in the same PROGRAM-ID is forbidden.
Missing END-EVALUATE (EVALWITHENDEVAL)
An EVALUATE statement shall be closed by END-EVALUATE
Close file once (FILECLOSEONCE)
A file shall be closed only once
Close open file (FILEOPENCLOSE)
A file shall be opened and closed in the same program
Open file once (FILEOPENONCE)
A file shall be opened only once
Use FILE STATUS (FILESTATUS)
FILE STATUS shall be used to manage I/O errors.
Single GOBACK (GOBACK)
Only a single GOBACK shall be used in a subprgram.
IDMS FIND CURRENT (IDMSFINDCURRENT)
IDMS FIND CURRENT is forbidden
IDMS One modify by PERFORM (IDMSONEMODFORPERF)
Each IDMS modify statement (MODIFY/ERASE/STORE) should be in a specific perform
IDMS One same call (IDMSONESAMECALL)
Avoid duplicated IDMS call.
IDMS Ready Protected Update (IDMSREADYPRTUPD)
Each IDMS Ready Update statement should be defined in PROTECTED mode.
IDMS Return Code (IDMSRETURNCODE)
After each IDMS statement, return code should be checked.
Missing END-IF (IFWITHENDIF)
An IF statement shall be closed by an END-IF
Avoid using inline PERFORM with too many lines of code (INLINE_PERFORM_SIZE)
Avoid Cobol programs containing PERFORM - END-PERFORM loops with more than 80 lines.
Standard Label (LABELSTD)
In the FILE-DESCRIPTION section, each file description shall always use the LABEL RECORD STANDARD clause. Only the standard labels are checked by the system.
Missing END-ADD (MISSING_END_ADD)
An ADD statement shall be closed by an END-ADD.
Missing END-CALL (MISSING_END_CALL)
An CALL statement shall be closed by an END-CALL.
Missing END-COMPUTE (MISSING_END_COMPUTE)
An COMPUTE statement shall be closed by an END-COMPUTE.
Missing END-DELETE (MISSING_END_DELETE)
An DELETE statement shall be closed by an END-DELETE.
Missing END-DIVIDE (MISSING_END_DIVIDE)
An DIVIDE statement shall be closed by an END-DIVIDE.
Missing END-MULTIPLY (MISSING_END_MULTIPLY)
An MULTIPLY statement shall be closed by an END-MULTIPLY.
Missing END-READ (MISSING_END_READ)
An READ statement shall be closed by an END-READ.
Missing END-RETURN (MISSING_END_RETURN)
An RETURN statement shall be closed by an END-RETURN.
Missing END-REWRITE (MISSING_END_REWRITE)
An REWRITE statement shall be closed by an END-REWRITE.
Missing END-SEARCH (MISSING_END_SEARCH)
An SEARCH statement shall be closed by an END-SEARCH.
Missing END-START (MISSING_END_START)
An START statement shall be closed by an END-START.
Missing END-STRING (MISSING_END_STRING)
An STRING statement shall be closed by an END-STRING.
Missing END-SUBTRACT (MISSING_END_SUBTRACT)
An SUBTRACT statement shall be closed by an END-SUBTRACT.
Missing END-UNSTRING (MISSING_END_UNSTRING)
An UNSTRING statement shall be closed by an END-UNSTRING.
Missing END-WRITE (MISSING_END_WRITE)
An WRITE statement shall be closed by an END-WRITE.
Missing FILLER (MISSING_FILLER)
Even the 'FILLER' word is optional since Cobol85, it is recommanded to write it.
No more than 3 nested IF (NESTEDIF)
There shall be no more than 3 nexted IF statements
Nested Program (NESTED_PROGRAM)
Nested program is not recommanded
ALTER shall not be used (NOALTER)
The ALTER statement shall not be used. Labels are decided only at execution time.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
No Conditional GOTO (NOCONDGOTO)
Conditional GO TO shall not be used. Use EVALUATE instead.
No MOVE CORRESPONDING (NOCORRESPONDING)
MOVE CORRESPONDING shall not be used.
COMPUTE instead of ADD (NOCPXADD)
COMPUTE shall be used to add more than 2 data instead of ADD.
COMPUTE instead of SUBTRACT (NOCPXSUBTRACT)
COMPUTE shall be used to add more than 2 data instead of SUBTRACT.
No DEBUG MODE (NODEBUG)
DEBUGGING-MODE shall not be used
COMPUTE instead of DIVIDE (NODIVIDE)
COMPUTE shall be used instead of DIVIDE.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
No INITIALIZE (NOINITIALIZE)
INITIALIZE shall not be used. Use MOVE to initialize variable.
COMPUTE instead of MULTIPLY (NOMULTIPLY)
COMPUTE shall be used instead of MULTIPLY.
No procedural COPY (NOPROCCOPY)
Procedural COPY clauses shall not be used. Use subprograms instead.
No RENAMES (NORENAMES)
The RENAMES clause shall not be used.
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
No Variables S9(9) (NOVARS9)
The variables shall not be declared in S9(9) COMP. It implies a conversion
Avoid GOTO jumps out of PERFORM range (NO_GOTO_OUT_OF_PERFORM_RANGE)
Avoid Cobol Programs containing sections or paragraphs that are called by PERFORM statements and that contain a GO TO statement to another section or paragraph that is not in the scope of the initial PERFORM.
Avoid OPEN/CLOSE inside loops (NO_OPEN_CLOSE_INSIDE_LOOP)
Avoid Cobol programs using OPEN or CLOSE in loops. Following loops are taken into account: - PERFORM TIMES / UNTIL / VARYING
Avoid accessing data by using the position and length (NO_REFERENCE_ACCESS)
Avoid Cobol programs accessing part of data by using a position and a length.
Use COMP for OCCURS (OCCURSCOMP)
For the OCCURS DEPENDING ON clause, the corresponding item shall be declared using COMP or BINARY.
Avoid mixing paragraphs and sections (PARA_OR_SECT_ONLY)
A program should not mix paragraphs and sections.
Perform with no THRU (PERFORMWITHTHRU)
The call of a paragraph shall be made in the use of PERFORM paragraphName THRU paragraphNameExit.
Bad paragraph position used in PERFORM (POSITION_OF_PERFORM_RANGE)
On a PERFORM range: P1 THRU P2, P1 must be declared before P2.
READ-WRITE Instruction (READWRITE)
READ A INTO B or WRITE A FROM B forms shall be used for reading/writing a file.
Avoid using READ statement without AT END clause (READ_AT_END)
Avoid Cobol programs using READ statements without the AT END clause.
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Statement shall be in uppercase (UPPERCASE)
A COBOL statement shall be written in uppercase to keep the program readable.
Use SYNCHRONIZED (USESYNCH)
SYNCHRONIZED shall be used for COMP, COMP-1, COMP-2, POINTER and INDEX variables.
Homonymous variable shall not be used (VARNAME)
There shall be no homonymous variables.
Use WHEN OTHER (WHENOTHER)
EVALUATE shall end by a WHEN OTHER clause.
C++
C++ Metrics
Constant Data (ACST)
Number of constant data
Number of Attributes (ANBR)
Number of attributes
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Protected Data (APRT)
Number of protected data
Private data (APRV)
Number of private data
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Static Data (ASTA)
Number of static data
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Calls to the Function (CAL2)
Number of calls to the function (including direct recursive calls).
Calls to Distinct Functions (CALD)
Number of calls to distinct functions defined in the project source files (including recursive call).
Calls from the Function (CALF)
Number of call statements in the function.
Distinct Calling Functions (CALI)
Number of distinct functions calling the function (including recursice call).
Calls to Distinct External Functions (CALX)
Number of distinct call to external functions (not present in project’s source files).
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Recursive Calls (CDRI)
Number of direct recursive call in the function.
Called External Functions (CEXT)
Number of calls to external functions (not present in project’s source files).
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Number of Indirect Call Cycles (CIRI)
Number of call graph cycles in which the function is involved (excluding direct recursive calls).
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Public Constant (CPBL)
Comparison Operators (CPOP)
Number of comparison operators used in the source file
Protected Constant (CPRT)
Private Constant (CPRV)
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Constant Methods (MCST)
Number of 'constant' methods i.e. which do not modify the object
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Public Methods (MPBL)
Number of public methods
Protected Methods (MPRT)
Number of protected methods
Private Methods (MPRV)
Number of private methods
Static Methods (MSTA)
Number of static methods
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Number of #DEFINE (P_DEFINE)
Number of #ELIF (P_ELIF)
Number of #ELSE (P_ELSE)
Number of #ENDIF (P_ENDIF)
Number of #ERROR (P_ERROR)
Number of #IF (P_IF)
Number of #IFDEF (P_IFDEF)
Number of #IFNDEF (P_IFNDEF)
Number of Include (P_INCLUDE)
Compiler FLAG Nested Level (P_NEST)
Number of #PRAGMA (P_PRAGMA)
Number of #UNDEF (P_UNDEF)
Number of #WARNING (P_WARNING)
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Special Operators (SPOP)
Number of special operators used in the source file
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
C++ Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
C#
C# Metrics
Constant Data (ACST)
Number of constant data
Internal Data (AINT)
Number of internal data (only applicable to C#)
Number of Attributes (ANBR)
Number of attributes
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Protected Internal Data (APIN)
Number of protected internal data (only applicable to C#)
Protected Data (APRT)
Number of protected data
Private data (APRV)
Number of private data
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Static Data (ASTA)
Number of static data
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Public Constant (CPBL)
Comparison Operators (CPOP)
Number of comparison operators used in the source file
Protected Constant (CPRT)
Private Constant (CPRV)
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Foreach Statements (FORE)
Number of 'foreach' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Constant Methods (MCST)
Number of 'constant' methods i.e. which do not modify the object
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
Internal Methods (MINT)
Number of internal methods (only applicable to C#)
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Public Methods (MPBL)
Number of public methods
Protected Internal Methods (MPIN)
Number of protected internal methods(only applicable to C#)
Protected Methods (MPRT)
Number of protected methods
Private Methods (MPRV)
Number of private methods
Static Methods (MSTA)
Number of static methods
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Constant Properties (PCST)
Number of constant properties
Properties with Get (PGET)
Number of properties with a setter (only applicable to C#)
Internal Properties (PINT)
Number of internal properties (only applicable to C#)
Properties (PNBR)
Total number of properties
Properties without Accessibility (PNON)
Number of properties without accessibility specifier
Public Properties (PPBL)
Number of public properties
Protected Internal Properties (PPIN)
Number of protected internal properties (only applicable to C#)
Protected Properties (PPRT)
Number of protected properties
Private Properties (PPRV)
Number of private properties
Properties with Set (PSET)
Number of properties with a getter (only applicable to C#)
Static Properties (PSTA)
Number of static properties in the class
Number of #DEFINE (P_DEFINE)
Number of #ELIF (P_ELIF)
Number of #ELSE (P_ELSE)
Number of #ENDIF (P_ENDIF)
Number of #ENDREGION (P_ENDREGION)
Number of #ERROR (P_ERROR)
Number of #IF (P_IF)
Number of #IFDEF (P_IFDEF)
Number of #IFNDEF (P_IFNDEF)
Compiler FLAG Nested Level (P_NEST)
Number of #PRAGMA (P_PRAGMA)
Number of #REGION (P_REGION)
Number of #UNDEF (P_UNDEF)
Number of #WARNING (P_WARNING)
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Special Operators (SPOP)
Number of special operators used in the source file
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
C# Ruleset
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Fortran
Fortran Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of arithmetic if (ARIF)
Count number of arithmetic if
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Number of declarative statements (DECL)
Count number of declarative statements
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
% of parsed tokens (PARSE)
Percent of parsed tokens
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
Fortran Ruleset
Use of allocate/deallocate (ALLOCATE_USE)
A function must have the same number of allocate and deallocate.
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Use of contains (CONTAINS_USE)
Use of contains is forbidden to declare functions inside another function.
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Use of continue is deprecated (Fortran) (NOCONTINUE)
The 'continue' statement is deprecated.
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Use of Fortran 77 (FORTRAN77_USE)
A project should not contain any Fortran 77 file.
Function size (FUNCTION_SIZE)
The number of lines of code of a function must not exceed the limit.
Use of module (MODULE_USE)
A function must be declared inside a Fortran module
Incorrect Function Name (NAMING_FUNCTION)
Function name does not fit the convention.
Incorrect Module Name (NAMING_MODULE)
Module name does not fit the convention.
Parameter name (NAMING_PARAM)
A parameter name must comply with the minimum length.
Incorrect Program Name (NAMING_PROGRAM)
Program name does not fit the convention.
Incorrect Subroutine Name (NAMING_SUBROUTINE)
Subroutine name does not fit the convention.
Number of parameters (NB_PARAM)
The number of parameters received by a function should not exceed the limit.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
'cycle' shall not be used (NOCYCL)
The 'cycle' statement shall not be used.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
'stop' shall not be used (NOSTOP)
The 'stop' statement shall not be used.
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Use of save and data (SAVE_DATA_USE)
A function must not use the SAVE and DATA keywords.
Multiple exit (SGLEXIT)
For any iteration statement there shall be at most one 'exit' statement used for loop termination.
Groovy
Groovy Metrics
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Continue Statements (CONT)
Number of 'continue' statements in the function
Public Constant (CPBL)
Protected Constant (CPRT)
Private Constant (CPRV)
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
Max Nested Functions (FNST)
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Public Methods (MPBL)
Number of public methods
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Groovy Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Java
Java Metrics
Constant Data (ACST)
Number of constant data
Number of Attributes (ANBR)
Number of attributes
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Public Constant (CPBL)
Comparison Operators (CPOP)
Number of comparison operators used in the source file
Protected Constant (CPRT)
Private Constant (CPRV)
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
Number of extended classes/interfaces (IEXT)
Number of classes/interfaces extended by this class/interface
If Statements (IF)
Number of 'if' statements
Number of implemented classes/interfaces (IIMPL)
Number of classes/interfaces implemented by this class/interface
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Public Methods (MPBL)
Number of public methods
Protected Methods (MPRT)
Number of protected methods
Private Methods (MPRV)
Number of private methods
Static Methods (MSTA)
Number of static methods
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Special Operators (SPOP)
Number of special operators used in the source file
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Java Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Javascript
Javascript Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
Max Nested Functions (FNST)
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Javascript Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
MindC
MindC Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Calls to the Function (CAL2)
Number of calls to the function (including direct recursive calls).
Calls to Distinct Functions (CALD)
Number of calls to distinct functions defined in the project source files (including recursive call).
Calls from the Function (CALF)
Number of call statements in the function.
Distinct Calling Functions (CALI)
Number of distinct functions calling the function (including recursice call).
Calls to Distinct External Functions (CALX)
Number of distinct call to external functions (not present in project’s source files).
Case Labels (CASE)
Number of 'case' labels in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Recursive Calls (CDRI)
Number of direct recursive call in the function.
Called External Functions (CEXT)
Number of calls to external functions (not present in project’s source files).
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Number of Indirect Call Cycles (CIRI)
Number of call graph cycles in which the function is involved (excluding direct recursive calls).
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Comparison Operators (CPOP)
Number of comparison operators used in the source file
Commented Statements (CSTAT)
Number of Commented Statements.
Number of Call Cycles (CYCL)
Number of call graph cycles in which the function is involved (including recursivity).
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Use of longjump (LONGJMP)
Loop Statements (LOOP)
Number of loop statements in the function
Memory Allocation (MEMALLOC)
Memory Freeing (MEMFREE)
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Use of offsetof (OFFSETOF)
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Number of #DEFINE (P_DEFINE)
Number of #ELIF (P_ELIF)
Number of #ELSE (P_ELSE)
Number of #ENDIF (P_ENDIF)
Number of #ERROR (P_ERROR)
Number of #IF (P_IF)
Number of #IFDEF (P_IFDEF)
Number of #IFNDEF (P_IFNDEF)
Number of Include (P_INCLUDE)
Compiler FLAG Nested Level (P_NEST)
Number of #PRAGMA (P_PRAGMA)
Number of #UNDEF (P_UNDEF)
Number of #WARNING (P_WARNING)
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Use of setjump (SETJMP)
Signal Functions (SIGNAL)
Use of signal Functions
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Special Operators (SPOP)
Number of special operators used in the source file
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
IO Functions (STDIO)
Use IO Functions
String Conversions (STRINGCONV)
Use of String Conversions
Switch Statements (SWIT)
Number of 'switch' statements in the function
System Functions (SYSCOM)
Use of system Functions
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Time Handling (TIMEHDL)
Use of Time Handling
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
MindC Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Dynamic Memory Allocation shall not be used (DYNMEMALLOC)
Dynamic heap memory allocation shall not used. This precludes the use of the functions calloc, malloc, realloc and free (see [MISRA-C:2004]: RULE 20.4)
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Macro longjmp or setjmp shall not be used (JUMP)
(The setjmp macro and the longjmp function shall not be used (see [MISRA-C:2004]: RULE 20.7).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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).
Recursion are not allowed (NORECURSION)
Functions shall not called themselves either directly or indirectly (see [MISRA-C:2004]: RULE 16.2).
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Macro offsetof shall not be used (OFFSETOF)
The macro offsetof, in library <stddef.h>, shall not be used (see [MISRA-C:2004]: RULE 20.6).
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Signal or Raise shall not be used (SIGNAL)
The signal handling facilities of <signal.h> shall not be used (see [MISRA-C:2004]: RULE 20.8).
IO Functions shall not be used (STDIO)
The input/output library <stdio.h> shall not be used in production code (see [MISRA-C:2004]: RULE 20.9).
'atof, atoi or atol' shall not be used (STRINGCONV)
The library functions atof, atoi and atol from library <stdlib.h> shall not be used (see [MISRA-C:2004]: RULE 20.10).
'abort, exit, getenv or system' shall not be used (SYSCOM)
The library functions abort, exit, getenv and system from library <stdlib.h> shall not be used (see [MISRA-C:2004]: RULE 20.11).
Time Handling Functions shall not be used (TIMEHDL)
The time handling functions of library <time.h> shall not be used: time, strftime, clock, difftime, mktime (see [MISRA-C:2004]: RULE 20.12).
Objective-C
Objective-C Metrics
Constant Data (ACST)
Number of constant data
Number of Attributes (ANBR)
Number of attributes
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Protected Data (APRT)
Number of protected data
Private data (APRV)
Number of private data
Assignment Operators (ASOP)
Number of assignment operators used in the source file
Static Data (ASTA)
Number of static data
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Comparison Operators (CPOP)
Number of comparison operators used in the source file
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Public Methods (MPBL)
Number of public methods
Protected Methods (MPRT)
Number of protected methods
Private Methods (MPRV)
Number of private methods
Static Methods (MSTA)
Number of static methods
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Properties (PNBR)
Total number of properties
Number of #DEFINE (P_DEFINE)
Number of #ELIF (P_ELIF)
Number of #ELSE (P_ELSE)
Number of #ENDIF (P_ENDIF)
Number of #ERROR (P_ERROR)
Number of #IF (P_IF)
Number of #IFDEF (P_IFDEF)
Number of #IFNDEF (P_IFNDEF)
Number of Include (P_INCLUDE)
Compiler FLAG Nested Level (P_NEST)
Number of #PRAGMA (P_PRAGMA)
Number of #UNDEF (P_UNDEF)
Number of #WARNING (P_WARNING)
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Special Operators (SPOP)
Number of special operators used in the source file
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Objective-C Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
PHP
PHP Metrics
Constant Data (ACST)
Number of constant data
Number of Attributes (ANBR)
Number of attributes
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Protected Data (APRT)
Number of protected data
Private data (APRV)
Number of private data
Static Data (ASTA)
Number of static data
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Call to exit (EXIT)
Number of calls to the exit function
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Foreach Statements (FORE)
Number of 'foreach' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
HTML Lines of Code (HTML)
Number of HTML lines of code in the source file(s).
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Constant Methods (MCST)
Number of 'constant' methods i.e. which do not modify the object
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
PHP/HTML Mixed Lines (MIXL)
Number of lines containing both PHP and HTML in the source files.
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Public Methods (MPBL)
Number of public methods
Protected Methods (MPRT)
Number of protected methods
Private Methods (MPRV)
Number of private methods
Static Methods (MSTA)
Number of static methods
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
PHP Lines of Code (PHPL)
Number of PHP lines of code in the source file(s).
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
PHP Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Python
Python Metrics
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Number of DocString lines (DOCL)
Count number of lines of python DocString
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Else Statements (ELSE)
Number of 'else' statements
Call to exit (EXIT)
Number of calls to the exit function
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
% of parsed tokens (PARSE)
Percent of parsed tokens
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Python Ruleset
There shall be a init method in the class. (CLASSNOINIT)
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Method should have "self" as first argument (METHODSELFFIRST)
Method has an attribute different the "self" as first argument.
Method without parameter (METHODWITHOUTPARAM)
Method without parameter.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Exec shall not be used. (NOEXEC)
Use of 'exec'
Use of exit is not recommended (NOEXIT)
exit should not be called to force the end of a program
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Label out a switch (NOLABEL)
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).
Print shall not be used. (NOPRINT)
Use of 'print'
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
'star' parameter shall not be used. (NOSTARPARAM)
Use of star parameter
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
There shall be only one Statement per line (ONESTMTPERLINE)
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
PL/SQL
PL/SQL Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Number of #DEFINE (P_DEFINE)
Number of #ELIF (P_ELIF)
Number of #ELSE (P_ELSE)
Number of #ENDIF (P_ENDIF)
Number of #ERROR (P_ERROR)
Number of #IF (P_IF)
Number of #IFDEF (P_IFDEF)
Number of #IFNDEF (P_IFNDEF)
Number of Include (P_INCLUDE)
Compiler FLAG Nested Level (P_NEST)
Number of #PRAGMA (P_PRAGMA)
Number of #UNDEF (P_UNDEF)
Number of #WARNING (P_WARNING)
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
PL/SQL Ruleset
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Commit Used (NOCOMMIT)
Commit instruction used in code
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Rollback Used (R_NOROLLBACK)
Rollback instruction used in code
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Swift
Swift Metrics
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Swift Ruleset
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
TSQL
TSQL Metrics
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Delete Statements (DELETE)
Number of Delete statements
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Insert Statements (INSERT)
Number of Insert statements
Label Statements (LABEL)
Number of Label statements
Line Count (LC)
Number of lines.
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Select Statements (SELECT)
Number of Select statements
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
Update Statements (UPDATE)
Number of Update statements
While Statements (WHIL)
Number of 'while' statements in the function
TSQL Ruleset
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
Typescript
Typescript Metrics
Number of data without accessibility (ANON)
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
Max Nested Functions (FNST)
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Typescript Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).
VB.net
VB.net Metrics
Constant Data (ACST)
Number of constant data
Fiend Attributes (AFRI)
Number of Friend Attributes
Number of Attributes (ANBR)
Number of attributes
Andthen Operators (ANTH)
Number of 'andthen' operators
Public Data (APBL)
Number of public data
Protected Data (APRT)
Number of protected data
Private data (APRV)
Number of private data
Shadowed Attributes (ASHD)
Number of Shadowed Attributes
Shared Attributes (ASHR)
Number of Shared Attributes
Number of comment blocks (BCOM)
Number of comment blocks.
Header Blocks Of Comment (BHCO)
Number block of comment placed before the beginning of the artefact.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Brace Lines (BRAC)
Number of lines of code containing only a brace in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Stop Statements (BRKP)
Number of Stop Statements (Breakpoints)
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Depth of Descendant Tree (DDT)
Maximun depth of the inheritance tree from the class
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Depth of Inheritance Tree (DIT)
DIT is the maximum depth of the class inheritance tree
Measurement method: The depth of inheritance tree counts the maximum length of inheritance from the class to the ultimate base class
Meaning: A large DIT reveals a long inheritance chain below the class and maybe a complex hierarchy, adding methods to that class may impact many inherited subclasses with inappropriate behaviours.
Improving: Carefully test the newly implemented methods in that class, verify if the abstraction tree could not be redesigned.
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Friend Events (EFRI)
Number of Friend Events
Else Statements (ELSE)
Number of 'else' statements
Events (ENBR)
Number of Events
Public Events (EPBL)
Number of Public Events
Protected Events (EPRT)
Number of Protected Events
Private Events (EPRV)
Number of Private Events
Shadowed Events (ESHD)
Number of Shadowed Events
Shared Events (ESHR)
Number of Shared Events
Call to exit (EXIT)
Number of calls to the exit function
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Header Lines Of Comment (HCOM)
Number of comment lines placed before the beginning of the artefact.
Header Lines Of Code (HLOC)
Number of lines between the function or class definition and the first opening brace.
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
End Statements (KILL)
Number of End Statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Declare Members (MDEC)
Number of Declare Members
Delegate Members (MDEL)
Number of Delegate Members
Friend Members (MFRI)
Number of Friend Members
Multiple Inheritance Indicator (MII)
Number of classes from which the class inherits directly.
Note: For Java Classes and Interfaces, the MII is computed by ignoring the number of implemented classes/interfaces (which is counted by the 'IIMPL' measure).
Mixed Lines (MLOC)
Number of lines containing both code and comment in the source files.
Must Members (MMST)
Number of Must Members
Methods without Accessibility (MNON)
Number of methods without any accessibility specifier
Partial Members (MPAR)
Number of Partial Members
Public Methods (MPBL)
Number of public methods
Protected Methods (MPRT)
Number of protected methods
Private Methods (MPRV)
Number of private methods
Shadowed Members (MSHD)
Number of Shadowed Members
Shared Members (MSHR)
Number of Shared Members
Number of Ancestors (NAC)
Number of classes from which the class inherits directly or indirectly
Number of Descendants (NDC)
Number of classes which inherit from the class directly or indirectly
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number Of Children (NOC)
NOC is the number of classes that inherit directly from the class.
Measurement method: NOC counts the number of classes inheriting from the class we are in.
Meaning: The higher the number of children the higher the possible impact of the class. A modification in the class may impact many sub-classes and thus should be done carefully. A large NOC may reveal misuse of subclassing. However, the greater the NOC the better because it uses the power of reuse introduced by OO languages.
Improving: A high number of NOC should lead to more testing and if the class is already complex (suggested by other metrics) then it may need to be redesigned, intensively tested or carefully reviewed.
Number of Methods (NOM)
NOM is the number of methods defined in the class.
Meaning: A large number of methods may suggest a class with a lot of processes, making the overall actions of the class more complex to understand.
Improving: You may consider using inheritance or more intensively review submodules.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
% of parsed tokens (PARSE)
Percent of parsed tokens
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Friend Properties (PFRI)
Number of Fiend Properties
Must Properties (PMST)
Number of Must Properties
Properties (PNBR)
Total number of properties
Public Properties (PPBL)
Number of public properties
Protected Properties (PPRT)
Number of protected properties
Private Properties (PPRV)
Number of private properties
Shadowed Properties (PSHD)
Number of Shadowed Properties
Shared Properties (PSHR)
Number of Shared Properties
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Skipped Lines of Comment code (SKLC)
Skipped Lines of Comment code i.e. lines that match a user defined regular expression to skip lines of comments.
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
VB.net Ruleset
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Missing Case Else clause (CASEELSE)
The final clause of a Select statement shall be the Case Else clause.
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
Use of Exit Do statement (EXITDO)
Do not use Exit Do statement to break a Do loop.
Use of Exit Function statement (EXITFCT)
Do not use Exit Function statement, use Return instead.
Use of Exit For statement (EXITFOR)
Do not use Exit For statement to break a For loop.
Use of Exit Property statement (EXITPROP)
Do not use Exit Property statement, use Return instead.
Use of Exit Select statement (EXITSELECT)
Do not use Exit Select statement to exit a Select statement.
Use of Exit Sub statement (EXITSUB)
Do not use Exit Sub statement.
Use of Exit Try statement (EXITTRY)
Do not use Exit Try statement to exit a Try statement.
Use of Exit While statement (EXITWHILE)
Do not use Exit While statement to break a While loop.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Avoid Duplicated Blocks in Function (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
No case in Select (ONECASE)
Every Select statement shall have at least one case clause.
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Multiple Exit Do statement (SGLEXITDO)
For any iteration statement there shall be at most one Exit statement used for loop termination.
Multiple Exit (Function, Sub or Property) statement (SGLEXITFCT)
A Function, Sub or Property must have only one Exit statement.
Multiple Exit For statement (SGLEXITFOR)
For any iteration statement there shall be at most one Exit statement used for loop termination.
Multiple Exit While statement (SGLEXITWHILE)
For any iteration statement there shall be at most one Exit statement used for loop termination.
Xaml
Xaml Metrics
Andthen Operators (ANTH)
Number of 'andthen' operators
Number of attributes (ATTR)
Number of attributes.
Number of comment blocks (BCOM)
Number of comment blocks.
Blank Lines (BLAN)
Number of blank lines of code in the source file(s).
Break in Loop (BRKL)
Number of 'break' statements in loop in the function
Break in Switch (BRKS)
Number of 'break' statements in 'switch' in the function
Case Blocks (CABL)
Number of 'case' blocks in 'switch' in the function
Case Labels (CASE)
Number of 'case' labels in the function
Catch Statements (CATC)
Number of 'catch' statements in the function
Cloned Code (CC)
Duplicated code of this artefact
Code Cloning Line Counting (CCLC)
Number of lines in source code used when searching for code duplication
Cyclomatic Complexity (CCN)
Number of linearly independent paths in the function control graph.
Control Flow Token (CFT)
Number of tokens in the control flow of functions
Cloned Control Flow Tokens (CFTC)
Number of duplicated tokens in control flow of functions
Comment Lines (CLOC)
Number of lines of comments in the source file(s).
Clones Number (CN)
Number of cloned artefacts
Continue Statements (CONT)
Number of 'continue' statements in the function
Commented Statements (CSTAT)
Number of Commented Statements.
Default Statement (DEFT)
Number of 'default' blocks in 'switch' in the function
Distinct Operands (DOPD)
DOPD counts the number of distinct operands: variables, constants, identifiers, constants and function names when used during calls. ([Halstead,76]: n2)
Example: In the expression A = B + 3; A, B and 3 are the operands.
Distinct Operators (DOPT)
Number of distinct operators: language keywords ([Halstead,76]: n1)
Do While Statements (DOWH)
Number of 'do…while' statements in the function
Else Statements (ELSE)
Number of 'else' statements
Number of XML elements (ELT)
Number of XML elements.
Comments containing FIXME (FIXME)
Number of Comments containing FIXME string.
For Statements (FOR)
Number of 'for' statements in the function
Structures Added (SADD)
Number of control structures added since the previous version.
Structures Modified (SMOD)
Number of control structures modified since the previous version.
Structures Removed (SREM)
Number of control structures removed since the previous version.
Goto Statements (GOTO)
Number of 'goto' statements
Cloned Code (ICC)
Duplicated code in this artefact
Cloned Control Flow Tokens (ICFTC)
Number of duplicated tokens in control flow of functions
If Statements (IF)
Number of 'if' statements
Line Count (LC)
Number of lines.
Loop Statements (LOOP)
Number of loop statements in the function
Maximum Nested Structures (NEST)
NEST is the maximum nesting level found in the function.
Measurement method: Nesting is computed by counting the number of imbrication level. For loop, while loop, if conditional statement is all considered as a layer, thus an if statement inside a for loop will be measured as a nesting level of 2. In a consistently indented code, the nesting number can be visualized as the right most-indented line of the function’s body. The maximum of all blocks of code containing imbrication is kept. Notes, else if structures are considered as imbrication level.
Meaning: High nesting levels make the code difficult to understand and can lead to errors in program logic, it shows a complicated design with either to much control flow ( if/else statements) or computational complexity (for loops) or both of them. Above 5 of nesting, the function should be perceived as critical.
Improving: Consider splitting the procedure, inspect the code and/or add unit testing.
Number of Parameters (NOP)
NOP counts the number of formal parameters of the method.
Meaning: A high number of parameters suggests a strong coupling between modules in comparison with low numbers. A module with many parameters may require more time and effort to understand, and when modified it is more likely that it will have side effects on other modules.
Improving: If coding with object-oriented programming language you may consider if some parameters could be grouped inside an object. Consider refactoring in successive smaller modules if possible.
Non-Cyclic Paths (PATH)
PATH is the number of non-cyclic paths in the function.
Measurement method: PATH is calculated according to the transfers of control induced by the various types of statements. The PATH for a sequence of statements with the same nesting level is the product of each statement’s PATH. For nested structures, the sum of the PATH is calculated.
Meaning: PATH is an objective measure of software complexity related to the ease with which software can be comprehensively tested.
Improving: To reduce PATH for a function, try to divide the function into blocks of code that logically belong together. Create a new function for each block of code. Then replace each block of code with the newly created function. The original functionality is thus distributed, reducing the PATH value for the original function.
Example:
PATH(if then else endif) = PATH(body of then) + PATH(body of else)
PATH(while do-endwhile for) = PATH(body of while) + 1
PATH(switch) = SUM (i=1,n) PATH(body of case(i)), where n is the number of cases.
PATH(sequence) = 1
Orelse operators (OREL)
Number of 'orelse' operators
Partially parsed files (PARSING_ERROR)
Number of files where a parsing error occured, resulting in a partial interpretation
Return Statements (RETURN)
Number of 'return' statements in the function
Repeated Code Blocks (RS)
Duplicated blocks in the function
Source Lines Of Code (SLOC)
Number of lines of source code in the source file(s).
Executable Statements (STAT)
STAT counts the number of executable statements in the artifact.
Measurement method: A statement is a syntactic unit of an imperative programming language that expresses some action to be carried out. To be counted in STAT, the statement has to contain executable code. Declarations are not counted as executable statements.
Meaning: STAT is a measure of the size of the module, it highlights a complexity by counting the number of executable statements. A high number of statements may suggest a high algorithmic complexity. Many statements also suggest more time to fully read and thus to fully understand the module.
Improving: A module with more than 50 statements should be inspected, the analysis of the module can be completed with the help of others metrics such as VG, NEST…
Switch Statements (SWIT)
Number of 'switch' statements in the function
Ternary operators (TERN)
Number of ternary operators i.e. ?:
Number of text blocks (TEXT)
Number of text blocks.
Throw Statements (THRO)
Number of 'throw' statements in the function
Comments containing TODO (TODO)
Number of Comments containing TODO string.
Operand Occurrences (TOPD)
Number of occurrences of operands: variables and constants ([Halstead,76]: N2)
Operator Occurrences (TOPT)
Number of occurrences of operators: language keywords ([Halstead,76]: N1)
Try Statements (TRY)
Number of 'try' statements in the function
Lines Added (LADD)
Number of lines added since the previous version.
Lines Modified (LMOD)
Number of lines modified since the previous version.
Lines Removed (LREM)
Number of lines removed since the previous version.
While Statements (WHIL)
Number of 'while' statements in the function
Xaml Ruleset
Missing Break (BRKFINAL)
An unconditional break statement shall terminate every non-empty switch clause (see [MISRA-C:2004]: RULE 15.2).
Backward Goto shall not be used (BWGOTO)
Backward gotos shall not be used.
Comment Before Paragraph (COMMENT)
A comment shall introduce a section or a paragraph.
Missing compound statement (COMPOUND)
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 (COMPOUNDIF)
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).
Missing Default (DEFAULT)
The final clause of a switch statement shall be the default clause (see [MISRA-C:2004]: RULE 15.3).
Missing final else (ELSEFINAL)
All if … else if constructs shall be terminated with an else clause (see [MISRA-C:2004]: RULE 14.10).
No Resources (FORBIDDEN_ELEMENT)
Elements 'ResourceDictionary' are forbidden.
Resources Folder (IN_FOLDER)
ResourceDictionary shall be in a 'Resources' directory
Assignment in Condition (NOASGCOND)
Assignment operators should not be used in condition expressions (if, for, while, do, switch).
Assignment without Comparison (NOASGINBOOL)
Assignment operators shall not be used in condition expressions (if, for, while, do, switch) that does not contain comparison operators.
Factorizable Classes (CAC_CL)
Consider classes refactorization
Factorizable Files (CAC_FI)
Consider files refactorization
Factorizable Functions (CAC_FN)
Consider functions refactorization
Factorizable Packages (CAC_PKG)
Consider packages refactorization
Cloned Classes (CC_CL)
There shall be no duplicated classes
Cloned Files (CC_FI)
There shall be no duplicated files
Cloned Functions (CC_FN)
There shall be no duplicated functions
Cloned Algorithmic (CFTC_FN)
There shall be no algorithmic cloning
There shall be a no code before first case (NOCODEBEFORECASE)
There shall be a no code before the first case of a switch statement.
Continue shall not be used (NOCONT)
The 'continue' statement shall not be used (see [MISRA-C:2004]: RULE 14.5).
Fallthrough shall be avoided (NOFALLTHROUGH)
There shall be no fallthrough the next case in a switch statement.
FIXME shall not be commited in sources code (R_NOFIXME)
FIXME shall not be commited in sources code as it brings confusion regarding code reliability.
Goto shall not be used (NOGOTO)
The 'goto' statement shall not be used (see [MISRA-C:2004]: RULE 14.4).
Label out a switch (NOLABEL)
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 (RS_FN)
There shall be no duplicated parts in functions
TODO shall not be commited in sources code (R_NOTODO)
TODO shall not be commited in sources code as it brings confusion regarding code reliability.
Missing case in switch (ONECASE)
Every switch statement shall have at least one case clause (see [MISRA-C:2004]: RULE 15.5).
Relaxed violation (RELAX)
A rule violation is relaxed and justified.
Resources Filename (RESOURCES_FILENAME)
All XAML resources files shall be suffixed with 'Resources.xaml'
Multiple exits are not allowed (RETURN)
A function shall have a single point of exit at the end (see [MISRA-C:2004]: RULE 14.7).
Risky Empty Statement (RISKYEMPTY)
Multiple break in loop are not allowed (SGLBRK)
For any iteration statement there shall be at most one 'break' statement used for loop termination (see [MISRA-C:2004]: RULE 14.6).