Skip to content

User Manual

Benoît Garçon edited this page Feb 11, 2020 · 8 revisions

Table of contents

1. Introduction

This document is the i-Code CNES user manual. It describes how to use i-Code CNES.

Before using i-Code CNES, you should:

  • Know eclipse. Eclipse documentation is available here [ R1 ].
  • Read CNES coding rules [ R2 ] [ R3 ] [ R4 ] [ R5 ].

Installation instructions are available in the installation manual [ R6 ].

2. i-Code CNES products

The new architecture of i-Code is decomposed as described in the following schema. It is designed to be easily extendable. Users can build their own checkers and simply add their jar in the icode/plugins directory. See the Developer Guide for more details.

i-Code CNES 4 architecture

2.1. i-Code App or i-Code CLI

This is the common command line application for i-Code. In your project directory, use the following command to analyze all files:

# Analyze whole project
icode .

# Analyze whole project and make an xml output of the analysis
icode . -f xml -o output.xml

# List all functionality and description
icode --help

Use icode --help to get the following help about i-Code:

usage: icode [<FILE> [...]] [-c <arg>] [-e] [-f <arg>] [-h] [-l] [-o <arg>] [-p <arg>] [-q <arg>] [-r] [-v] [-x <arg>]
Analyze Shell, F77 & F90 code to find defects & bugs.

 -c,--checked-languages <arg>        Comma separated list of languages checked during analysis. All by default.
 -e,--exporters                      Display all available exporters.
 -f,--export-format <arg>            Set the format for result file. Default format is XML.
 -h,--help                           Display this message.
 -l,--languages                      Display all available languages.
 -o,--output <arg>                   Set the name for result file. Results are displayed in standard output by default.
 -p,--export-parameters <arg>        Comma separated list of parameters for the export. Format is:
                                     key1=value1,key2=value2,key3=value3. Default values depend on the chosen export plugin.
 -q,--list-export-parameters <arg>   Display all available parameters for the given export.
 -r,--rules                          Display all available rules.
 -v,--version                        Display version information.
 -x,--excluded-rules <arg>           Comma separated list of rules id to exclude from analysis. None by default.

2.2. i-Code IDE

This is the common GUI application for i-Code.

Preferences

Select Window > Preferences > i-Code CNES.

You can set the severity configuration of the analysis using the scrollbar from RNC A to D, and choose rules to enable or disable in the different tables. You can also edit metrics' threshold.

Launching an analysis

Select files to analysis, one or several, and then click on i-Code CNES > Run analysis.

2.3. i-Code plugin for Eclipse

The Eclipse plugin for i-Code allows to use i-Code from Eclipse IDE.

Preferences

Select Window > Preferences > i-Code CNES.

You can set the severity configuration of the analysis using the scrollbar from RNC A to D, and choose rules to enable or disable in the different tables. You can also edit Metrics threshold.

Launching an analysis

Select files to analysis, one or several, and then click on i-Code CNES > Run analysis.

2.4. i-Code plugin for SonarQube

The SonarQube plugin for i-Code allows to use i-Code through SonarQube analysis.

Please refer to sonar-icode-cnes-plugin for more details.

2.5. i-Code Core

This is the core library containing all i-Code utilities for code analysis.

See the Developer Guide for more details.

2.6. i-Code Library

This is the full library containing all official checkers. It includes i-Code Core and all official language analyzers.

See the Developer Guide for more details.

3. Rules description

3.1. Common rules

Rule Description Coverage
COM.DATA.Array Two dimensions arrays should be declared in this way : line x column
COM.DATA.DeclarationOrder Fortran 77: not applicable
Fortran 90: Parameters should declared in the following order: input, input/output, output. Declaration is made using keyword “INTENT”, and then “IN”, “INOUT” and “OUT”. If “INTENT” keyword is not used, the check is impossible.
Shell: not applicable

