Skip to content

Commit f7bf365

Browse files
authored
Merge pull request #243 from cnescatlab/develop
Release 5.1.0
2 parents 5e26581 + 6c840d1 commit f7bf365

File tree

76 files changed

+6596
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+6596
-146
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ If you need to add some new feature, the easiest way is to implment your own plu
8181

8282
## Changelog
8383

84+
#### Release 5.1.0
85+
- Includes fixes from Eumetsat (thanks for your contribution!)
86+
- Includes security fixes from dependabot
87+
8488
#### Release 5.0.0
8589
- Remove shell support
8690

fortran77-rules/src/main/resources/fortran77-rules.xml

+48
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,52 @@
342342
<languageId>fr.cnes.icode.fortran77</languageId>
343343
<name>F77.TYPE.Hollerith</name>
344344
</check>
345+
<check>
346+
<class>fr.cnes.icode.fortran77.rules.COMPRESFileLength</class>
347+
<id>fr.cnes.icode.fortran77.rules.COMPRESFileLength</id>
348+
<name>COM.PRES.FileLength</name>
349+
<languageId>fr.cnes.icode.fortran77</languageId>
350+
</check>
351+
<check>
352+
<class>fr.cnes.icode.fortran77.rules.COMMETLineOfCode</class>
353+
<id>fr.cnes.icode.fortran77.rules.COMMETLineOfCode</id>
354+
<name>COM.MET.LineOfCode</name>
355+
<languageId>fr.cnes.icode.fortran77</languageId>
356+
</check>
357+
<check>
358+
<class>fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments</class>
359+
<id>fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments</id>
360+
<name>COM.FLOW.CheckArguments</name>
361+
<languageId>fr.cnes.icode.fortran77</languageId>
362+
</check>
363+
<check>
364+
<class>fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified</class>
365+
<id>fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified</id>
366+
<name>COM.MET.ComplexitySimplified</name>
367+
<languageId>fr.cnes.icode.fortran77</languageId>
368+
</check>
369+
<check>
370+
<class>fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit</class>
371+
<id>fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit</id>
372+
<name>F77.DESIGN.LogicUnit</name>
373+
<languageId>fr.cnes.icode.fortran77</languageId>
374+
</check>
375+
<check>
376+
<class>fr.cnes.icode.fortran77.rules.COMMETRatioComment</class>
377+
<id>fr.cnes.icode.fortran77.rules.COMMETRatioComment</id>
378+
<name>COM.MET.RatioComment</name>
379+
<languageId>fr.cnes.icode.fortran77</languageId>
380+
</check>
381+
<check>
382+
<class>fr.cnes.icode.fortran77.rules.COMPRESData</class>
383+
<id>fr.cnes.icode.fortran77.rules.COMPRESData</id>
384+
<name>COM.PRES.Data</name>
385+
<languageId>fr.cnes.icode.fortran77</languageId>
386+
</check>
387+
<check>
388+
<class>fr.cnes.icode.fortran77.rules.F77FILEHeader</class>
389+
<id>fr.cnes.icode.fortran77.rules.F77FILEHeader</id>
390+
<name>F77.FILE.Header</name>
391+
<languageId>fr.cnes.icode.fortran77</languageId>
392+
</check>
345393
</checkers>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/************************************************************************************************/
2+
/* i-Code CNES is a static code analyzer. */
3+
/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */
4+
/* http://www.eclipse.org/legal/epl-v10.html */
5+
/************************************************************************************************/
6+
/***************************************************************************************/
7+
/* This file is used to generate a rule checker for COM.FLOW.CheckArguments rule.*/
8+
/* For further information on this, we advise you to refer to RNC manuals. */
9+
/* As many comments have been done on the ExampleRule.lex file, this file */
10+
/* will restrain its comments on modifications. */
11+
/* */
12+
/***************************************************************************************/
13+
package fr.cnes.icode.fortran77.rules;
14+
import java.io.FileNotFoundException;
15+
import java.io.FileReader;
16+
import java.io.File;
17+
import java.util.List;
18+
import java.util.LinkedList;
19+
import fr.cnes.icode.data.AbstractChecker;
20+
import fr.cnes.icode.data.CheckResult;
21+
import fr.cnes.icode.exception.JFlexException;
22+
%%
23+
%class COMFLOWCheckArguments
24+
%extends AbstractChecker
25+
%public
26+
%column
27+
%line
28+
%ignorecase
29+
%function run
30+
%yylexthrow JFlexException
31+
%type List<CheckResult>
32+
%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, ARGUMENTS_DEF
33+
COMMENT_WORD = \! | c | C | \*
34+
PROCEDURES = PROCEDURE | procedure | SUBROUTINE | subroutine | FUNCTION | function
35+
PROG = PROGRAM | program
36+
MOD = MODULE | module
37+
INTER = INTERFACE | interface
38+
TYPE = {PROG} | {MOD} | {INTER}
39+
VAR = [a-zA-Z][a-zA-Z0-9\_]*
40+
STRING = \'[^\']*\' | \"[^\"]*\"
41+
SPACE = [\ \r\t\f]
42+
END = END | end
43+
INITARG = \(
44+
FINARG = \)
45+
COMA = \,
46+
47+
%{
48+
String location = "MAIN PROGRAM";
49+
private String parsedFileName;
50+
int arguments = 1;
51+
boolean procStarted = false;
52+
boolean nameRead = false;
53+
54+
public COMFLOWCheckArguments(){
55+
}
56+
57+
@Override
58+
public void setInputFile(final File file) throws FileNotFoundException {
59+
super.setInputFile(file);
60+
this.parsedFileName = file.toString();
61+
this.zzReader = new FileReader(new File(file.getAbsolutePath()));
62+
}
63+
64+
private void checkArgumentsProcedure() {
65+
if(procStarted && arguments > 5) {
66+
this.setError(location,"This procedure contains more than 5 arguments: " + arguments, yyline+1);
67+
}
68+
procStarted = false;
69+
nameRead = false;
70+
}
71+
72+
%}
73+
%eofval{
74+
return getCheckResults();
75+
%eofval}
76+
%eofclose
77+
%%
78+
/************************/
79+
80+
/************************/
81+
/* COMMENT STATE */
82+
/************************/
83+
<COMMENT>
84+
{
85+
\n {yybegin(NEW_LINE);}
86+
. {}
87+
}
88+
/************************/
89+
/* AVOID STATE */
90+
/************************/
91+
<AVOID> \n {yybegin(NEW_LINE);}
92+
<AVOID> . {}
93+
/************************/
94+
/* NAMING STATE */
95+
/************************/
96+
<NAMING>
97+
{
98+
{VAR} {yybegin(AVOID);}
99+
\n {yybegin(NEW_LINE);}
100+
. {}
101+
}
102+
/************************/
103+
/* YYINITIAL STATE */
104+
/************************/
105+
<YYINITIAL>
106+
{
107+
{COMMENT_WORD} {yybegin(COMMENT);}
108+
{STRING} {yybegin(LINE);}
109+
{TYPE} {yybegin(NAMING);}
110+
{END} {yybegin(AVOID);}
111+
{PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);}
112+
{SPACE} {}
113+
\n {yybegin(NEW_LINE);}
114+
. {yybegin(LINE);}
115+
}
116+
/************************/
117+
/* ARGUMENTS_DEF STATE */
118+
/************************/
119+
<ARGUMENTS_DEF>
120+
{
121+
{VAR} {if(!nameRead) {location = location + " " + yytext(); nameRead = true;}}
122+
{INITARG} {arguments = 1;}
123+
{COMA} {arguments++;}
124+
{FINARG} {checkArgumentsProcedure(); yybegin(AVOID);}
125+
\n {if(procStarted == false) yybegin(NEW_LINE);}
126+
. {}
127+
}
128+
/************************/
129+
/* NEW_LINE STATE */
130+
/************************/
131+
<NEW_LINE>
132+
{
133+
{COMMENT_WORD} {yybegin(COMMENT);}
134+
{STRING} {yybegin(LINE);}
135+
{TYPE} {yybegin(NAMING);}
136+
{END} {yybegin(AVOID);}
137+
{PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);}
138+
{SPACE} {}
139+
\n {yybegin(NEW_LINE);}
140+
. {yybegin(LINE);}
141+
}
142+
/************************/
143+
/* LINE STATE */
144+
/************************/
145+
<LINE>
146+
{
147+
{COMMENT_WORD} {}
148+
{STRING} {}
149+
{TYPE} {yybegin(NAMING);}
150+
{END} {yybegin(AVOID);}
151+
{PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);}
152+
{VAR} {}
153+
\n {yybegin(NEW_LINE);}
154+
. {}
155+
}
156+
/************************/
157+
/* ERROR STATE */
158+
/************************/
159+
[^] {
160+
161+
final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
162+
throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn);
163+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/************************************************************************************************/
2+
/* i-Code CNES is a static code analyzer. */
3+
/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */
4+
/* http://www.eclipse.org/legal/epl-v10.html */
5+
/************************************************************************************************/
6+
/********************************************************************************************/
7+
/* This file is used to generate a rule checker for COM.MET.ComplexitySimplified rule. */
8+
/* For further information on this, we advise you to refer to RNC manuals. */
9+
/* As many comments have been done on the ExampleRule.lex file, this file */
10+
/* will restrain its comments on modifications. */
11+
/* */
12+
/********************************************************************************************/
13+
package fr.cnes.icode.fortran77.rules;
14+
import java.io.FileNotFoundException;
15+
import java.io.FileReader;
16+
import java.io.File;
17+
import java.util.List;
18+
import java.util.LinkedList;
19+
import fr.cnes.icode.data.AbstractChecker;
20+
import fr.cnes.icode.data.CheckResult;
21+
import fr.cnes.icode.exception.JFlexException;
22+
%%
23+
%class COMMETComplexitySimplified
24+
%extends AbstractChecker
25+
%public
26+
%column
27+
%line
28+
%function run
29+
%yylexthrow JFlexException
30+
%type List<CheckResult>
31+
%state COMMENT, NAMING, NEW_LINE, LINE, AVOID
32+
COMMENT_WORD = \! | c | C | \*
33+
FUNC = FUNCTION | function
34+
PROC = PROCEDURE | procedure
35+
SUB = SUBROUTINE | subroutine
36+
PROG = PROGRAM | program
37+
MOD = MODULE | module
38+
INTER = INTERFACE | interface
39+
TYPE = {PROG} | {MOD} | {INTER}
40+
PROCEDURES = {FUNC} | {PROC} | {SUB}
41+
UNION = \.AND\. | \.and\. | \.OR\. | \.or\.
42+
CICLO = DO | do | IF | if | ELSE[\ ]*IF | else[\ ]*if
43+
CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do
44+
VAR = [a-zA-Z][a-zA-Z0-9\_]*
45+
END = END | end
46+
STRING = \'[^\']*\' | \"[^\"]*\"
47+
48+
%{
49+
String location = "MAIN PROGRAM";
50+
private String parsedFileName;
51+
int numCyclomatic = 1;
52+
int procedureLine = 0;
53+
54+
public COMMETComplexitySimplified(){
55+
}
56+
57+
@Override
58+
public void setInputFile(final File file) throws FileNotFoundException {
59+
super.setInputFile(file);
60+
this.parsedFileName = file.toString();
61+
this.zzReader = new FileReader(new File(file.getAbsolutePath()));
62+
}
63+
64+
private void checkTotalComplexity() {
65+
if(numCyclomatic > 20 ) {
66+
setError(location,"The cyclomatic complexity of this function is more than 20: " +numCyclomatic, procedureLine+1);
67+
}
68+
}
69+
70+
%}
71+
%eofval{
72+
return getCheckResults();
73+
%eofval}
74+
%eofclose
75+
%%
76+
/************************/
77+
78+
/************************/
79+
/* COMMENT STATE */
80+
/************************/
81+
<COMMENT>
82+
{
83+
\n {yybegin(NEW_LINE);}
84+
. {}
85+
}
86+
/************************/
87+
/* AVOID STATE */
88+
/************************/
89+
<AVOID> \n {yybegin(NEW_LINE);}
90+
<AVOID> . {}
91+
/************************/
92+
/* NAMING STATE */
93+
/************************/
94+
<NAMING>
95+
{
96+
{VAR} {location = location + " " + yytext(); yybegin(AVOID);}
97+
\n {yybegin(NEW_LINE);}
98+
. {}
99+
}
100+
/************************/
101+
/* YYINITIAL STATE */
102+
/************************/
103+
<YYINITIAL>
104+
{
105+
{COMMENT_WORD} {yybegin(COMMENT);}
106+
{STRING} {yybegin(LINE);}
107+
{TYPE} {yybegin(AVOID);}
108+
{PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);}
109+
\n {yybegin(NEW_LINE);}
110+
. {yybegin(LINE);}
111+
}
112+
/************************/
113+
/* NEW_LINE STATE */
114+
/************************/
115+
<NEW_LINE>
116+
{
117+
{COMMENT_WORD} {yybegin(COMMENT);}
118+
{STRING} {yybegin(LINE);}
119+
{TYPE} {yybegin(AVOID);}
120+
{PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);}
121+
{CICLO} {numCyclomatic++; yybegin(LINE);}
122+
{UNION} {numCyclomatic++; yybegin(LINE);}
123+
{CLOSING} {yybegin(LINE);}
124+
{END} {checkTotalComplexity();}
125+
{VAR} {yybegin(LINE);}
126+
\n {}
127+
. {yybegin(LINE);}
128+
}
129+
/************************/
130+
/* LINE STATE */
131+
/************************/
132+
<LINE>
133+
{
134+
{COMMENT_WORD} {yybegin(COMMENT);}
135+
{STRING} {}
136+
{TYPE} {yybegin(AVOID);}
137+
{PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);}
138+
{CICLO} {numCyclomatic++;}
139+
{UNION} {numCyclomatic++;}
140+
{CLOSING} {}
141+
{END} {checkTotalComplexity();}
142+
{VAR} {}
143+
\n {yybegin(NEW_LINE);}
144+
. {}
145+
}
146+
/************************/
147+
/* ERROR STATE */
148+
/************************/
149+
[^] {
150+
151+
final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
152+
throw new JFlexException(this.getClass().getName(), parsedFileName,
153+
errorMessage, yytext(), yyline, yycolumn);
154+
}

0 commit comments

Comments
 (0)