Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Roxane MARECHAL
Source Code Analyzer
Commits
f5bce021
Commit
f5bce021
authored
Dec 20, 2019
by
Raphael PAGE
Committed by
Gerson SUNYE
Dec 20, 2019
Browse files
Revert "REMOVED ALL IF THEN ELSE"
This reverts commit 7f7099f93e6bc4b785033b2ecdc1d38678335428.
parent
353af789
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/atl/analysis.atl
View file @
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 ()
...
...
src/main/atl/multithreading.atl
View file @
f5bce021
...
...
@@ -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.isDontCall
Thread
Run()
)
-> 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 ---------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment