diff --git a/src/main/atl/analysis.atl b/src/main/atl/analysis.atl index ed1e0c2cb3b3c23917dbd67846b11047930f1dcd..68cacf6de4091f14b2d9c82d3e30857444099a73 100644 --- a/src/main/atl/analysis.atl +++ b/src/main/atl/analysis.atl @@ -38,6 +38,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = -- Multithreading rules -- thisModule.useNotifyAllInsteadOfNotify(), + thisModule.avoidThreadGroup(), + thisModule.dontCallThreadRun(), -- Code Style rules -- @@ -72,7 +74,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = thisModule.emptyStatementBlock(), thisModule.avoidRethrowingException(), thisModule.integerInstantiation(), - thisModule.stringToString(), + -- thisModule.stringToString(), -- Documentation rules -- @@ -115,8 +117,6 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = -- thisModule.doNotThrowExceptionInFinally(), -- thisModule.finalizeShouldBeProtected(), -- thisModule.avoidDollarSigns(), - -- thisModule.avoidThreadGroup(), - -- thisModule.dontCallThreadRun(), -- thisModule.returnEmptyArrayRatherThanNull(), -- thisModule.replaceVectorToList() -- thisModule.unusedPrivateMethod () diff --git a/src/main/atl/multithreading.atl b/src/main/atl/multithreading.atl index 081edc9238bb2a3769b343f38613d2e67a47133f..e7d8ebd895eb9837cb3f734bfd8a02aebd9f32b8 100644 --- a/src/main/atl/multithreading.atl +++ b/src/main/atl/multithreading.atl @@ -7,35 +7,17 @@ library multithreading; helper def: dontCallThreadRun() : Set(smm!Measure) = java!MethodInvocation.allInstances() -> select (m | m.method.name='run' ) - -> select (m | m.expression.isDontCallThreadRun() ) + -> select (m | m.method.abstractTypeDeclaration.name = 'Thread' ) -> collect (m | thisModule.MeasureDontCallThreadRun(m)); ---Detect a wrong usage of the method Thread.run() ---return true if run() is called on a Thread variable -helper context java!SingleVariableAccess def : isDontCallThreadRun(): Boolean = - --check if the method is called like this: - --t.run() where t is of type Thread - self.variable.variablesContainer.type.type.name.toString() = 'Thread'; - - ---Detect a wrong usage of the method Thread.run() ---return true if run() is called on a Thread instance creation -helper context java!ClassInstanceCreation def : isDontCallThreadRun(): Boolean = - --check if the method run is called like this: - --new Thread().run(); - self.method.name.toString() = 'Thread'; - - - --------------------------------------------- AvoidThreadGroup --------------------------------------------- --Goes through all the variables to check if the following rule is followed: --Avoid using java.lang.ThreadGroup; helper def: avoidThreadGroup() : Set(smm!Measure) = - java!VariableDeclarationFragment.allInstances() - -> select(i | i.variablesContainer.type.toString() <> 'OclUndefined') - -> select(s|s.variablesContainer.type.type.name.toString() = 'ThreadGroup') - -> collect(i | thisModule.measureAvoidThreadGroup(i) ); + java!VariableDeclarationStatement.allInstances() + -> select(variable | variable.type.type.name = 'ThreadGroup') + -> collect(variable | thisModule.measureAvoidThreadGroup(variable) ); --------------------------------------------- UseNotifyAllInsteadOfNotify ---------------------------------------------