Commit fbf1a695 authored by E19C506H's avatar E19C506H
Browse files

ExcessiveClassLength

parent fa6c7381
......@@ -50,7 +50,7 @@ helper def: allMeasures(project: java!Model): Set(smm!Measure) =
thisModule.noPackageDeclaration(),
thisModule.UnconditionalIfStatement(),
thisModule.EmptyInitializer(),
thisModule.ExcessiveMethodLength(),
thisModule.ExcessiveClassLength(),
-- Design rules
--
thisModule.tooManyFields(),
......@@ -1231,19 +1231,19 @@ rule MeasureEmptyInitializer(w: java!Initializer) {
}
}
-- A Measure instance if the class violates the rule ExcessiveMethodLength.
rule MeasureExcessiveMethodLength(w: java!MethodDeclaration) {
-- A Measure instance if the class violates the rule ExcessiveClassLength.
rule MeasureExcessiveClassLength(w: java!MethodDeclaration) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'ExcessiveMethodLength',
shortDescription <- ': methods are excessively long this usually indicates that the method is doing more than its name/signature might suggest. They also become challenging for others to digest since excessive scrolling causes readers to lose focus'
name <- 'ExcessiveClassLength',
shortDescription <- ': class file lengths are usually indications that the class may be burdened with excessive responsibilities that could be provided by external classes or functions'
),
measurement: smm!DirectMeasurement (
error <- w.originalCompilationUnit.name+ 'has a methode with more than 1000 line of code per a method it may need a separation in the code'
error <- w.originalCompilationUnit.name+ 'has a block with more than 1000 line of code per a method it may need a separation in the code'
)
do {
noc;
......
......@@ -88,12 +88,12 @@ helper def: EmptyInitializer() : Set(smm!Measure) =
-- Rule for metrics ExcessiveClassLength : return the set of class Measures that violates the rule.
helper def: ExcessiveMethodLength() : Set(smm!Measure) =
helper def: ExcessiveClassLength() : Set(smm!Measure) =
java!MethodDeclaration.allInstances()
->select (w | w.body <> OclUndefined )
->select (w | w.body.statements <> OclUndefined )
->select (w| w.body.statements.size() > 1000)
->collect(w | thisModule.MeasureExcessiveMethodLength(w));
->collect(w | thisModule.MeasureExcessiveClassLength(w));
......
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