Commit 105ccab0 authored by Romain F. T's avatar Romain F. T
Browse files

aesthetic considerations

parent aa9b8167
-- @nsURI smm=http://www.eclipse.org/MoDisco/SMM/1.0.Beta2/smm
-- @nsURI java=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
module analysis;
create OUT: smm from IN: java;
......@@ -13,7 +12,6 @@ uses bestPractices;
uses documentation;
uses errorProne;
rule Java2SMM {
from
project: java!Model
......@@ -152,22 +150,22 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
thisModule.UnconditionalIfStatement(),
thisModule.useEqualsToCompareString(),
thisModule.UseProperClassLoader(),
-- Best practices rules
-- #FIXME: thisModule.arrayIsStoredDirectly(),
thisModule.avoidReassigningParameters(),
thisModule.avoidStringBufferField(),
thisModule.forLoopVariableCount(),
thisModule.JUnitTestsShouldIncludeAssert(),
thisModule.JUnitTestContainsTooManyAsserts(1) -- TODO il s'agit d'une
thisModule.JUnitTestContainsTooManyAsserts(1), -- TODO il s'agit d'une
-- règle paramétrée, je ne sais pas du tout où l'utilisateur indiquerait
-- sa préférence donc en attendant je mets 1 (valeur par défaut).
thisModule.oneDeclarationPerLine(),
thisModule.switchDensity(),
-- #FIXME: thisModule.unusedLocalVariable(),
thisModule.useAssertSameInsteadOfAssertTrue(),
thisModule.useAssertTrueInsteadOfAssertEquals(),
thisModule.useAssertTrueInsteadOfAssertEquals()
-- Bugged rules:
--
-- thisModule.UseArrayListInsteadOfVector(),
......@@ -206,7 +204,7 @@ rule MeasureMissingBreakInSwitch(ss: java!SwitchStatement) {
}
}
-- ------------------------------------------- AbstractClassWithoutAnyMethod ---------------------------------------------
-- ------------------ AbstractClassWithoutAnyMethod ----------------------------
--- creates a new Measure when an abstract class does not provides any methods.
rule MeasureAbstractClassWithoutAnyMethod(i : java!ClassDeclaration) {
to
......@@ -226,7 +224,7 @@ rule MeasureAbstractClassWithoutAnyMethod(i : java!ClassDeclaration) {
}
}
-- ------------------------------------------- ArrayIsStoredDirectly ---------------------------------------------
-- ------------------------------------- ArrayIsStoredDirectly ---------------------------------------
--- creates a measure when an array parameter of a method is directly used as a reference instead of storing it first
rule MeasureArrayIsStoredDirectly(s: java!MethodDeclaration){
to
......@@ -246,7 +244,7 @@ rule MeasureArrayIsStoredDirectly(s: java!MethodDeclaration){
}
}
-- ------------------------------------------- AvoidCallingFinalize ---------------------------------------------
-- ------------------------------------- AvoidCallingFinalize ---------------------------------------
--- A Measure instance if the class violates the rule LongVariable.
rule MeasureAvoidCallingFinalize(methode : java!MethodInvocation) {
to
......@@ -283,11 +281,11 @@ rule MeasureAvoidCatchingNPE(w: java!CatchClause) {
original error, causing other, more subtle problems later on.'
)
do {
noc;
noc;
}
}
-- -----------------------------------------AvoidCatchingThrowable----------------------------------------------
-- -----------------------------------------AvoidCatchingThrowable----------------------------------------
--- A Measure instance if the class violate the rule MisLeadingVariableName
rule MeasureAvoidCatchingThrowable(catch :java!CatchClause) {
to
......@@ -326,7 +324,7 @@ rule MeasureAvoidEnumAsIdentifier(w: java!VariableDeclaration) {
}
}
-- ---------------------------------------- AvoidInstantiatingObjectInLoops -------------------------------------------
-- ---------------------------------------- AvoidInstantiatingObjectInLoops -------------------------------------
--- creates a measure when an object is instantiated in a loop
rule MeasureAvoidInstantiatingObjectInLoops(s: java!Statement){
to
......@@ -346,7 +344,7 @@ rule MeasureAvoidInstantiatingObjectInLoops(s: java!Statement){
}
}
-- ----------------------------------------- AvoidPrefixingMethodParameters----------------------------------------------
-- ----------------------------------------- AvoidPrefixingMethodParameters----------------------------------------
--- A Measure instance if the class violates the rule AvoidPrefixingMethodParameters.
rule MeasureAvoidPrefixingMethodParameters(method: java!MethodDeclaration) {
to
......@@ -358,11 +356,11 @@ rule MeasureAvoidPrefixingMethodParameters(method: java!MethodDeclaration) {
name <- 'AvoidPrefixingMethodParameters',
shortDescription <- 'Prefixing parameters by ‘in’ or ‘out’ pollutes the name of the parameters and reduces code readability.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<- 'Bad parameters : ' + method.getIncorrectParameters() + ', for the method ' + method.name + ' defined in the file ' + method.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -377,15 +375,15 @@ rule MeasureAvoidPrintStackTrace(method : java!MethodInvocation) {
name <- 'Avoid print stack trace',
shortDescription <- 'Avoid printStackTrace(); use a logger call instead.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<- 'The class '+ method.originalCompilationUnit.name + ' violates the rule avoid print stack trace.'
)
do {
noc;
noc;
}
}
-- ----------------------------------------- AvoidReassigningParameters ----------------------------------------------
-- ----------------------------------------- AvoidReassigningParameters ----------------------------------------
--- A Measure instance if the class violates the rule AvoidReassigningParameters.
rule MeasureAvoidReassigningParameters(assignment: java!SingleVariableAccess) {
to
......@@ -397,15 +395,15 @@ rule MeasureAvoidReassigningParameters(assignment: java!SingleVariableAccess) {
name <- 'AvoidReassigningParameters',
shortDescription <- 'Reassigning values to incoming parameters is not recommended. Use temporary local variables instead.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<- assignment.leftHandSide.variable.name + ' should not be reassigned'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- AvoidRethrowingException ---------------------------------------------
-- ------------------------------------- AvoidRethrowingException ---------------------------------------
---A Measure instance if the class violates the rule AvoidRethrowingException.
rule MeasureAvoidRethrowingException(statement : java!TryStatement) {
to
......@@ -414,20 +412,20 @@ rule MeasureAvoidRethrowingException(statement : java!TryStatement) {
measurements <- measurement
),
noc: smm!DimensionalMeasure (
name <- 'AvoidRethrowingException ',
shortDescription <- 'Avoid merely rethrowing an exception.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ statement.originalCompilationUnit.name + ' an exception was caught and merely rethrown.'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- AvoidStringBufferField ---------------------------------------------
-- ------------------------------------- AvoidStringBufferField ---------------------------------------
--- A Measure instance if the class violates AvoidStringBufferField .
rule MeasureAvoidStringBufferField(declaration : java!FieldDeclaration) {
to
......@@ -443,7 +441,7 @@ rule MeasureAvoidStringBufferField(declaration : java!FieldDeclaration) {
error <- 'AvoidStringBufferField is detected in ' + declaration.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -458,12 +456,12 @@ rule measureAvoidThreadGroup(variable : java!VariableDeclarationStatement) {
name <- 'Avoid Thread Group',
shortDescription <- 'Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread-safe.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'The class '+ variable.originalCompilationUnit.name + ' violates the rule avoid thread group.'
)
do {
noc;
noc;
}
}
......@@ -479,7 +477,7 @@ rule MeasureAvoidThrowingNewInstanceOfSameException(catch : java!CatchClause) {
name <- 'AvoidThrowingNewInstanceOfSameException',
shortDescription <- 'Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same type only add to code size and runtime complexity.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error <-'The class '+ catch.originalCompilationUnit.name + ' has a method that rethrows a caught exception wrapped inside a new instance of the same type.'
)
do {
......@@ -503,7 +501,7 @@ rule MeasureAvoidThrowingNullPointerException(c : java!ClassInstanceCreation) {
error <- 'AvoidThrowingNullPointerException is detected in ' + c.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -530,7 +528,7 @@ rule MeasureAvoidUsingShortType(typeShort : java!VariableDeclarationStatement) {
}
}
-- ---------------------------------------- AvoidUsingNativeCode -------------------------------------------------------
-- ---------------------------------------- AvoidUsingNativeCode -------------------------------------
---creates a new Measure when a Java Native Interface (JNI) calls unecessary reliance(s).
rule MeasureAvoidUsingNativeCode(classDeclaration : java!ClassDeclaration) {
......@@ -543,15 +541,15 @@ rule MeasureAvoidUsingNativeCode(classDeclaration : java!ClassDeclaration) {
name <- 'AvoidUsingNativeCode',
shortDescription <- 'Unnecessary reliance on Java Native Interface (JNI) calls directly reduces application portability and increases the maintenance burden.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<- 'The method '+ classDeclaration.method.name + ' violates the rule AvoidUsingNativeCode.'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- BigIntegerInstantiation ---------------------------------------------
-- ------------------------------------- BigIntegerInstantiation ---------------------------------------
--- creates a Measure when a BigInteger is instantiated with a "new BigInteger()" statement.
rule MeasureBigIntegerInstantiation(variable : java!CompilationUnit) {
to
......@@ -563,16 +561,16 @@ rule MeasureBigIntegerInstantiation(variable : java!CompilationUnit) {
name <- 'BigIntegerInstantiation',
shortDescription <- 'Don’t create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and for Java 1.5 onwards, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' an instantiation of BigInteger must be BigInteger.valueOf().'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- BooleanInstantiation ---------------------------------------------
-- ------------------------------------- BooleanInstantiation ---------------------------------------
--- creates a Measure when a Boolean is instantiated with a "new Boolean()" statement.
rule MeasureBooleanInstantiation(variable : java!CompilationUnit) {
to
......@@ -584,16 +582,16 @@ rule MeasureBooleanInstantiation(variable : java!CompilationUnit) {
name <- 'BooleanInstantiation',
shortDescription <- 'Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead. Note that new Boolean() is deprecated since JDK 9 for that reason.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' an instantiation of Boolean must be Boolean.TRUE, Boolean.FALSE or Boolean.valueOf().'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- ByteInstantiation ---------------------------------------------
-- ------------------------------------- ByteInstantiation ---------------------------------------
--- creates a Measure when a Byte is instantiated with a "new Byte()" statement.
rule MeasureByteInstantiation(variable : java!CompilationUnit) {
to
......@@ -605,11 +603,11 @@ rule MeasureByteInstantiation(variable : java!CompilationUnit) {
name <- 'ByteInstantiation',
shortDescription <- 'Calling new Byte() causes memory allocation that can be avoided by the static Byte.valueOf(). It makes use of an internal cache that recycles earlier instances making it more memory efficient. Note that new Byte() is deprecated since JDK 9 for that reason.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' an instantiation of Byte must be Byte.valueOf().'
)
do {
noc;
noc;
}
}
......@@ -628,7 +626,7 @@ rule MeasureCloneMethodMustBePublic(w: java!MethodDeclaration) {
error <- ' class '+w.originalCompilationUnit.name+ ' has a clone methode witch need to be public '
)
do {
noc;
noc;
}
}
......@@ -670,7 +668,7 @@ rule MeasureCommentRequired(element: java!BodyDeclaration, violatedProperties: S
}
}
-- --------------------------------------- MeasureCompareObjectsWithEquals ---------------------------------------------
-- --------------------------------------- MeasureCompareObjectsWithEquals ---------------------------------------
--- A measure instance if the class violates the rule MeasureCompareObjectsWithEquals.
rule MeasureCompareObjectsWithEquals(expression : java!InfixExpression) {
to
......@@ -712,7 +710,7 @@ rule MeasureDoNotCallGarbageCollectionExplicitly(method : java!MethodInvocation)
}
}
-- ----------------------------------------- DoNotCallSystemExit ----------------------------------------------
-- ----------------------------------------- DoNotCallSystemExit ----------------------------------------
--- A Measure instance if the class violates the rule DoNotCallSystemExit.
rule MeasureDoNotCallSystemExit(invocation : java!MethodInvocation) {
to
......@@ -729,11 +727,11 @@ rule MeasureDoNotCallSystemExit(invocation : java!MethodInvocation) {
error<- 'Do not call ' + invocation.method.getMethodClassName() + '.' + invocation.method.name + ' in the file ' + invocation.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
-- ------------------------------------------- DoNotExtendJavaLangError ---------------------------------------------
-- ------------------------------------- DoNotExtendJavaLangError ---------------------------------------
--- A Measure instance if the class violates the rule DoNotExtendJavaLangError.
rule MeasureDoNotExtendJavaLangError(variable : java!ClassDeclaration) {
to
......@@ -746,16 +744,16 @@ rule MeasureDoNotExtendJavaLangError(variable : java!ClassDeclaration) {
shortDescription <- 'Errors are system exceptions. Do not extend them.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' Do not extend Error, Errors are system exceptions.'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- DoNotExtendJavaLangThrowable ---------------------------------------------
-- ------------------------------------- DoNotExtendJavaLangThrowable ---------------------------------------
--- A Measure instance if the class violates the rule DoNotExtendJavaLangThrowable.
rule MeasureDoNotExtendJavaLangThrowable(variable : java!ClassDeclaration) {
to
......@@ -768,12 +766,12 @@ rule MeasureDoNotExtendJavaLangThrowable(variable : java!ClassDeclaration) {
shortDescription <- 'Extend Exception or RuntimeException instead of Throwable.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' should not extend Throwable but RuntimeException or Exception .'
)
do {
noc;
noc;
}
}
......@@ -788,15 +786,15 @@ rule MeasureDontCallThreadRun(method : java!MethodDeclaration) {
name <- 'Don t call Thread.run()',
shortDescription <- 'Explicitly calling Thread.run() method will execute in the caller s thread of control. Instead, call Thread.start() for the intended behavior.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'The class '+ method.originalCompilationUnit.name + ' violates the rule don t call Thread.run().'
)
do {
noc;
noc;
}
}
-- ----------------------------------------- MeasureDontImportSun----------------------------------------------
-- ----------------------------------------- MeasureDontImportSun----------------------------------------
--- A Measure instance if the class violate the rule DontImportSun
rule MeasureDontImportSun(p : java!CompilationUnit) {
to
......@@ -812,7 +810,7 @@ rule MeasureDontImportSun(p : java!CompilationUnit) {
error <- ' Import Sun. , is detected in '+ p -> collect(i | i.name)
)
do {
noc;
noc;
}
}
......@@ -836,7 +834,7 @@ rule MeasureDontUseFloatTypeForLoopIndices(){
}
-- ----------------------------------------- DuplicateImport ----------------------------------------------
-- ----------------------------------------- DuplicateImport ----------------------------------------
-- Create a new Measure when an import is duplicated in a class.
rule MeasureDuplicateImport(import : java!ImportDeclaration) {
to
......@@ -852,11 +850,11 @@ rule MeasureDuplicateImport(import : java!ImportDeclaration) {
error <- 'In the Class ' + import.importedElement.name + ' there are duplicated imports.'
)
do {
noc;
noc;
}
}
-- -----------------------------------------EmptyCatchBlock----------------------------------------------
-- -----------------------------------------EmptyCatchBlock----------------------------------------
--- A Measure instance if the class violate the rule EmptyCatchBlock
rule MeasureEmptyCatchBlock(catch : java!CatchClause) {
to
......@@ -892,7 +890,7 @@ rule MeasureEmptyFinalizer(finalizeMethod : java!MethodDeclaration) {
error <- 'EmptyFinalizer is detected in ' + finalizeMethod.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -912,7 +910,7 @@ rule MeasureEmptyFinallyBlock(finallyBlock : java!TryStatement) {
error <- 'EmptyFinallyBlock is detected in ' + finallyBlock.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -931,7 +929,7 @@ rule MeasureEmptyInitializer(w: java!Initializer) {
error <- ' class '+w.originalCompilationUnit.name +' hase an empty Initializer! do not declare an EmptyInitializer, EmptyInitializer! this block need to be deleted'
)
do {
noc;
noc;
}
}
......@@ -955,7 +953,7 @@ rule MeasureEmptyStatementBlock(block : java!Block) {
}
}
-- ---------------------EmptySwitchStatement---------------------------------------------
-- ---------------------EmptySwitchStatement---------------------------------------
--- A Measure instance if the class violates the rule 'EmptySwitchStatement'
rule MeasureEmptySwitchStatement(switchStatement: java!SwitchStatement) {
to
......@@ -975,7 +973,7 @@ rule MeasureEmptySwitchStatement(switchStatement: java!SwitchStatement) {
}
}
-- ------------------------------EmptySynchronizedBlock---------------------------------------------
-- ------------------------------EmptySynchronizedBlock---------------------------------------
--- A Measure instance if the class violates the rule 'EmptySynchronizedBlock'
rule MeasureEmptySynchronizedBlock(synchronizedBlock: java!SynchronizedStatement) {
to
......@@ -1011,7 +1009,7 @@ rule MeasureEmptyTryBlock(t : java!TryStatement) {
error <- 'EmptyTryBlock is detected in ' + t.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -1031,7 +1029,7 @@ rule MeasureEmptyWhileStmt(w : java!WhileStatement) {
error <- 'EmptyWhileStmt is detected in ' + w.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
......@@ -1050,11 +1048,11 @@ rule MeasureExcessiveClassLength(w: java!MethodDeclaration) {
error <- ' class '+w.originalCompilationUnit.name+ ' has a block with more than 1000 line of code per a method it may need a separation in the code'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- ExcessiveImports ---------------------------------------------
-- ------------------------------------- ExcessiveImports ---------------------------------------
--- creates a new Measure when a class has more than 4 imports
rule MeasureExcessiveImports(i : java!CompilationUnit) {
to
......@@ -1066,16 +1064,16 @@ rule MeasureExcessiveImports(i : java!CompilationUnit) {
name <- 'ExcessiveImports',
shortDescription <- 'A high number of imports can indicate a high degree of coupling within an object. This rule counts the number of unique imports and reports a violation if the count is above the user-specified threshold.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'The class '+ i.name + ' has an excessive imports.',
value<- i.imports.size()
)
do {
noc;
noc;
}
}
-- ------------------------------------------ ExcessiveMethodLength ---------------------------------------------
-- ------------------------------------------ ExcessiveMethodLength ---------------------------------------
--- creates a new Measure when a class has more than 4 imports
rule MeasureExcessiveMethodLength(block : java!Block) {
to
......@@ -1096,7 +1094,7 @@ rule MeasureExcessiveMethodLength(block : java!Block) {
}
}
-- ------------------------------------------- MeasureExtendsObject ---------------------------------------------
-- ------------------------------------- MeasureExtendsObject ---------------------------------------
--- A Measure instance if the class violates the rule ExtendsObject.
rule MeasureExtendsObject(variable : java!ClassDeclaration) {
to
......@@ -1109,16 +1107,16 @@ rule MeasureExtendsObject(variable : java!ClassDeclaration) {
shortDescription <- 'No need to explicitly extend Object.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'In the Class '+ variable.name + ' No need to explicitly extend Object.'
)
do {
noc;
noc;
}
}
-- ----------------------------------------- FieldDeclarationsShouldBeAtStartOfClass----------------------------------------------
-- ----------------------------------------- FieldDeclarationsShouldBeAtStartOfClass----------------------------------------
--- A Measure instance if the class violates the rule FieldDeclarationsShouldBeAtStartOfClass.
rule MeasureFieldDeclarationsShouldBeAtStartOfClass(class: java!ClassDeclaration) {
to
......@@ -1134,11 +1132,11 @@ rule MeasureFieldDeclarationsShouldBeAtStartOfClass(class: java!ClassDeclaration
error<- 'Some of the fields of the class ' + class.name + ' are not declared at the top'
)
do {
noc;
noc;
}
}
-- --------------------------------- MeasureFinalFieldCouldBeStatic ---------------------------------------------
-- --------------------------------- MeasureFinalFieldCouldBeStatic ---------------------------------------
--- A Measure instance if the class violates the rule MeasureFinalFieldCouldBeStatic.
rule MeasureFinalFieldCouldBeStatic(field : java!FieldDeclaration) {
to
......@@ -1151,16 +1149,16 @@ rule MeasureFinalFieldCouldBeStatic(field : java!FieldDeclaration) {
shortDescription <- 'If a final field is assigned to a compile-time constant, it could be made static, thus saving overhead in each object at runtime.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'The field '+ field.fragments->collect(i | i.name)->first() + ' could be static in the class ' + field.originalCompilationUnit.name +'.'
)
do {
noc;
noc;
}
}
-- ----------------------------------------- ForLoopVariableCount ----------------------------------------------
-- ----------------------------------------- ForLoopVariableCount ----------------------------------------
--- A Measure instance if the class violates the rule ForLoopVariableCount.
rule MeasureForLoopVariableCount(forStatement: java!ForStatement) {
to
......@@ -1173,15 +1171,15 @@ rule MeasureForLoopVariableCount(forStatement: java!ForStatement) {
shortDescription <- 'Having a lot of control variables in a "for" loop makes it harder to see what range of values the loop iterates over.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<- 'A "for" loop use more than one local variable in the file ' + forStatement.originalCompilationUnit.name
)
do {
noc;
noc;
}
}
-- ---------------------------------------- GenericsNaming ---------------------------------------------
-- ---------------------------------------- GenericsNaming ---------------------------------------
--- A Measure instance if the class violate the rule GenericsNaming
rule MeasureGenericsNaming(type :java!TypeParameter) {
to
......@@ -1201,7 +1199,7 @@ rule MeasureGenericsNaming(type :java!TypeParameter) {
}
}
--------------------------------------------- IfElseStmtsMustUseBraces ---------------------------------------------
--------------------------------------- IfElseStmtsMustUseBraces ---------------------------------------
--- Evaluates wether a method contain an if/else statement without braces.
rule MeasureIfElseStmtsMustUseBraces(condition : java!IfStatement) {
to
......@@ -1221,7 +1219,7 @@ rule MeasureIfElseStmtsMustUseBraces(condition : java!IfStatement) {
}
}
-- ------------------------------------------- IfStmtsMustUseBraces ---------------------------------------------
-- ------------------------------------- IfStmtsMustUseBraces ---------------------------------------
--- creates a new Measure when a class that contains an if statement without braces.
rule MeasureIfStmtsMustUseBraces(i : java!IfStatement) {
to
......@@ -1233,15 +1231,15 @@ rule MeasureIfStmtsMustUseBraces(i : java!IfStatement) {
name <- 'If then Statement must use braces',
shortDescription <- 'Deprecated Avoid using if statements without using braces to surround the code block. If the code formatting...'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error <- 'The class ' + i.originalCompilationUnit.name + ' has an if statement without braces. '
)
do {
noc;
noc;
}
}
-- -----------------------------------------ImportFromSamePackage----------------------------------------------
-- -----------------------------------------ImportFromSamePackage----------------------------------------
--- A Measure instance if the class violate the rule ImportFromSamePackage
rule MeasureImportFromSamePackage(import : java!ImportDeclaration) {
to
......@@ -1261,7 +1259,7 @@ rule MeasureImportFromSamePackage(import : java!ImportDeclaration) {
}
}
-- ----------------------------------------- InefficientEmptyStringCheck ----------------------------------------------
-- ----------------------------------------- InefficientEmptyStringCheck ----------------------------------------
--- creates a measure when String.trim().isEmpty() is used to check if a string is empty
rule MeasureInefficientEmptyStringCheck(mi: java!Expression){
to
......@@ -1297,11 +1295,11 @@ rule MeasureInsufficientStringBufferDeclaration(w: java!CompilationUnit) {
error <- ' class'+ w.name+ 'has insufficientStringBufferDeclaration'
)
do {
noc;
noc;
}
}
-- ------------------------------------------- IntegerInstantiation ---------------------------------------------
-- ------------------------------------- IntegerInstantiation ---------------------------------------
--- A Measure instance if the class violates the rule 'IntegerInstantiation'.
rule MeasureIntegerInstantiation(variable : java!CompilationUnit) {
to
......@@ -1318,11 +1316,11 @@ rule MeasureIntegerInstantiation(variable : java!CompilationUnit) {
)
do {
noc;
noc;
}
}
-- ------------------------------------------- JUnitSpelling ---------------------------------------------
-- ------------------------------------- JUnitSpelling ---------------------------------------
--- return a Measure for if "tearDown" or "setUp" arent spelled with a capital D and U and the rest is in lower case
rule MeasureJUnitSpelling(i : java!MethodDeclaration) {
to
......@@ -1334,12 +1332,12 @@ rule MeasureJUnitSpelling(i : java!MethodDeclaration) {
name <- 'JUnitSpelling',
shortDescription <- 'Some JUnit framework methods are easy to misspell.'
),
measurement: smm!DirectMeasurement (
measurement: smm!DirectMeasurement (
error<-'The method Junit ' + i.name + ' is not spelled correctly.',
name<- i.name + ' is not spelled correctly'
)
do {
noc;
noc;
}