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 !138
parents 56b81c52 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!VariableDeclaration) {
rule MeasureAvoidStringBufferField(declaration : java!FieldDeclaration) {
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!TryStatement) {
rule MeasureEmptyWhileStmt(w : java!WhileStatement) {
to
om: smm!ObservedMeasure (
measure <- noc,
......
......@@ -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
......
......@@ -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));
......
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