Commit 78fab2a3 authored by Gerson SUNYE's avatar Gerson SUNYE
Browse files

Merge branch 'master' into 'master'

Fix Bug #619 , #825 , #830

See merge request naomod/mde/projet-2019!138
parents 56b81c52 bdeadfa2
...@@ -113,6 +113,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -113,6 +113,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptySwitchStatement(), thisModule.emptySwitchStatement(),
thisModule.emptySynchronizedBlock(), thisModule.emptySynchronizedBlock(),
thisModule.emptyTryBlock(), thisModule.emptyTryBlock(),
thisModule.emptyWhileStmt(),
thisModule.finalizeShouldBeProtected(),
thisModule.importFromSamePackage(), thisModule.importFromSamePackage(),
thisModule.missingBreakInSwitch(), thisModule.missingBreakInSwitch(),
thisModule.suspiciousEqualsMethodName(), thisModule.suspiciousEqualsMethodName(),
...@@ -121,6 +123,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -121,6 +123,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.UseProperClassLoader(), thisModule.UseProperClassLoader(),
-- Best practices rules -- Best practices rules
thisModule.avoidStringBufferField(),
thisModule.forLoopVariableCount(), thisModule.forLoopVariableCount(),
thisModule.switchDensity(), thisModule.switchDensity(),
thisModule.useAssertSameInsteadOfAssertTrue(), thisModule.useAssertSameInsteadOfAssertTrue(),
...@@ -131,15 +134,12 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -131,15 +134,12 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- thisModule.UseArrayListInsteadOfVector(), -- thisModule.UseArrayListInsteadOfVector(),
-- thisModule.commentRequired(), -- thisModule.commentRequired(),
-- thisModule.compareObjectsWithEquals(), -- thisModule.compareObjectsWithEquals(),
-- thisModule.emptyWhileStmt(),
-- thisModule.emptyFinallyBlock(), -- thisModule.emptyFinallyBlock(),
-- thisModule.emptyfinalizeMethod(), -- thisModule.emptyfinalizeMethod(),
-- thisModule.doNotThrowExceptionInFinally(), -- thisModule.doNotThrowExceptionInFinally(),
-- thisModule.finalizeShouldBeProtected(),
-- thisModule.returnEmptyArrayRatherThanNull(), -- thisModule.returnEmptyArrayRatherThanNull(),
-- thisModule.replaceVectorToList() -- thisModule.replaceVectorToList()
-- thisModule.unusedPrivateMethod () -- thisModule.unusedPrivateMethod ()
-- thisModule.avoidStringBufferField()
-- thisModule.avoidThrowingNewInstanceOfSameException(), -- thisModule.avoidThrowingNewInstanceOfSameException(),
-- thisModule.stringToString(), -- thisModule.stringToString(),
-- thisModule.methodWithSameNameAsEnclosingClass(), -- thisModule.methodWithSameNameAsEnclosingClass(),
...@@ -1080,7 +1080,7 @@ rule MeasureAvoidCallingFinalize(methode : java!MethodInvocation) { ...@@ -1080,7 +1080,7 @@ rule MeasureAvoidCallingFinalize(methode : java!MethodInvocation) {
--------------------------------------------- AvoidStringBufferField --------------------------------------------- --------------------------------------------- AvoidStringBufferField ---------------------------------------------
-- A Measure instance if the class violates AvoidStringBufferField . -- A Measure instance if the class violates AvoidStringBufferField .
rule MeasureAvoidStringBufferField(declaration : java!VariableDeclaration) { rule MeasureAvoidStringBufferField(declaration : java!FieldDeclaration) {
to to
om: smm!ObservedMeasure ( om: smm!ObservedMeasure (
measure <- noc, measure <- noc,
...@@ -1141,7 +1141,7 @@ rule MeasureEmptyTryBlock(t : java!TryStatement) { ...@@ -1141,7 +1141,7 @@ rule MeasureEmptyTryBlock(t : java!TryStatement) {
---------------------EmptyWhileStmt---------------------------------- ---------------------EmptyWhileStmt----------------------------------
--A measure instance if the class violates the rule EmptyWhileStmt. --A measure instance if the class violates the rule EmptyWhileStmt.
rule MeasureEmptyWhileStmt(w : java!TryStatement) { rule MeasureEmptyWhileStmt(w : java!WhileStatement) {
to to
om: smm!ObservedMeasure ( om: smm!ObservedMeasure (
measure <- noc, measure <- noc,
......
...@@ -80,9 +80,9 @@ helper context java!FieldDeclaration def: isBoolean() : Boolean = ...@@ -80,9 +80,9 @@ helper context java!FieldDeclaration def: isBoolean() : Boolean =
-- Rule for metrics AvoidStringBufferField -- Rule for metrics AvoidStringBufferField
helper def: avoidStringBufferField() : Set(smm!Measure) = helper def: avoidStringBufferField() : Set(smm!Measure) =
java!FieldDeclaration.allInstances() 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)); ->collect(dec | thisModule.MeasureAvoidStringBufferField(dec));
---------------------------------------------UseAssertSameInsteadOfAssertTrue--------------------------------------------- ---------------------------------------------UseAssertSameInsteadOfAssertTrue---------------------------------------------
helper def: useAssertSameInsteadOfAssertTrue() : Set(smm!Measure) = helper def: useAssertSameInsteadOfAssertTrue() : Set(smm!Measure) =
-- Browse through all methods use -- Browse through all methods use
......
...@@ -163,9 +163,9 @@ helper def: emptyTryBlock() : Set(smm!Measure) = ...@@ -163,9 +163,9 @@ helper def: emptyTryBlock() : Set(smm!Measure) =
-- Rule for metrics EmptyWhileStmt -- Rule for metrics EmptyWhileStmt
helper def: emptyWhileStmt() : Set(smm!Measure) = helper def: emptyWhileStmt() : Set(smm!Measure) =
java!WhileStatement.allInstances() 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)); ->collect(w | thisModule.MeasureEmptyWhileStmt(w));
------------------------------------------- MeasureDontImportSun---------------------------------------------- ------------------------------------------- MeasureDontImportSun----------------------------------------------
-- Rule for metrics DontImportSun -- Rule for metrics DontImportSun
helper def: dontImportSun() : Set(smm!Measure) = helper def: dontImportSun() : Set(smm!Measure) =
...@@ -177,7 +177,7 @@ helper def: dontImportSun() : Set(smm!Measure) = ...@@ -177,7 +177,7 @@ helper def: dontImportSun() : Set(smm!Measure) =
-- Rule for metrics FinalizeShouldBeProtected -- Rule for metrics FinalizeShouldBeProtected
helper def: finalizeShouldBeProtected() : Set(smm!Measure) = helper def: finalizeShouldBeProtected() : Set(smm!Measure) =
java!MethodDeclaration.allInstances() 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)); ->collect(m | thisModule.MesureFinalizeShouldBeProtected(m));
......
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