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
naomod
Model Driven Engineering (MDE)
Source Code Analyzer
Commits
bdeadfa2
Commit
bdeadfa2
authored
Dec 21, 2019
by
Oussama EL KOURRI
Committed by
Gerson SUNYE
Dec 21, 2019
Browse files
Fix Bug #619 , #825 , #830
parent
56b81c52
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/atl/analysis.atl
View file @
bdeadfa2
...
...
@@ -113,6 +113,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptySwitchStatement(),
thisModule.emptySynchronizedBlock(),
thisModule.emptyTryBlock(),
thisModule.emptyWhileStmt(),
thisModule.finalizeShouldBeProtected(),
thisModule.importFromSamePackage(),
thisModule.missingBreakInSwitch(),
thisModule.suspiciousEqualsMethodName(),
...
...
@@ -121,6 +123,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.UseProperClassLoader(),
-- Best practices rules
thisModule.avoidStringBufferField(),
thisModule.forLoopVariableCount(),
thisModule.switchDensity(),
thisModule.useAssertSameInsteadOfAssertTrue(),
...
...
@@ -131,15 +134,12 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- thisModule.UseArrayListInsteadOfVector(),
-- thisModule.commentRequired(),
-- thisModule.compareObjectsWithEquals(),
-- thisModule.emptyWhileStmt(),
-- thisModule.emptyFinallyBlock(),
-- thisModule.emptyfinalizeMethod(),
-- thisModule.doNotThrowExceptionInFinally(),
-- thisModule.finalizeShouldBeProtected(),
-- thisModule.returnEmptyArrayRatherThanNull(),
-- thisModule.replaceVectorToList()
-- thisModule.unusedPrivateMethod ()
-- thisModule.avoidStringBufferField()
-- thisModule.avoidThrowingNewInstanceOfSameException(),
-- thisModule.stringToString(),
-- thisModule.methodWithSameNameAsEnclosingClass(),
...
...
@@ -1080,7 +1080,7 @@ rule MeasureAvoidCallingFinalize(methode : java!MethodInvocation) {
--------------------------------------------- AvoidStringBufferField ---------------------------------------------
-- A Measure instance if the class violates AvoidStringBufferField .
rule MeasureAvoidStringBufferField(declaration : java!
Variable
Declaration) {
rule MeasureAvoidStringBufferField(declaration : java!
Field
Declaration) {
to
om: smm!ObservedMeasure (
measure <- noc,
...
...
@@ -1141,7 +1141,7 @@ rule MeasureEmptyTryBlock(t : java!TryStatement) {
---------------------EmptyWhileStmt----------------------------------
--A measure instance if the class violates the rule EmptyWhileStmt.
rule MeasureEmptyWhileStmt(w : java!
Try
Statement) {
rule MeasureEmptyWhileStmt(w : java!
While
Statement) {
to
om: smm!ObservedMeasure (
measure <- noc,
...
...
src/main/atl/bestPractices.atl
View file @
bdeadfa2
...
...
@@ -80,9 +80,9 @@ helper context java!FieldDeclaration def: isBoolean() : Boolean =
-- Rule for metrics AvoidStringBufferField
helper def: avoidStringBufferField() : Set(smm!Measure) =
java!FieldDeclaration.allInstances()
->select(dec | dec.type.type.name = 'StringBuffer' or dec.type.type.name = 'StringBuilder')
->select(dec | dec.type <> OclUndefined )
->select(dec | ( dec.type.type.name = 'StringBuffer' or dec.type.type.name = 'StringBuilder'))
->collect(dec | thisModule.MeasureAvoidStringBufferField(dec));
---------------------------------------------UseAssertSameInsteadOfAssertTrue---------------------------------------------
helper def: useAssertSameInsteadOfAssertTrue() : Set(smm!Measure) =
-- Browse through all methods use
...
...
src/main/atl/errorProne.atl
View file @
bdeadfa2
...
...
@@ -163,9 +163,9 @@ helper def: emptyTryBlock() : Set(smm!Measure) =
-- Rule for metrics EmptyWhileStmt
helper def: emptyWhileStmt() : Set(smm!Measure) =
java!WhileStatement.allInstances()
->select( w | w.body.statements.size() = 0)
->select( w | w.body.oclIsTypeOf(java!Block))
->select(w | w.body.statements.isEmpty())
->collect(w | thisModule.MeasureEmptyWhileStmt(w));
------------------------------------------- MeasureDontImportSun----------------------------------------------
-- Rule for metrics DontImportSun
helper def: dontImportSun() : Set(smm!Measure) =
...
...
@@ -177,7 +177,7 @@ helper def: dontImportSun() : Set(smm!Measure) =
-- Rule for metrics FinalizeShouldBeProtected
helper def: finalizeShouldBeProtected() : Set(smm!Measure) =
java!MethodDeclaration.allInstances()
->select(m | m.name = 'finalize' and m.modifier
.visibility.toString()
<> 'protected')
->select(m | m.name = 'finalize' and m.modifier <> 'protected')
->collect(m | thisModule.MesureFinalizeShouldBeProtected(m));
...
...
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