✔️
COM.DATA.FloatCompare Fortran: Equality and non-equality (.EQ., ==, .NE., /=) are forbidden on reals (REAL, DOUBLE PRECISION, COMPLEX)
Shell: not applicable
✔️
COM.DATA.Initialisation 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. ✔️
COM.DATA.Invariant Data declared into subroutine, function, … and which are never modified then should be declared as constant. ✔️
COM.DATA.LoopCondition It is forbidden to modify loop condition inside the loop. ✔️
COM.DATA.NotUsed Fortran: Every declared variable should be used.
Shell: Every declared variable should be used.
Limitations: a variable is considered as used if used with ${variable}
✔️
COM.DATA.Using It is forbidden to reuse local object in several different treatments.
COM.DESIGN.Alloc Fortran: Allocation and deallocation of resources 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.
Shell: not applicable
partial
COM.DESIGN.ActiveWait Fortran: in a loop, SLEEP, WAIT and PAUSE instructions are forbidden. Shell: WHILE[1] and keyword READ are forbidden. ✔️
COM.FLOW.Abort Fortran: Keyword STOP is forbidden
Shell: Keyword KILL, PKILL and KILLALL are forbidden.
Limitation: i-Code CNES do not consider keyword “RETURN”, “BREAK” and “EXIT”.
✔️
COM.FLOW.BooleanExpression In a condition (IF,DO), maximum number of operands is 5 (AND, OR, NEQV, XOR, EQV, NOT, LT, <, LE, <=, GT, >, GE, >=, EQ, ==, NE, /=) ✔️
COM.FLOW.CaseSwitch Fortran 77: not applicable
Fortran 90: SWITCH instruction should define the DEFAULT case as last one.
Shell: CASE instruction should finish with *)

✔️
✔️
COM.FLOW.CheckArguments Fortran: Every parameter should be checked.
Shell: see SH.FLOW.CheckArguments
COM.FLOW.CheckCodeReturn Fortran: Function return values should be checked.
Shell: see SH.FLOW.CheckCodeReturn
✔️
COM.FLOW.CheckUser Fortran: The identity of the user running the program should be checked.
Shell: see SH.FLOW.CheckUser
✔️
COM.FLOW.Exit Fortran: Function, procedure and method should have a unique exit point.
Shell: not available
✔️
COM.FLOW.ExitLoop Loops should have a unique exit point. ✔️
COM.FLOW.FileExistence Fortran: File opening (OPEN, READ, WRITE) should be done after using INQUIRE and EXIST instruction of this file.
Shell: A file access (> file_name) should be preceded by the check : if[ ! -f $file_name]
Limitations: - No detection in commands $(…) or - A redirection or a redirected variable could be considered as a file
✔️
✔️
COM.FLOW.FilePath In the OPEN instruction, it is forbidden to use directly the file name (file.txt). Path should be defined through a variable. ✔️
COM.FLOW.Recursion Fortran77: not applicable
Fortran 90: Recursivity is forbidden. In Fortran, i-Code CNES checks that « RECURSIVE FUNCTION(params) » is not found.

