Commit ec47bfd8 authored by Gerson Sunyé's avatar Gerson Sunyé
Browse files

More code reorganization: new library codestyle

parent 73074e35
......@@ -6,6 +6,7 @@ module analysis;
create OUT: smm from IN: java;
uses design;
uses codestyle;
rule Java2SMM {
from
......@@ -131,18 +132,6 @@ rule MesureAvoidDollarSigns(node : java!ASTNode) {
}
}
------------------------------------------------------------------------------------------
-- 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
);
-- A Measure instance if the class violates the rule 'ShortMethodName'.
......@@ -398,18 +387,6 @@ rule MesureReturnFromFinallyBlock(method : java!MethodDeclaration) {
noc;
}
}
--------------------------------------------- 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.
if thisModule.numberOfStaticImportInClass(i) > 4
then res->union(Set{thisModule.MesureTooManyStaticImports(i)})
else res
endif
);
-- Return the number of static imports in a specific ClassDeclaration.
helper def: numberOfStaticImportInClass(s:java!CompilationUnit) : Integer =
......
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.
if thisModule.numberOfStaticImportInClass(i) > 4
then res->union(Set{thisModule.MesureTooManyStaticImports(i)})
else res
endif
);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment