Commit 12a0774e authored by Gerson SUNYE's avatar Gerson SUNYE
Browse files

Merge branch 'master' into 'master'

Fix #876, Fix #616, Fix #873, Fix #910

Closes #910, #873, #616, and #876

See merge request naomod/mde/projet-2019!115
parents 353af789 f5bce021
......@@ -38,6 +38,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- Multithreading rules
--
thisModule.useNotifyAllInsteadOfNotify(),
thisModule.avoidThreadGroup(),
thisModule.dontCallThreadRun(),
-- Code Style rules
--
......@@ -74,7 +76,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptyStatementBlock(),
thisModule.avoidRethrowingException(),
thisModule.integerInstantiation(),
thisModule.stringToString(),
-- thisModule.stringToString(),
-- Documentation rules
--
......@@ -122,8 +124,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 ()
......
......@@ -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 ---------------------------------------------
......
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