Commit b524aa1e authored by Khaled AMIRAT's avatar Khaled AMIRAT
Browse files

Update src/main/atl/analysis.atl, src/main/atl/codestyle.atl, src/main/atl/errorProne.atl files

parent 5162f574
......@@ -99,7 +99,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptySwitchStatement(),
thisModule.emptySynchronizedBlock(),
thisModule.emptyFinallyBlock(),
thisModule.emptyfinalizeMethod(),
--thisModule.emptyfinalizeMethod(),
--thisModule.doNotThrowExceptionInFinally(),
--thisModule.finalizeShouldBeProtected(),
......
......@@ -61,6 +61,17 @@ helper def: longVariable() : Set(smm!Measure) =
--------------------------------------------- ShortVariableName ---------------------------------------------
-- Rule for metrics shortVariableName : return the set of variables measures that violates the rule.
helper def: shortVariableName() : Set(smm!Measure) =
java!SingleVariableDeclaration.allInstances()
-> reject(each | each.isProxy() or not each.catchClause->oclIsUndefined() or not each.enhancedForStatement->oclIsUndefined())
-> select( i | i.name.size() < 3)
-> union( java!VariableDeclarationFragment.allInstances()
-> reject(each | each.isProxy() or each.variablesContainer.oclIsTypeOf(java!VariableDeclarationExpression))
-> select( i | i.name.size() < 3)
)
-> collect (i | thisModule.MesureShortVariableName(i));
----- Fix Issues #699
......
......@@ -180,6 +180,41 @@ helper def: finalizeShouldBeProtected() : Set(smm!Measure) =
->select(m | m.name = 'finalize' and m.modifier.visibility.toString() <> 'protected')
->collect(m | thisModule.MesureFinalizeShouldBeProtected(m));
--------------------------------------------- EmptySwitchStatement ---------------------------------------------
--Detects the use of empty switch statements. These blocks serve no purpose and should be removed
helper def: emptySwitchStatement() : Set(smm!Measure) =
java!SwitchStatement.allInstances()
->select(switchStatement | switchStatement.statements.isEmpty())
->collect(switchStatement | thisModule.MeasureEmptySwitchStatement(switchStatement));
------------------------------------------ EmptySynchronizedBlock ---------------------------------------------
--Detects the use of empty synchronized block. These blocks serve no purpose and should be removed
helper def: emptySynchronizedBlock() : Set(smm!Measure) =
java!SynchronizedStatement.allInstances()
->select(synchronizedBlock | synchronizedBlock.body.statements.isEmpty() )
->collect(synchronizedBlock | thisModule.MeasureEmptySynchronizedBlock(synchronizedBlock));
---------------------------------------- EmptyFinallyBlock----------------------------------------------
-- Rule for metrics EmptyFinallyBlock
helper def: emptyFinallyBlock() : Set(smm!Measure) =
java!TryStatement.allInstances()
->select( finallyBlock | finallyBlock.finally.statements.isEmpty())
->collect(finallyBlock| thisModule.MeasureEmptyFinallyBlock(finallyBlock));
----------------------------------------- EmptyFinalizer----------------------------------------------
-- Rule for metrics EmptyFinalizer
helper def: emptyfinalizeMethod() : Set(smm!Measure) =
java!MethodDeclaration.allInstances()
->select( finalizeMethod | finalizeMethod.name = 'finalize' and finalizeMethod.body.statements.isEmpty())
->collect(finalizeMethod| thisModule. MeasureEmptyFinalizer(finalizeMethod));
--- Issues #780, #784, #799, #819, #862, #871
......
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