✔️
COM.INST.BoolNegation 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 ✔️
COM.INST.Brace Fortran: Every expression should be braced.
Shell: not available
✔️
COM.INST.CodeComment Fortran: Code comments are forbidden. I-Code CNES checks all keywords in comments, except in the header. Shell: Code comments are forbidden. I-Code CNES checks all keywords in comments (after #). Limitation: False positive will be raised due to common word used as keyword, for example “date”. ✔️
COM.INST.GOTO Fortran: “GO TO” is forbidden
Shell: not applicable
✔️
COM.INST.Line Fortran 77 : not applicable Fortan 90 and shell: Each line should be limited to only one expression. Shell Limitation: The use of keywords in command messages without using « » could produce false positive. ❌ ✔️
COM.INST.LoopCondition Fortran: In a loop instruction, comparison using (.EQ., ==, .NE., =) are forbidden.
Shell: not available
✔️
COM.NAME.Homonymy Fortran: Variable name should be unique. ✔️
COM.PRES.Data Important objects should be well commented.
COM.PRES.Indent Source code should be indented with space. Example: DO i = 2, nb somme = somme + x(i) IF (isnan(somme)) THEN print *, 'somme is a NaN' moy = -1.0 END IF END DO ✔️
COM.PRES.LengthLine A line of source code should contain 100 characters maximum. ✔️
COM.PROJECT.Analyser All source code should be analyzed with checkers.
COM.PROJECT.CodeCloning Duplicated code is forbidden.
COM.PROJECT.Header Shell: named COM.PRES.Header Fortran: Headers are mandatory for each module and function ✔️
COM.PROJECT.Warnings Warning should be displayed and fixed.
COM.TYPE.Expression Fortran: in a expression (defined by operator like +, -, /, *, **) all variables should have the same type : REAL, INTEGER, …
Shell: not available
✔️

3.2. Specific rules

3.2.1. Shell rules

Rule Description Coverage
SH.DATA.Constant Constants should be defined using ‘typeset –r’.
SH.DATA.IFS It is forbidden to modify IFS variable ✔️
SH.DATA.Integer Integer declaration should be done with ‘typeset –i’ ✔️
SH.DESIGN.Bash Script firs line should be # !/bin/bash, # !/bin/ksh or # !/bin/false. ✔️
SH.DESIGN.Exit It is forbidden for a program to end before the processes it launches.
SH.DESIGN.Options Getopts should be followed by a case where options are evaluated. ✔️
SH.ERR.Args It is mandatory to display a message when a script does not recognize an option. This message should include the way to use the script (-help)
SH.ERR.Help Options should be managed with getopts or getopt followed by a case. One of these cases should be –h or --helpLimitation: if "h)"" appears in a string in a case, whereas no -h option is handled, so there won't be any issue." ✔️
SH.ERR.NoPipe Use ‘set –o pipefail’ before using pipes.Limitations:- The use of | into a string or command line options will raise an error except in a printf or sed- The use of | followed by # are not detected ✔️
SH.ERR.String The use of « if » or « while » with strings, empty wtrings should be managed.Limitation : Call of ls inside a command $(…) or could be ignored. ✔️
SH.FLOW.CheckArguments In a function, first instruction should be the parameters check. ✔️
SH.FLOW.CheckCodeReturn For each function and command call in the script, it’s mandatory to verify the code return of the execution using $# ✔️
SH.FLOW.CheckUser If root rights are needed, the administration intervention should be asked right after the user check ✔️
SH.INST.Basename Do not use $0, replace it by ‘basename $0‘ ✔️
SH.INST.Continue Shell : not available
SH.INST.Copy ‘cp’ command should be used with arguments of the same type (file or directory)
SH.INST.Find LS instruction is forbidden ✔️
SH.INST.GetOpts GETOPS should be used to check parametersLimitation: After calling getopt, issues on $1 are ignored until the declaration of a new function. partial
SH.INST.Interpreter First line should be the access to interpretor. ✔️
SH.INST.Keywords Keyword should not be used as variable name.Limitation: Use of command having keywords as option raise false positives (e.g.: option if of command dd). ✔️
SH.INST.Logical After && or ||, only echo and axit are allowed. ✔️
SH.INST.Move It is forbidden to erase a file using « mv » command.
SH.INST.POSIX POSIX commands should be used.Limitation: call of echo with redirections could raise errors. ✔️
SH.INST.SetShift Instructions SET and SHIFT are forbidden. ✔️
SH.INST.Variables Every variable should be written as : ${variable_name} ✔️
SH.IO.Redirect not implementedstandard redirections should be commented, the comment should contains the redirection name. ✔️
SH.MET.LimitAWK AWK instruction should not exceed 5 actions. ✔️
SH.MET.LimitSed SED instruction should not exceed 5 actions. ✔️
SH.MET.PipeLine Every command pipeline should be commented. ✔️
SH.REF.Export It’s forbidden to export function self defined by the script. ✔️
SH.REF.Inheritance Scripts should not inherit alias or user defined functions.
SH.SYNC.Signals It’s mandatory to define intercepted signals using trap by their name. It’s forbidden to define it by its numeric value. ✔️

3.2.2. Fortran 77 rules

Rule Description Coverage
F77.BLOC.Common White COMMON are forbidden. ✔️
F77.BLOC.Else In an instruction IF, the last ELSE IF should be follow by ELSE. ✔️
F77.BLOC.File File access whould be done using OPEN and CLOSE instructions.
F77.BLOC.Function Parameter’s braces sohuld be used when defining a FUNCTION whenever there is no parameter. ✔️
F77.BLOC.Loop Nested DO loop should have different end instructions (one for each). ✔️
F77.DATA.Array Arrays dimension should be declared explicitly. The use of * is tolerated for the last one if justified with a comment. A(*), A(4, *), A(4, *, *), A(4, 4, ), but A(, 4) ✔️
F77.DATA.Common INCLUDE must be used to declare COMMON in program units referencing it. ✔️
F77.DATA.Double In a constante initialisation or in an expression evaluation, the use of (D) (as double precision is mandatory. ✔️
F77.DATA.Initialisation Variable initialisation should be done using DATA or BLOCKDATA ✔️
F77.DATA.IO Implicit logical units defined by * are forbidden. READ (,f) [iolist], READ f [,iolist], WRITE (,f) [iolist], PRINT f [,iolist] ✔️
F77.DATA.LoopDo DO loop condition parameter should use INTEGER. ✔️
F77.DATA.Parameter The use of constants, computed values or function calls as function parameters is forbidden. CALL function (3, x*y, f(z), var) ✔️
F77.ERR.OpenRead The check of eturn status for instructions OPEN and READ is mandatory. It is recommended to use “IOSTAT = “ to do it. ✔️
F77.INST.Assign ASSIGN instruction is forbidden. ✔️
F77.INST.Dimension DIMENSION instruction is forbidden. ✔️
F77.INST.Equivalence EQUIVALENCE instruction is forbidden. ✔️
F77.INST.Function FUNCTION instruction should be used with an explicite type declaration, at function definition. ✔️
F77.INST.If Arithmetic IF is forbidden. IF (Arithmetic expression) e1,e2,e3 Where "eN" are tags ✔️
F77.INST.Include 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) ✔️
F77.INST.Pause PAUSE instruction is forbidden. ✔️
F77.INST.Return RETURN(i) instruction is forbidden in subprogram. ✔️
F77.INST.Save SAVE instruction is forbidden except for local variables with justification in a comment. ✔️
F77.MET.Line Interdiction de dépasser 72 caractères par ligne. ✔️
F77.NAME.GenericIntrinsic The use of generic names for intrinseque functions is mandatory. ✔️
F77.NAME.Intrinsic Intrinseque function names reuse is forbidden. ✔️
F77.NAME.KeyWords Fortran 77 keywords should not be reused for variable names. ✔️
F77.NAME.Label Tags are limited to FORMAT and CONTINUE. ✔️
F77.PROTO.Declaration External functions should be declared with EXTERNAL keyword. ✔️
F77.REF.IO Logical unit should be identified with symbolic name. ✔️
F77.REF.Open OPEN parameters FILE, STATUS and POSITION should be defined. ✔️
F77.REF.Parameter 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. COMMON /CONTROL/ A, B, C, D … PROGRAM ESSAI CALL MY_SUB1 (A, B, C, D) … END PROGRAM ESSAI …. SUBROUTINE MY_SUB1 (C _A, B, _C, C_D) ✔️
F77.TYPE.Basic Only standard types (INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, CHARACTER) are allowed. ✔️
F77.TYPE.Hollerith Data and constant of type Hollerith are forbidden. ✔️

3.2.3. Fortran 90 rules

Rule Description Coverage
F90.DESIGN.Free Allocated memory should be free in the same conceptual level.
F90.DESIGN.Include File inclusion is forbidden. INCLUDE ‘file_to_include.F90’ ✔️
F90.DESIGN.Interface Modules should only contains USE, PRIVATE and PUBLIC clauses. MODULE interface_syslog Implicit none PRIVATE Interface Subroutine f_syslog(cdata) USE message_syslog Type(opendata_type) End subroutine End interface PUBLIC f_syslog End module interface_syslog ✔️
F90.DESIGN.IO In an OPEN function, units number should depend on another function or array. partial
F90.DESIGN.Obsolete 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 ✔️
F90.BLOC.File Every open file should be closed. OPEN ( unit = f_unit, …) … CLOSE ( unit = f_unit, …) ✔️
F90.DATA.Array Array dimensions should be respected. Example: Subroutine s1(tab) -> Subroutine s1(tab, x) Integer :: tab(2) Integer :: tab(x) ✔️
F90.DATA.ArrayAccess In an array of indirections, it is not possible to define the same item several times. Integer,dimension(3) :: a Integer.dimension(3) :: b a = ( / 1,1,3 / ) b(a) = ( / 1,2,3 / ) ✔️
F90.DATA.Constant Constants which appear in several subprograms should be defined into a module. Subroutine s1() Real PI = 3,141519 End subroutine s1 module precision -> real PI = 3.141519 Function f1() end module precision Real PI = 3,141519 End function ✔️
F90.DATA.ConstantFloat Numerical constants (see above) should be followed by subtype parameter. Integer,parameter :: DOUBLE=selected_real_kind(15) Real (DOUBLE) :: x = 0.1_DOUBLE ✔️
F90.DATA.Declaration The use of IMPLICITE NONE instruction is mandatory for each method header. Limitations : this rule is not checked for function and array ✔️
F90.DATA.Float It is forbidden to use * output format (WRITE instruction) for REAL ✔️
F90.DATA.Parameter Functions SELECTED_REAL_KIND and SELECTED_INT_KIND should be grouped in the same module. MODULE precision Integer, parameter :: DOUBLE = SELECTED_REAL_KIND(15) END MODULE ✔️
F90.ERR.Allocate Allocation and deallocation should contain “STAT” parameter. Then, « STAT » value should be tested. ALLOCATE(x, STAT = iom) IF (iom > 0) THEN … ✔️
F90.ERR.OpenRead 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. ✔️
F90.INST.Associated Between declaration and ASSOCIATED instruction, it is mandatory to call NULLIFY. ✔️
F90.INST.Entry ENTRY instruction is forbidden. ✔️
F90.INST.Equivalence EQUIVALENCE instruction is forbidden. ✔️
F90.INST.If IF followed by one of these instructions : EXIT, GOTO, CYCLE, RETURN is forbidden. IF (x == 0) THEN GO TO 1000 End IF ✔️
F90.INST.Intent Each subprogram parameter should be declared with INTENT keyword Function f1(x, y, z) Integer, INTENT(IN) :: x Integer, INTENT(IN) :: y Integer, INTENT(OUT) :: z ✔️
F90.INST.Nullify After deallocate, the use of NULLIFY into the same logical uniti s mandatory DEALLOCATE (C, stat = iom ) NULLIFY ( C )
F90.INST.Only The use of keyword ONLY without comment is forbidden ✔️
F90.INST.Operator Do not use old notation. Replace .EQ., .NE., .LT., .LE., .GT., .GE. by ==, /=, <, <=, >, >= ✔️
F90.INST.Pointer POINTER is forbidden except in those cases: - Complex data structure creation - Manage array references - Dynamic allocation into composants with derivated types ✔️
F90.NAME.GenericIntrinsic Do not use specific functions (INT, IFIX, IDINT, REAL, FLOAT, SNGL, ICHAR, CHAR, AINT, DINT, ANINT, DNINT, NINT, IDNINT, IABS, ABS, DABS, CABS, MOD, AMOD, DMOD, ISIGN, SIGN, DSIGN, IDIM, DIM, DDIM, DPROD, MAX0, AMAX1, DMAX1, AMAX0, MAX1, MIN0, AMIN1, DMIN1, AMIN0, MIN1, AIMAG, CONJG, SQRT, DSQRT, CSQRT, EXP, DEXP, CEXP, ALOG, DLOG, CLOG, ALOG10, DLOG10, SIN, DSIN, CSIN, COS, DCOS, CCOS, TAN, DTAN, ASIN, DASIN, ACOS, DACOS, ATAN, DATAN, ATAN2, DATAN2, SINH, DSINH, COSH, DCOSH, TANH, DTANH), use generic ones (INT, REAL, AINT, ANINT, NINT, ABS, MOD, SIGN, DIM, MAX, MIN, SQRT, EXP, LOG, LOG10, SIN, COS, TAN, ASIN, ACOS, ATAN, ATAN2, SINH, COSH, TANH). ✔️
F90.NAME.KeyWords Fortran keywords should not be used as variable names. ✔️
F90.PROTO.Overload Overraded operators are forbidden ✔️
F90.REF.ARRAY The use of a whole array should be represented using the notation (:) Y = A*X + B Y(:) = A(:)*X + B où Y et A sont des tableaux ✔️
F90.REF.Interface Called subprogram should be visible. subroutine Pas_1 subroutine Pas_1 call Mouv(3.0,resul) call Mouv(3.0,resul) end subroutine Pas_1 contains subroutine Mouv(oper0, resul) -> subroutine Mouv(oper0, resul) … … end subroutine Mouv end subroutine Mouv end subroutine Pas_1 ✔️
F90.REF.Label END keyword should be followed by the type (function, subroutine…) and the name. function f function f … -> … end function end function f ✔️
F90.REF.Open Every OPEN instruction should have parameters FILE, STATUS, IOSTAT and POSITION OPEN (UNIT=f_unit, FILE=c_args, STATUS=’old’, POSITION=’rewind’, IOSTAT=ios) ✔️
F90.REF.Variable A variable should be referenced with the same name in subprogram. Call incr( i ) call incr( i ) … … subroutine incr( j ) -> subroutine incr( j ) i = i + 1 j = j + 1 end subroutine incr end subroutine incr ✔️
F90.TYPE.Derivate Every type declaration should be placed into a module ✔️
F90.TYPE.Integer INTEGER parameters should be followed by SELECTED_INT_KIND expression. ✔️
F90.TYPE.Real REAL parameters should be followed by SELECTED_REAL_KIND Real, parameter :: LONG real, parameter :: LONG = SELECTED_REAL_KIND(5) ✔️

4. Metrics description

Metric File computation
MET.Nesting Maximum number of nested levels if a function/method. This number is 0 if there is no imbrication.
MET.Cyclomatic Number of decisions into the source code.
MET.LineOfCode Number of lines into the source code (except white line and comment line).
MET.RatioComment Ratio of comment in the source code.
MET.LineOfComment Number of comment lines.

5. Messages

5.1. Common messages

Rule Message
COM.DATA.DeclarationOrder The parameters are not defined in the right order. The order shall be: in, in/out, out.
COM.DATA.FloatCompare It’s not allowed to compare float variables( "variable") with equality.
COM.DATA.Initialisation The variable "variable" is used before being initialized.
COM.DATA.Invariant The variable "variable" must be defined as constant.
COM.DATA.LoopCondition The variable "variable" is modified inside the loop.
COM.DATA.NotUsed The variable "variable" is declared and not used
COM.DESIGN.ActiveWait This process contains an active wait. Shell: There is an active wait in this point.
COM.DESIGN.Alloc The resource named "variable" has not been allocated and deallocated in the same algorithmic level.
COM.FLOW.Abort The keyword STOP is not allowed.
COM.FLOW.BooleanExpression Shell: It is not allowed use five or more conditional expressions in the same instruction.Using more than five conditions in an expression is not allowed.
COM.FLOW.CaseSwitch A DEFAULT case is needed in a switch case instruction. Shell: The default case of the case switch condition is missing.
COM.FLOW.CheckCodeReturn The return code of the function “function” is not checked.
COM.FLOW.CheckUser The user identity is not verified in the main program.
COM.FLOW.Exit There is more than one exit in the function.
COM.FLOW.ExitLoop There is more than one exit in the loop.
COM.FLOW.FileExistence The existences of the file “file” must be checked with the instruction INQUIRE before being opened or created. Shell: The existence of the file " + name + " has not been checked.
COM.FLOW.FilePath It is not allowed to use directly the file name. Store the file path in a variable. Use the variable instead.
COM.FLOW.Recursion The use of recursivity is not allowed.
COM.INST.BoolNegation Double negation is not allowed.
COM.INST.Brace Parentheses are needed for readability.
COM.INST.CodeComment Commented code is not allowed. It shall be suppressed. Shell: The keyword " + yytext() + " is used in a comment. A variable is assigned in a comment.
COM.INST.GOTO The keyword GOTO is not allowed.
COM.INST.Line More than one instruction per line is not allowed.
COM.INST.LoopCondition A loop condition shall be written with inequality (.LE.,<=, or .GT.,>=)
COM.NAME.Homonymy Names must be unique. The name "variable" is already defined in this file.
COM.PRES.Indent The code is not indented.
COM.PRESLengthLine There are more than 100 characters in this line.
COM.PROJECT.Header - No file header existing. This module/function should have a header with a brief description. - No file header (file name not found). This module/function should have a header with a brief description. - The module/function should have a header with a brief description. SH : The function should have a header with a brief description.
COM.TYPE.Expression Mixed types “type_variable_1” with “type_variable_2” in the same expression

5.2. Shell messages

Rule Message
SH.DATA.IFS The environment variable IFS can't be modified.
SH.DATA.Integer The integer variables must be defined using the typeset -i declaration.
SH.DESIGN.Bash The first line must declare the interpreter (/bin/bash, /bin/ksh or /bin/false)
SH.DESIGN.Options It is mandatory to use getopts and getopt and to provide the –h, -help, –v and -version options at least.
SH.ERR.Help The help option (-h or --help) must be implemented.
SH.ERR.NoPipe When the pipe is used in the script the option set -o pipefail is mandatory.
SH.ERR.String The empty strings must be taken into account
SH.FLOW.CheckArguments The number of parameters received has not been checked.
SH.FLOW.CheckCodeReturn The function's return function_name has not been checked.
SH.FLOW.CheckUser The user has not been checked.
SH.INST.Basename The use of the keyword basename before $0 is mandatory.
SH.INST.Continue The keyword CONTINUE is not allowed.
SH.INST.Find The use of LS is not allowed. Use FIND instead.
SH.INST.GetOpts It is mandatory to use getopts & getopt in the script.
SH.INST.Interpreter The first line must declare the interpreter
SH.INST.Keywords The keywords variable cannot be used as a variable.
SH.INST.Logical The abbreviation &#124;&#124; and && must be followed only by ECHO or EXIT.
SH.INST.POSIX The keyword POSIX_word is not allowed.
SH.INST.SetShift The keyword SET/SHIFT is not allowed.
SH.INST.Variables The variable variable_name is not correctly declared (must be declared using ${ } or " " notation )
SH.IO.Redirect Thenon-standard redirection must be preceded by a comment.
SH.MET.LimitAWK The AWK expression has more than 5 actions
SH.MET.LimitSed The SED expression has more than 5 actions/lines
SH.MET.PipeLine Every pipeline must be preceded by a comment.
SH.REF.Export The keyword EXPORT is no allowed.
SH.SYNC.Signals The keyword TRAP must be followed by a variable, not an integer.

5.3. Fortran 77 messages

Rule Message
F77.BLOC.Common Unnamed COMMON is not allowed.
F77.BLOC.Else The IF instruction shall finish with an ELSE after the last ELSE IF.
F77.BLOC.Function When calling a function, the brackets following the function name are mandatory.
F77.BLOC.Loop Loops shall have distinct ends.
F77.DATA.Array The dimension of the array “variable” is not well declared. The * shall be used for the last dimension.
F77.DATA.Common The INCLUDE instruction shall be used to reference the needed common bloc.
F77.DATA.Double The double precision variable is not correctly initialized. It misses the character D in its declaration.
F77.DATA.Initialization The variable “variable” shall be initialized with DATA or BLOCK DATA before its use.
F77.DATA.IO The use of * with logical units is not allowed.
F77.DATA.LoopDo The control variable in a loop shall be an integer.
F77.DATA.Parameter ”variable” belongs to parameter types forbidden when calling a function: a constant, an expression to be evaluated, a call to another function
F77.ERR.OpenRead The status of OPEN/READ shall be tested with the parameter IOSTAT.
F77.INST.Assign The instruction ASSIGN Is not allowed.
F77.INST.Dimension The instruction DIMENSION Is not allowed.
F77.INST.Equivalence The instruction EQUIVALENCE is not allowed.
F77.INST.Function It misses the type declaration in FUNCTION header.
F77.INST.If The arithmetic if is not allowed.
F77.INST.Include The executable instruction “variable” is not allowed in the include file.
F77.INST.Pause The instruction PAUSE is not allowed.
F77.INST.Return The instruction RETURN(i) is not allowed.
F77.INST.Save The instruction SAVE is only permitted for local variables
F77.MET.Line There are more than 72 characters in this line.
F77.NAME.GenericIntrinsic It should be used the generic name of the intrinsic function instead of “variable”
F77.NAME.Intrinsic It is not allowed to use the name of an intrinsic function.
F77.NAME.KeyWords The variable “variable” is a keyword in Fortran77 language.
F77.NAME.Label The use of labels is not allowed except with the instructions FORMAT and CONTINUE.
F77.PROTO.Declaration The function “variable” shall be declared.
F77.REF.IO The logical entities shall be declared using a symbolic name.
F77.REF.Open The instruction OPEN shall be called with the parameters FILE, STATUS and POSITION.
F77.REF.Parameter It is not allowed to provide as a parameter the variables of an accessible bloc COMMON. The variable “variable” is used in a wrong way.
F77.TYPE.Basic ”variable” is not a basic type. Basic types are INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL and CHARACTER.
F77.TYPE.Hollerith Type Hollerith is not allowed. “variable” shall be a CHARACTER.

5.4. Fortran 90 messages

Rule Message
F90.BLOC.File The file “variable” is not correctly closed.
F90.DATA.Array The dimension’s array must be declared as parameters’ function.
F90.DATA.ArrayAccess Array “ variable1” initialized using other array named “variable2 “ with repeated values.
F90.DATA.Constant The constants shall be declared and initialized in a module.
F90.DATA.ConstantFloat Float constant “variable” shall be declared using the subtype_parameter: _<subtype_parameter>
F90.DATA.Declaration The variable must be declared. The sequence IMPLICITE NONE must be declared after the method.
F90.DATA.Float It is not allowed to use the format * for reals like “variable”.
F90.DATA.Parameter It misses the use of intrinsic function SELECTED_REAL_KIND or SELECTED_INT_KIND for the subtype specification.
F90.DESIGN.Include Is it possible to use a module instead of this inclusion?
F90.DESIGN.Interface Interface Module shall only contain: INTERFACE, USE, IMPLICIT instructions as well as PRIVATE or PUBLIC declaration.
F90.DESIGN.IO The value of the logic unity should be a integer or a variable initialised directly.
F90.DESIGN.Obsolete The instruction calculed GOTO is not allowed. The instruction PAUSE is not allowed. The alternate return statement is not allowed. There is a branch on an END IF statement. It is not allowed. The use of CHARACTER* is not allowed. The instruction HOLLERITH is not allowed inside FORMAT. Error in "variable" used. The instruction ASSIGN contains the label for the FORMAT instruction. Arithmetical IF is not allowed. A DO loop shall end with END DO. The variable "variable" is a real used in a do loop. Use only INTEGER. Each loop shall have its own END DO. Shared END DO is forbidden.
F90.ERR.Allocate The status of the ALLOCATE or DEALLOCATE instruction is not checked
F90.ERR.OpenRead - There is no parameter IOSTAT in the OPEN/READ instruction. - The return of IOSTAT is no checked in the OPEN/READ instruction.
F90.INST.Associated The pointer « variable » is not set to null before the use of the instruction ASSOCIATED.
F90.INST.Entry The instruction ENTRY is not allowed.
F90.INST.Equivalence The instruction EQUIVALENCE is not allowed.
F90.INST.If Logical IF (without THEN and ENDIF) is only allowed with EXIT, CYCLE, GOTO, RETURN statements.
F90.INST.Intent It misses the attribute INTENT for the parameter “variable”
F90.INST.Nullify It misses the instruction NULLIFY after the DEALLOCATION of “variable”.
F90.INST.Only The instruction ONLY must be preceded by a comment.
F90.INST.Operator The symbolic notation (==, /=, <=, <, >=, >) must be used instead of (.EQ., .NE., .LT., .LE., .GT., .GE.). Error in “variable”.
F90.INST.Pointer This use of POINTER is not allowed.
F90.NAME.GenericIntrinsic Use the generic name of the intrinsic functions instead of “variable”.
F90.NAME.KeyWords The variable “variable” is a keyword in Fortran90 language.
F90.PROTO.Overload Overloading operator is not allowed. Overload of “variable”
F90.REF.ARRAY It should be used the notation(:) to specify the entire use of the arrays: “list_variables”.
F90.REF.Interface The function "function" is not visible in this point.
F90.REF.Label It misses the name of the subprogram. It must finish with END TYPE_PROGRAM NAME.
F90.REF.Open It misses one or more parameters In OPEN instruction. Mandatory parameters are FILE, STATUS, IOSTAT, POSITION.
F90.REF.Variable The variable “variable” is used with different names inside the subprogram.
F90.TYPE.Derivate The variable " must be defined inside the module structure.
F90.TYPE.Integer It misses the declaration SELECTED_INT_KIND in the initialisation of “variables”
F90.TYPE.Real It misses the declaration SELECTED_REAL_KIND in the initialisation of “variables”

6. Limitations

LIMITATION ALTERNATIVE LINKED ISSUE
Powershell does not allow to analysis launch Use cmd.exe #73
Shell: strings without quotes are not well supported Use quotes for strings #31
Files without identified extension are not analyzed Analysis on project are based on file extension to attribute the good file to the good analyzer. Which mean, it's not required to filter file's extension when launching an analysis on a project, however it's important (especially in shell) that files that should be analyzed have an appropriate extension.
Extension supported by languages:
- Shell: sh, ksh, bash
- Fortran: f, f77, f90, F, F90, F77, fortran
A Shell file for instance no_extension should be renamed no_extension.sh in order to be analyzed.
#00

7. References

  • [ R1 ] Eclipse Documentation
  • [ R2 ] RNC-CNES-Q-HB-80-505 - Coding rules Fortran 77 Version 7
  • [ R3 ] RNC-CNES-Q-HB-80-517 - Coding rules Fortran 90 Version 5
  • [ R4 ] RNC-CNES-Q-HB-80-501 - Common coding rules Version 5
  • [ R5 ] RNC-CNES-Q-HB-80-516 - Coding rules SHELL Version 6
  • [ R6 ] i-Code Installation Manual