Commit 899a673b authored by Knowish's avatar Knowish
Browse files

fix issue #656 with comment

parent 933cc9b4
......@@ -93,14 +93,10 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.emptyWhileStmt(),
thisModule.dontImportSun(),
--thisModule.finalizeShouldBeProtected(),
-- Best practicices rules
thisModule.avoidThrowingNewInstanceOfSameException(),
thisModule.switchDensity(),
thisModule.useAssertTrueInsteadOfAssertEquals(),
-- Best practices rules
thisModule.avoidThrowingNewInstanceOfSameException(),
thisModule.useAssertTrueInsteadOfAssertEquals(),
thisModule.switchDensity()
--thisModule.avoidStringBufferField()
......
......@@ -66,23 +66,24 @@ helper def: switchDensity() : Set (smm!Measure) =
helper def: useAssertTrueInsteadOfAssertEquals() : Set(smm!Measure) =
-- Browse through all methods use
java!MethodInvocation.allInstances()
--if the method use is assertEqual
--Check if the method use is assertEqual and a Boolean is used
->select(assert | thisModule.isWrongUseAssertTrueInsteadOfAssertEquals(assert) and assert.method.name = 'assertEquals')
->collect(assert | thisModule.MesureUseAssertTrueInsteadOfAssertEquals(assert));
helper def: isWrongUseAssertTrueInsteadOfAssertEquals(m:java!MethodInvocation) : Boolean =
let lastArgument : java!Expression = m.arguments.last() in lastArgument.isBoolean();
--Shorten the path m.arguments.last() to lastArgument and check if it's a boolean
let lastArgument : java!Expression = m.arguments.last() in lastArgument.isBoolean();
--if it's a variable check if it's a boolean
--Checks if it's a BooleanLiteral
helper context java!BooleanLiteral def: isBoolean() : Boolean = true;
--if it's a variable check if it's a boolean
--Checks if the type of a Expression is Boolean
helper context java!Expression def: isBoolean() : Boolean =
self.variable.variablesContainer.isBoolean();
--if it's a variable check if it's a boolean
--Checks if the type of a VariableDeclarationStatement is Boolean
helper context java!VariableDeclarationStatement def: isBoolean() : Boolean =
self.type.type.name= 'boolean';
--use in case of use Boolean.TRUE or Boolean.FALSE
--Use in case of Boolean.TRUE or Boolean.FALSE
helper context java!FieldDeclaration def: isBoolean() : Boolean =
self.abstractTypeDeclaration.name = 'Boolean';
......
Supports Markdown
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