-
Notifications
You must be signed in to change notification settings - Fork 16
User Manual
Benoît Garçon edited this page Feb 3, 2020
·
8 revisions
- 1. Introduction
- 2. i-Code CNES products
- 3. Rules description
- 4. Metrics description
- [5. Messages]
- 6. Limitations
- 7. References
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 ].
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. | ✔️ |
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 |
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 || 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. |
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. |
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” |
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 |
- [ 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
i-Code CNES is an open source project under license EPL-1.0