Commit a872a2f2 authored by Marion HUNAULT's avatar Marion HUNAULT Committed by Gerson SUNYE
Browse files

Correction #904 String toString

parent 2d3a3528
...@@ -91,6 +91,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -91,6 +91,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.integerInstantiation(), thisModule.integerInstantiation(),
-- #FIXME: -- #FIXME:
-- thisModule.startsWith(), -- thisModule.startsWith(),
thisModule.stringToString(),
thisModule.tooFewBranchesForASwitchStatement(), thisModule.tooFewBranchesForASwitchStatement(),
-- #FIXME: thisModule.useArraysAsList(), -- #FIXME: thisModule.useArraysAsList(),
thisModule.useIndexOfChar(), thisModule.useIndexOfChar(),
...@@ -152,7 +153,6 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) = ...@@ -152,7 +153,6 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- thisModule.replaceVectorToList() -- thisModule.replaceVectorToList()
-- thisModule.unusedPrivateMethod () -- thisModule.unusedPrivateMethod ()
-- thisModule.avoidThrowingNewInstanceOfSameException(), -- thisModule.avoidThrowingNewInstanceOfSameException(),
-- thisModule.stringToString(),
-- thisModule.methodWithSameNameAsEnclosingClass(), -- thisModule.methodWithSameNameAsEnclosingClass(),
-- thisModule.dontUseFloatTypeForLoopIndices(), -- thisModule.dontUseFloatTypeForLoopIndices(),
-- thisModule.methodWithSameNameAsEnclosingClass(), -- thisModule.methodWithSameNameAsEnclosingClass(),
...@@ -1895,6 +1895,25 @@ rule MesureShortVariableName(variable : java!VariableDeclaration) { ...@@ -1895,6 +1895,25 @@ rule MesureShortVariableName(variable : java!VariableDeclaration) {
} }
} }
--- Creates a new Measure when the method toString() is unnecessarily invoked.
rule MeasureStringToString(method : java!MethodInvocation) {
to
om: smm!ObservedMeasure (
measure <- noc,
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'StringToString',
shortDescription <- 'Avoid calling toString() on objects already known to be string instances; this is unnecessary.'
),
measurement: smm!DirectMeasurement (
error <- 'The Object ' + method.expression.variable.name + ' is already a String in ' + method.originalCompilationUnit.name
)
do {
noc;
}
}
--- A Measure instance if the class violates the rule 'TooManyFields'. --- A Measure instance if the class violates the rule 'TooManyFields'.
-- #FIXME: Typo -- #FIXME: Typo
rule MesureTooManyFields(class : java!ClassDeclaration) { rule MesureTooManyFields(class : java!ClassDeclaration) {
...@@ -2083,8 +2102,4 @@ helper context java!FieldDeclaration def: getBodyDeclarationName() : String = ...@@ -2083,8 +2102,4 @@ helper context java!FieldDeclaration def: getBodyDeclarationName() : String =
-- ATTENTION !!! -- ATTENTION !!!
-- Before adding a new rule in the end of the file, remember that rules respect an alphabetical order. -- Before adding a new rule in the end of the file, remember that rules respect an alphabetical order.
\ No newline at end of file
This diff is collapsed.
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