diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bcbb524 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: java + +sudo: false +install: true + +jdk: + - oraclejdk8 + +cache: + directories: + - '$HOME/.m2/repository' + - '$HOME/.sonar/cache' + - '$HOME/.sonar/installs' + +addons: + sonarqube: true + +notifications: + email: false + +addons: + sonarcloud: + organization: "lequal" + token: + secure: projettest # encrypted value of your token +# Script to execute. + +script: + - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=lequal -Dsonar.login=181e22946e5e05302ceb4513dae3dcc9f7161f2f diff --git a/pom.xml b/pom.xml index 4556ccb..a5f9187 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ fr.cnes.sonarqube.plugins sonaricode sonar-plugin - 1.0.1 + 1.0.2 Sonar i-Code CNES plugin i-Code CNES plugin for SonarQube diff --git a/src/main/java/fr/cnes/sonar/plugins/icode/measures/ICodeNestingMetric.java b/src/main/java/fr/cnes/sonar/plugins/icode/measures/ICodeNestingMetric.java index e2effef..6e5101b 100644 --- a/src/main/java/fr/cnes/sonar/plugins/icode/measures/ICodeNestingMetric.java +++ b/src/main/java/fr/cnes/sonar/plugins/icode/measures/ICodeNestingMetric.java @@ -33,7 +33,7 @@ public class ICodeNestingMetric implements Metrics, MeasureComputer { /** Name of the category in which defined metrics should be displayed **/ - public static final String DOMAIN = "i-Code"; + public static final String DOMAIN = "Size"; /** Key of the nesting metric. **/ public static final String KEY = "icode-nesting-max"; diff --git a/src/main/resources/rules/icode-f77-rules.xml b/src/main/resources/rules/icode-f77-rules.xml index 0f6b8d7..4e9cc60 100644 --- a/src/main/resources/rules/icode-f77-rules.xml +++ b/src/main/resources/rules/icode-f77-rules.xml @@ -4,12 +4,11 @@ COM.DATA.FloatCompare COM.DATA.FloatCompare * - Unreferenced rule + Equality and non equality (.EQ., ==, .NE., /=) are forbidden on reals (REAL, DOUBLE PRECISION, COMPLEX). MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -17,12 +16,11 @@ COM.DATA.Initialisation COM.DATA.Initialisation * - Unreferenced rule + Variables have to be initialized before being used. When a variable is used, the algorithm should checked if it is initialized and if not throw an error. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -30,12 +28,11 @@ COM.DATA.Invariant COM.DATA.Invariant * - Unreferenced rule + Data declared into subroutine, function, ... and which are never modified then should be declared as constant. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -43,12 +40,11 @@ COM.DATA.LoopCondition COM.DATA.LoopCondition * - Unreferenced rule + It is forbidden to modify loop condition inside the loop. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -56,12 +52,11 @@ COM.DATA.NotUsed COM.DATA.NotUsed * - Unreferenced rule + Every declared variable should be used. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -69,12 +64,11 @@ COM.DESIGN.Alloc COM.DESIGN.Alloc * - Unreferenced rule + Allocation and desallocation of ressources should be in the same level. For each “DEALLOCATE” keyword found, i-Code CNES checks that the keyword “ALLOCATE” is also found and checks that they are relative to the same resource. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -82,12 +76,11 @@ COM.DESIGN.ActiveWait COM.DESIGN.ActiveWait * - Unreferenced rule + In a loop, SLEEP, WAIT and PAUSE instructions are forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -95,12 +88,11 @@ COM.FLOW.Abort COM.FLOW.Abort * - Unreferenced rule + Keyword STOP is forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -108,12 +100,11 @@ COM.FLOW.BooleanExpression COM.FLOW.BooleanExpression * - Unreferenced rule + In a condition (IF,DO), maximum number of operands is 5 (AND, OR, NEQV, XOR, EQV, NOT, LT, <, LE, <=, GT, >, GE, >=, EQ, ==, NE, /=). MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -121,12 +112,11 @@ COM.FLOW.CheckCodeReturn COM.FLOW.CheckCodeReturn * - Unreferenced rule + Function return values should be checked. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -134,12 +124,11 @@ COM.FLOW.CheckUser COM.FLOW.CheckUser * - Unreferenced rule + The identity of the user running the program should be checked. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -147,12 +136,11 @@ COM.FLOW.Exit COM.FLOW.Exit * - Unreferenced rule + Function, procedure and method should have a unique exit point. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -160,12 +148,11 @@ COM.FLOW.ExitLoop COM.FLOW.ExitLoop * - Unreferenced rule + Function, procedure and method should have a unique exit point. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -173,12 +160,11 @@ COM.FLOW.FileExistence COM.FLOW.FileExistence * - Unreferenced rule + File opening (OPEN, READ, WRITE) should be done after using INQUIRE and EXIST instruction of this file. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -186,12 +172,11 @@ COM.FLOW.FilePath COM.FLOW.FilePath * - Unreferenced rule + In the OPEN instruction, it is forbidden to use directly the file name (file.txt). Path should be defined through a variable. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -199,12 +184,13 @@ COM.INST.BoolNegation COM.INST.BoolNegation * - Unreferenced rule + Double negation is forbidden on Boolean expressions. Negations are defined with the keyword « NOT ». Following expressions are not allowed: + NOT. (.NOT. a) -> ( a ) + .NOT. ( a .AND. .NOT. b) -> .NOT. a .OR. b MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -212,12 +198,11 @@ COM.INST.Brace COM.INST.Brace * - Unreferenced rule + Every expression should be braced. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -225,12 +210,11 @@ COM.INST.CodeComment COM.INST.CodeComment * - Unreferenced rule + Commented code is forbidden. i-Code CNES checks all keywords in comments, except in the header. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -238,12 +222,11 @@ COM.INST.GoTo COM.INST.GoTo * - Unreferenced rule + "GO TO" is forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -251,12 +234,11 @@ COM.INST.LoopCondition COM.INST.LoopCondition * - Unreferenced rule + In a loop instruction, comparison using (.EQ., ==, .NE., \=) are forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -264,12 +246,11 @@ COM.NAME.Homonymy COM.NAME.Homonymy * - Unreferenced rule + Variable name should be unique. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -277,12 +258,11 @@ COM.PROJECT.Header COM.PROJECT.Header * - Unreferenced rule + Headers are mandatory for each module and function. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -290,12 +270,19 @@ COM.PRES.Indent COM.PRES.Indent * - Unreferenced rule + Source code should be indented with spaces: + DO i = 2, nb + somme = somme + x(i) + IF (isnan(somme)) THEN + print *, 'somme is a NaN' + moy = -1.0 + END IF + END DO + MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -303,12 +290,11 @@ COM.PRES.LengthLine COM.PRES.LengthLine * - Unreferenced rule + A line of source code should contain 100 characters maximum. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -316,12 +302,11 @@ COM.TYPE.Expression COM.TYPE.Expression * - Unreferenced rule + In a expression (defined by operator like +, -, /, *, **) all variables should have the same type : REAL, INTEGER, … MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -329,12 +314,11 @@ F77.BLOC.Common F77.BLOC.Common * - Unreferenced rule + White COMMON are forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -342,12 +326,11 @@ F77.BLOC.Else F77.BLOC.Else * - Unreferenced rule + In an instruction IF, the last ELSE IF should be follow by ELSE. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -355,12 +338,11 @@ F77.BLOC.Function F77.BLOC.Function * - Unreferenced rule + Parameter’s braces should be used when defining a FUNCTION whenever there is no parameter. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -368,12 +350,11 @@ F77.BLOC.Loop F77.BLOC.Loop * - Unreferenced rule + Nested DO loop should have different end instructions (one for each). MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -381,12 +362,11 @@ F77.DATA.Array F77.DATA.Array * - Unreferenced rule + Arrays dimension should be declared explicitly. The use of * is tolerated for the last one if justified with a comment. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -394,12 +374,11 @@ F77.DATA.Common F77.DATA.Common * - Unreferenced rule + INCLUDE must be used to declare COMMON in program units referencing it. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -407,12 +386,11 @@ F77.DATA.Double F77.DATA.Double * - Unreferenced rule + In a constant initialisation or in an expression evaluation, the use of (D) (as double precision is mandatory. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -420,12 +398,11 @@ F77.DATA.Initialisation F77.DATA.Initialisation * - Unreferenced rule + Variable initialisation should be done using DATA or BLOCKDATA. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -433,12 +410,11 @@ F77.DATA.IO F77.DATA.IO * - Unreferenced rule + Implicit logical units defined by * are forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -446,12 +422,11 @@ F77.DATA.LoopDO F77.DATA.LoopDO * - Unreferenced rule + DO loop condition parameter should use INTEGER. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -459,12 +434,11 @@ F77.DATA.Parameter F77.DATA.Parameter * - Unreferenced rule + The use of constants, computed values or function calls as function parameters is forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -472,12 +446,11 @@ F77.ERR.OpenRead F77.ERR.OpenRead * - Unreferenced rule + The check of return status for instructions OPEN and READ is mandatory. It is recommended to use “IOSTAT = “ to do it. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -485,12 +458,11 @@ F77.INST.Assign F77.INST.Assign * - Unreferenced rule + ASSIGN instruction is forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -498,12 +470,11 @@ F77.INST.Dimension F77.INST.Dimension * - Unreferenced rule + DIMENSION instruction is forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -511,12 +482,11 @@ F77.INST.Equivalence F77.INST.Equivalence * - Unreferenced rule + EQUIVALENCE instruction is forbidden. MAJOR SINGLE READY CODE_SMELL - value CONSTANT_ISSUE 30min @@ -524,12 +494,11 @@ F77.INST.Function F77.INST.Function * - Unreferenced rule + FUNCTION instruction should be used with an explicite type declaration, at function definition. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -537,12 +506,11 @@ F77.INST.If F77.INST.If * - Unreferenced rule + Arithmetic IF is forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -550,12 +518,11 @@ F77.INST.Include F77.INST.Include * - Unreferenced rule + If instruction INCLUDE is used, the included file should not contain executable instructions. (ASSIGN, GOTO, IF, ELSE, CONTINUE, STOP, PAUSE ; DO, READ, WRITE, PRINT, REWIND ; BACKSPACE, ENDFILE, OPEN, CLOSE, INQUIER, CALL, RETURN, END). MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -563,12 +530,11 @@ F77.INST.Pause F77.INST.Pause * - Unreferenced rule + PAUSE instruction is forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -576,12 +542,11 @@ F77.INST.Return F77.INST.Return * - Unreferenced rule + RETURN(i) instruction is forbidden in subprogram. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -589,12 +554,11 @@ F77.INST.Save F77.INST.Save * - Unreferenced rule + SAVE instruction is forbidden except for local variables with justification in a comment. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -602,12 +566,11 @@ F77.MET.Line F77.MET.Line * - Unreferenced rule + Each line should contain less than 72 characters. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -615,12 +578,11 @@ F77.NAME.GenericIntrinsic F77.NAME.GenericIntrinsic * - Unreferenced rule + The use of generic names for intrinseque functions is mandatory. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -628,12 +590,11 @@ F77.NAME.Intrinsic F77.NAME.Intrinsic * - Unreferenced rule + Intrinsic function names reuse is forbidden. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -641,12 +602,11 @@ F77.NAME.KeyWords F77.NAME.KeyWords * - Unreferenced rule + Fortran 77 keywords should not be reused for variable names. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -654,12 +614,11 @@ F77.NAME.Label F77.NAME.Label * - Unreferenced rule + Label usage is restricted to instruction FORMAT and CONTINUE. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -667,12 +626,11 @@ F77.PROTO.Declaration F77.PROTO.Declaration * - Unreferenced rule + External functions should be declared with EXTERNAL keyword. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -680,12 +638,11 @@ F77.REF.IO F77.REF.IO * - Unreferenced rule + Logical unit should be identified with symbolic name. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -693,12 +650,11 @@ F77.REF.Open F77.REF.Open * - Unreferenced rule + OPEN parameters FILE, STATUS and POSITION should be defined. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -706,12 +662,11 @@ F77.REF.Parameter F77.REF.Parameter * - Unreferenced rule + It is forbidden to set as subroutine parameter variables which are already in a COMMON bloc accessible from the subroutine and the program which calls it. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -719,12 +674,11 @@ F77.TYPE.Basic F77.TYPE.Basic * - Unreferenced rule + Only standard types (INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, CHARACTER) are allowed. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -732,12 +686,11 @@ F77.TYPE.Hollerith F77.TYPE.Hollerith * - Unreferenced rule + Data and constant of type Hollerith are forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min diff --git a/src/main/resources/rules/icode-f90-rules.xml b/src/main/resources/rules/icode-f90-rules.xml index 0619035..4a4ab5f 100644 --- a/src/main/resources/rules/icode-f90-rules.xml +++ b/src/main/resources/rules/icode-f90-rules.xml @@ -4,12 +4,11 @@ COM.DATA.FloatCompare COM.DATA.FloatCompare * - Unreferenced rule + Equality and non equality (.EQ., ==, .NE., /=) are forbidden on reals (REAL, DOUBLE PRECISION, COMPLEX). MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -17,12 +16,11 @@ COM.DATA.Initialisation COM.DATA.Initialisation * - Unreferenced rule + Variables have to be initialized before being used. When a variable is used, the algorithm should checked if it is initialized and if not throw an error. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -30,12 +28,11 @@ COM.DATA.Invariant COM.DATA.Invariant * - Unreferenced rule + Data declared into subroutine, function, ... and which are never modified then should be declared as constant. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -43,12 +40,11 @@ COM.DATA.LoopCondition COM.DATA.LoopCondition * - Unreferenced rule + It is forbidden to modify loop condition inside the loop. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -56,12 +52,11 @@ COM.DATA.NotUsed COM.DATA.NotUsed * - Unreferenced rule + Every declared variable should be used. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -69,12 +64,11 @@ COM.DESIGN.Alloc COM.DESIGN.Alloc * - Unreferenced rule + Allocation and deallocation of ressources should be in the same level. For each “DEALLOCATE” keyword found, i-Code CNES checks that the keyword “ALLOCATE” is also found and checks that they are relative to the same resource. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -82,12 +76,11 @@ COM.DESIGN.ActiveWait COM.DESIGN.ActiveWait * - Unreferenced rule + In a loop, SLEEP, WAIT and PAUSE instructions are forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -95,12 +88,11 @@ COM.FLOW.Abort COM.FLOW.Abort * - Unreferenced rule + Keyword STOP is forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -108,12 +100,11 @@ COM.FLOW.BooleanExpression COM.FLOW.BooleanExpression * - Unreferenced rule + In a condition (IF,DO), maximum number of operands is 5 (AND, OR, NEQV, XOR, EQV, NOT, LT, <, LE, <=, GT, >, GE, >=, EQ, ==, NE, /=). MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -121,12 +112,11 @@ COM.FLOW.CheckCodeReturn COM.FLOW.CheckCodeReturn * - Unreferenced rule + Function return values should be checked. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -134,12 +124,11 @@ COM.FLOW.CheckUser COM.FLOW.CheckUser * - Unreferenced rule + The identity of the user running the program should be checked. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -147,12 +136,11 @@ COM.FLOW.Exit COM.FLOW.Exit * - Unreferenced rule + Function, procedure and method should have a unique exit point. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -160,12 +148,11 @@ COM.FLOW.ExitLoop COM.FLOW.ExitLoop * - Unreferenced rule + Function, procedure and method should have a unique exit point. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -173,12 +160,11 @@ COM.FLOW.FileExistence COM.FLOW.FileExistence * - Unreferenced rule + File opening (OPEN, READ, WRITE) should be done after using INQUIRE and EXIST instruction of this file. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -186,12 +172,11 @@ COM.FLOW.FilePath COM.FLOW.FilePath * - Unreferenced rule + In the OPEN instruction, it is forbidden to use directly the file name (file.txt). Path should be defined through a variable. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -199,12 +184,13 @@ COM.INST.BoolNegation COM.INST.BoolNegation * - Unreferenced rule + Double negation is forbidden on Boolean expressions. Negations are defined with the keyword « NOT ». Following expressions are not allowed: + NOT. (.NOT. a) -> ( a ) + .NOT. ( a .AND. .NOT. b) -> .NOT. a .OR. b MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -212,12 +198,11 @@ COM.INST.Brace COM.INST.Brace * - Unreferenced rule + Every expression should be braced. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -225,12 +210,11 @@ COM.INST.CodeComment COM.INST.CodeComment * - Unreferenced rule + Commented code is forbidden. i-Code CNES checks all keywords in comments, except in the header. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -238,12 +222,11 @@ COM.INST.GoTo COM.INST.GoTo * - Unreferenced rule + "GO TO" is forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -251,12 +234,11 @@ COM.INST.LoopCondition COM.INST.LoopCondition * - Unreferenced rule + In a loop instruction, comparison using (.EQ., ==, .NE., \=) are forbidden. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -264,12 +246,11 @@ COM.NAME.Homonymy COM.NAME.Homonymy * - Unreferenced rule + Variable name should be unique. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -277,12 +258,11 @@ COM.PROJECT.Header COM.PROJECT.Header * - Unreferenced rule + Headers are mandatory for each module and function. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -290,12 +270,19 @@ COM.PRES.Indent COM.PRES.Indent * - Unreferenced rule + Source code should be indented with spaces: + DO i = 2, nb + somme = somme + x(i) + IF (isnan(somme)) THEN + print *, 'somme is a NaN' + moy = -1.0 + END IF + END DO + MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -303,12 +290,11 @@ COM.PRES.LengthLine COM.PRES.LengthLine * - Unreferenced rule + A line of source code should contain 100 characters maximum. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -316,12 +302,11 @@ COM.TYPE.Expression COM.TYPE.Expression * - Unreferenced rule + In a expression (defined by operator like +, -, /, *, **) all variables should have the same type : REAL, INTEGER, … MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -329,12 +314,11 @@ COM.FLOW.CaseSwitch COM.FLOW.CaseSwitch * - Unreferenced rule + SWITCH instruction should define the DEFAULT case as last one. MAJOR SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -342,12 +326,11 @@ COM.INST.Line COM.INST.Line * - Unreferenced rule + Each line should be limited to only one expression. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -355,12 +338,11 @@ COM.FLOW.Recursion COM.FLOW.Recursion * - Unreferenced rule + Recursion is forbidden. In Fortran, i-Code CNES checks that "RECURSIVE FUNCTION(params)" is not found. MAJOR SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -368,12 +350,11 @@ F90.BLOC.File F90.BLOC.File * - Unreferenced rule + Every open file should be closed. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -381,12 +362,11 @@ F90.DATA.Array F90.DATA.Array * - Unreferenced rule + Array dimensions should be respected. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -394,12 +374,11 @@ F90.DATA.ArrayAccess F90.DATA.ArrayAccess * - Unreferenced rule + In an array of indirections, it is not possible to define the same item several times. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -407,12 +386,11 @@ F90.DATA.Constant F90.DATA.Constant * - Unreferenced rule + Constants which appear in several subprograms should be defined into a module. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -420,12 +398,11 @@ F90.DATA.ConstantFloat F90.DATA.ConstantFloat * - Unreferenced rule + Numerical constants (see above) should be followed by subtype parameter. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -433,12 +410,12 @@ F90.DATA.Declaration F90.DATA.Declaration * - Unreferenced rule + The use of IMPLICIT NONE instruction is mandatory for each method header. + Limitations : this rule is not checked for function and array. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -446,12 +423,11 @@ F90.DATA.Float F90.DATA.Float * - Unreferenced rule + It is forbidden to use * output format (WRITE instruction) for REAL. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -459,12 +435,11 @@ F90.DATA.Parameter F90.DATA.Parameter * - Unreferenced rule + Functions SELECTED_REAL_KIND and SELECTED_INT_KIND should be grouped in the same module. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -472,12 +447,11 @@ F90.DESIGN.Free F90.DESIGN.Free * - Unreferenced rule + Allocated memory should be free in the same conceptual level. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -485,12 +459,11 @@ F90.DESIGN.Include F90.DESIGN.Include * - Unreferenced rule + File inclusion is forbidden. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -498,12 +471,11 @@ F90.DESIGN.Interface F90.DESIGN.Interface * - Unreferenced rule + Modules should only contains USE, PRIVATE and PUBLIC clauses. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -511,12 +483,11 @@ F90.DESIGN.IO F90.DESIGN.IO * - Unreferenced rule + In an OPEN function, units number should depend on another function or array. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -524,12 +495,21 @@ F90.DESIGN.Obsolete F90.DESIGN.Obsolete * - Unreferenced rule + This rule checks the following points: + - Do not use computed GO TO + - Do not use syntaxe: CHARACTER*N + - Do not use arithmetic IF + - In a DO loop, do not use REAL variables, neither as indice, nor as interval limits, nor as increment step + - Do not exit a DO loop with other than END DO or CONTINUE + - Do not branch on ENDIF + - Do not use PAUSE + - Do not use assigned GOTO + - Do not use FORMAT label + - Do not use descriptor H (Hollerith) in formats MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -537,12 +517,11 @@ F90.ERR.Allocate F90.ERR.Allocate * - Unreferenced rule + Allocation and deallocation should contain “STAT” parameter. Then, « STAT » value should be tested. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -550,12 +529,11 @@ F90.ERR.OpenRead F90.ERR.OpenRead * - Unreferenced rule + OPEN and READ instructions, which work on files, should contain IOSTAT parameter and check this variable value. To check this, OPEN instruction should contain FILE attribute. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -563,12 +541,11 @@ F90.INST.Associated F90.INST.Associated * - Unreferenced rule + Between declaration and ASSOCIATED instruction, it is mandatory to call NULLIFY. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -576,12 +553,11 @@ F90.INST.Entry F90.INST.Entry * - Unreferenced rule + ENTRY instruction is forbidden. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -589,12 +565,11 @@ F90.INST.Equivalence F90.INST.Equivalence * - Unreferenced rule + EQUIVALENCE instruction is forbidden. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -602,12 +577,11 @@ F90.INST.If F90.INST.If * - Unreferenced rule + IF followed by one of these instructions : EXIT, GOTO, CYCLE, RETURN is forbidden. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -615,12 +589,11 @@ F90.INST.Intent F90.INST.Intent * - Unreferenced rule + Each subprogram parameter should be declared with INTENT keyword. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -628,12 +601,11 @@ F90.INST.Nullify F90.INST.Nullify * - Unreferenced rule + After deallocate, the use of NULLIFY into the same logical unit is mandatory. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -641,12 +613,11 @@ F90.INST.Only F90.INST.Only * - Unreferenced rule + The use of keyword ONLY without comment is forbidden. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -654,12 +625,11 @@ F90.INST.Operator F90.INST.Operator * - Unreferenced rule + Do not use old notation. Replace .EQ., .NE., .LT., .LE., .GT., .GE. by ==, /=, <, <=, >, >=. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -667,12 +637,14 @@ F90.INST.Pointer F90.INST.Pointer * - Unreferenced rule + POINTER is forbidden except in those cases: + - Complex data structure creation + - Manage array references + - Dynamic allocation into components with derived types MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -680,12 +652,13 @@ F90.NAME.GenericIntrinsic F90.NAME.GenericIntrinsic * - Unreferenced rule + Do not use specific functions (see below), use generic ones: + BAD: result = AMOD (argument, divider) + GOOD: result = MOD (argument, divider) MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -693,12 +666,11 @@ F90.NAME.KeyWords F90.NAME.KeyWords * - Unreferenced rule + Fortran keywords should not be used as variable names. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -706,12 +678,11 @@ F90.PROTO.Overload F90.PROTO.Overload * - Unreferenced rule + Overriding operators is forbidden. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -719,12 +690,11 @@ F90.REF.Array F90.REF.Array * - Unreferenced rule + The use of a whole array should be represented using the notation (:). MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -732,12 +702,11 @@ F90.REF.Interface F90.REF.Interface * - Unreferenced rule + Called subprogram should be visible. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -745,12 +714,11 @@ F90.REF.Label F90.REF.Label * - Unreferenced rule + END keyword should be followed by the type (function, subroutine…) and the name. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -758,12 +726,11 @@ F90.REF.Open F90.REF.Open * - Unreferenced rule + Every OPEN instruction should have parameters FILE, STATUS, IOSTAT and POSITION. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -771,12 +738,11 @@ F90.REF.Variable F90.REF.Variable * - Unreferenced rule + A variable should be referenced with the same name in subprogram. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -784,12 +750,11 @@ F90.TYPE.Derivate F90.TYPE.Derivate * - Unreferenced rule + Every type declaration should be placed into a module. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -797,12 +762,11 @@ F90.TYPE.Integer F90.TYPE.Integer * - Unreferenced rule + INTEGER parameters should be followed by SELECTED_INT_KIND expression. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min @@ -810,12 +774,11 @@ F90.TYPE.Real F90.TYPE.Real * - Unreferenced rule + REAL parameters should be followed by SELECTED_REAL_KIND. MAJOR SINGLE READY CODE_SMELL - f90 CONSTANT_ISSUE 30min diff --git a/src/main/resources/rules/icode-shell-rules.xml b/src/main/resources/rules/icode-shell-rules.xml index b69cfc3..41512b1 100644 --- a/src/main/resources/rules/icode-shell-rules.xml +++ b/src/main/resources/rules/icode-shell-rules.xml @@ -9,7 +9,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -22,7 +21,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -35,7 +33,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -48,7 +45,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -61,7 +57,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -77,7 +72,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -90,7 +84,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -103,7 +96,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -116,7 +108,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -129,7 +120,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -142,7 +132,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -155,7 +144,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -168,7 +156,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -181,7 +168,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -194,7 +180,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -207,7 +192,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -220,7 +204,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -233,7 +216,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -246,7 +228,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -259,7 +240,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -272,7 +252,6 @@ SINGLE READY CODE_SMELL - shell CONSTANT_ISSUE 30min @@ -285,7 +264,6 @@ SINGLE READY CODE_SMELL - value CONSTANT_ISSUE 30min @@ -298,7 +276,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -312,7 +289,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -325,7 +301,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -339,7 +314,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -352,7 +326,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -365,7 +338,6 @@ SINGLE READY CODE_SMELL - f77 CONSTANT_ISSUE 30min @@ -378,7 +350,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -394,7 +365,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -408,7 +378,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -422,7 +391,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min @@ -435,7 +403,6 @@ SINGLE READY CODE_SMELL - common CONSTANT_ISSUE 30min