Commit d909aaff authored by Gerson SUNYE's avatar Gerson SUNYE
Browse files

Merge branch 'fix/correction_string_tostring' into 'master'

Correction #904 String toString

Closes #904

See merge request !159
parents 2d3a3528 a872a2f2
......@@ -91,6 +91,7 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.integerInstantiation(),
-- #FIXME:
-- thisModule.startsWith(),
thisModule.stringToString(),
thisModule.tooFewBranchesForASwitchStatement(),
-- #FIXME: thisModule.useArraysAsList(),
thisModule.useIndexOfChar(),
......@@ -152,7 +153,6 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
-- thisModule.replaceVectorToList()
-- thisModule.unusedPrivateMethod ()
-- thisModule.avoidThrowingNewInstanceOfSameException(),
-- thisModule.stringToString(),
-- thisModule.methodWithSameNameAsEnclosingClass(),
-- thisModule.dontUseFloatTypeForLoopIndices(),
-- thisModule.methodWithSameNameAsEnclosingClass(),
......@@ -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'.
-- #FIXME: Typo
rule MesureTooManyFields(class : java!ClassDeclaration) {
......@@ -2083,8 +2102,4 @@ helper context java!FieldDeclaration def: getBodyDeclarationName() : String =
-- 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