You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also called Cognitive Complexity, this measure computes the cognitive weight of a Java Architecture. The cognitive weight represents the complexity of a code architecture in terms of maintainability and code understanding.
Measure Architecture
Type : Direct Measure
Data Model
value : Integer
Scope
Property1 : The link of the SVN repository of the java project
Property2 : The login of the SVN repository
Property3 : The password associated to the login
Depenpendency
No dependency
Algorithms
The implementation of that measure computes the cognitive weight of a Java project by adding the cognitive weight of each method of each class.
In order to compute the cognitive weight of a method, we focus on the nested level of conditional statements/blocks (if-then-else) and the for and foreach loops. As shown in the pseudocode below, each level is associated with a weight (a number) and thus all these weights are summed. Therefore, we add the weights of all methods to have the cognitive weight of a class.
CognitiveWeight(statements block, integer weight, integer level):
For each statement S of block
If S is conditional statement or for statement of foreach statement:
level2=level+1
weight2=weight+level
S1 = block1 of S
CognitiveWeight(S1,weight2,level2)
End If
End For
End
Execution result
The result of the cognitive measure is the number representing the cognitive weight of the project, in other terms, it returns the sum of the weight of each method of each class of the project provided as the scope parameter.