codestyle.atl 1.23 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
library codestyle;

------------------------------------------------------------------------------------------

-- Rule for metrics shortMethodName : return the set of method Measures that violates the rule.
helper def: shortMethodName() : Set(smm!Measure) =
	-- Browse through all method 
	java!MethodDeclaration.allInstances() -> reject(each | each.isProxy())->iterate(i; res : Set(smm!Measure) = Set{} |
		-- Add a new measurement if the size of the method name is less than 3.
		if i.name.size() < 3
		then res->union(Set{thisModule.MesureShortMethodName(i)})
		else res
		endif
	);

--------------------------------------------- TooManyStaticImports ---------------------------------------------

-- Rule for metrics TooManyStaticImports : return the set of class Measures that violates the rule.
helper def: tooManyStaticImports() : Set(smm!Measure) =
	-- Browse through all class(CompilationUnit) 
	java!CompilationUnit.allInstances()->iterate(i; res : Set(smm!Measure) = Set{} |
		-- Add a new measurement if there are more than 4 static imports in the class.
23
		if i.types.first().oclIsTypeOf(java!ClassDeclaration) and i.imports->select(i | i.static)->size() > 4
24
25
26
		then res->union(Set{thisModule.MesureTooManyStaticImports(i)})
		else res
		endif
27
	);