Commit 34769985 authored by Apollon VIEIRA's avatar Apollon VIEIRA Committed by Gerson SUNYE
Browse files

fix issue 740 ExcessiveMethodLength updated

parent 80cd461f
This diff is collapsed.
......@@ -70,6 +70,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.avoidThrowingNullPointerException(),
thisModule.ExcessiveClassLength(),
thisModule.excessiveImports(),
thisModule.excessiveMethodLength(),
thisModule.excessiveParameterList(),
thisModule.excessivePublicCount(),
thisModule.finalFieldCouldBeStatic(),
......@@ -1077,6 +1078,27 @@ rule MeasureExcessiveImports(i : java!CompilationUnit) {
}
}
-- ------------------------------------------ ExcessiveMethodLength ---------------------------------------------
--- creates a new Measure when a class has more than 4 imports
rule MeasureExcessiveMethodLength(block : java!Block) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'Excessive Method Length',
shortDescription <- 'Methods with numerous parameters are a challenge to maintain, especially if most of them share the same datatype.'
),
measurement: smm!DirectMeasurement (
error <- 'The class ' + block.originalCompilationUnit.name + ' has an excessive method length in the method ',
value<- block.statements.size()
)
do {
noc;
}
}
-- ------------------------------------------- MeasureExtendsObject ---------------------------------------------
--- A Measure instance if the class violates the rule ExtendsObject.
rule MeasureExtendsObject(variable : java!ClassDeclaration) {
......
......@@ -57,6 +57,14 @@ helper def: returnEmptyArrayRatherThanNull() : Set(smm!Measure) =
-> collect(statement | thisModule.MesureReturnEmptyArrayRatherThanNull(statement))
);
-- ------------------------------------------ ExcessiveMethodLength ---------------------------------------------
--- Helper for issue ExcessiveMethodLength : return a Measure for each class that contains a method with excessive length.
helper def: excessiveMethodLength() : Set(smm!Measure) =
java!Block.allInstances()
-> select (b | b.statements.size() > 40)
-> collect(b | thisModule.MeasureExcessiveMethodLength(b));
--------------------------------------------- ExcessiveParameterList ---------------------------------------------
-- Helper for issue ExcessiveParameterList : return a Measure for each method that has too many parameters.
helper def: excessiveParameterList() : Set(smm!Measure) =
......
Markdown is supported
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