Skip to content

Commit

Permalink
Merge pull request #243 from cnescatlab/develop
Browse files Browse the repository at this point in the history
Release 5.1.0
  • Loading branch information
dev31520 authored Jan 15, 2025
2 parents 5e26581 + 6c840d1 commit f7bf365
Show file tree
Hide file tree
Showing 76 changed files with 6,596 additions and 146 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ If you need to add some new feature, the easiest way is to implment your own plu

## Changelog

#### Release 5.1.0
- Includes fixes from Eumetsat (thanks for your contribution!)
- Includes security fixes from dependabot

#### Release 5.0.0
- Remove shell support

Expand Down
48 changes: 48 additions & 0 deletions fortran77-rules/src/main/resources/fortran77-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,52 @@
<languageId>fr.cnes.icode.fortran77</languageId>
<name>F77.TYPE.Hollerith</name>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.COMPRESFileLength</class>
<id>fr.cnes.icode.fortran77.rules.COMPRESFileLength</id>
<name>COM.PRES.FileLength</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.COMMETLineOfCode</class>
<id>fr.cnes.icode.fortran77.rules.COMMETLineOfCode</id>
<name>COM.MET.LineOfCode</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments</class>
<id>fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments</id>
<name>COM.FLOW.CheckArguments</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified</class>
<id>fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified</id>
<name>COM.MET.ComplexitySimplified</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit</class>
<id>fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit</id>
<name>F77.DESIGN.LogicUnit</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.COMMETRatioComment</class>
<id>fr.cnes.icode.fortran77.rules.COMMETRatioComment</id>
<name>COM.MET.RatioComment</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.COMPRESData</class>
<id>fr.cnes.icode.fortran77.rules.COMPRESData</id>
<name>COM.PRES.Data</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
<check>
<class>fr.cnes.icode.fortran77.rules.F77FILEHeader</class>
<id>fr.cnes.icode.fortran77.rules.F77FILEHeader</id>
<name>F77.FILE.Header</name>
<languageId>fr.cnes.icode.fortran77</languageId>
</check>
</checkers>
163 changes: 163 additions & 0 deletions fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/************************************************************************************************/
/* i-Code CNES is a static code analyzer. */
/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */
/* http://www.eclipse.org/legal/epl-v10.html */
/************************************************************************************************/
/***************************************************************************************/
/* This file is used to generate a rule checker for COM.FLOW.CheckArguments rule.*/
/* For further information on this, we advise you to refer to RNC manuals. */
/* As many comments have been done on the ExampleRule.lex file, this file */
/* will restrain its comments on modifications. */
/* */
/***************************************************************************************/
package fr.cnes.icode.fortran77.rules;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.File;
import java.util.List;
import java.util.LinkedList;
import fr.cnes.icode.data.AbstractChecker;
import fr.cnes.icode.data.CheckResult;
import fr.cnes.icode.exception.JFlexException;
%%
%class COMFLOWCheckArguments
%extends AbstractChecker
%public
%column
%line
%ignorecase
%function run
%yylexthrow JFlexException
%type List<CheckResult>
%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, ARGUMENTS_DEF
COMMENT_WORD = \! | c | C | \*
PROCEDURES = PROCEDURE | procedure | SUBROUTINE | subroutine | FUNCTION | function
PROG = PROGRAM | program
MOD = MODULE | module
INTER = INTERFACE | interface
TYPE = {PROG} | {MOD} | {INTER}
VAR = [a-zA-Z][a-zA-Z0-9\_]*
STRING = \'[^\']*\' | \"[^\"]*\"
SPACE = [\ \r\t\f]
END = END | end
INITARG = \(
FINARG = \)
COMA = \,

%{
String location = "MAIN PROGRAM";
private String parsedFileName;
int arguments = 1;
boolean procStarted = false;
boolean nameRead = false;

public COMFLOWCheckArguments(){
}

@Override
public void setInputFile(final File file) throws FileNotFoundException {
super.setInputFile(file);
this.parsedFileName = file.toString();
this.zzReader = new FileReader(new File(file.getAbsolutePath()));
}

private void checkArgumentsProcedure() {
if(procStarted && arguments > 5) {
this.setError(location,"This procedure contains more than 5 arguments: " + arguments, yyline+1);
}
procStarted = false;
nameRead = false;
}

%}
%eofval{
return getCheckResults();
%eofval}
%eofclose
%%
/************************/

/************************/
/* COMMENT STATE */
/************************/
<COMMENT>
{
\n {yybegin(NEW_LINE);}
. {}
}
/************************/
/* AVOID STATE */
/************************/
<AVOID> \n {yybegin(NEW_LINE);}
<AVOID> . {}
/************************/
/* NAMING STATE */
/************************/
<NAMING>
{
{VAR} {yybegin(AVOID);}
\n {yybegin(NEW_LINE);}
. {}
}
/************************/
/* YYINITIAL STATE */
/************************/
<YYINITIAL>
{
{COMMENT_WORD} {yybegin(COMMENT);}
{STRING} {yybegin(LINE);}
{TYPE} {yybegin(NAMING);}
{END} {yybegin(AVOID);}
{PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);}
{SPACE} {}
\n {yybegin(NEW_LINE);}
. {yybegin(LINE);}
}
/************************/
/* ARGUMENTS_DEF STATE */
/************************/
<ARGUMENTS_DEF>
{
{VAR} {if(!nameRead) {location = location + " " + yytext(); nameRead = true;}}
{INITARG} {arguments = 1;}
{COMA} {arguments++;}
{FINARG} {checkArgumentsProcedure(); yybegin(AVOID);}
\n {if(procStarted == false) yybegin(NEW_LINE);}
. {}
}
/************************/
/* NEW_LINE STATE */
/************************/
<NEW_LINE>
{
{COMMENT_WORD} {yybegin(COMMENT);}
{STRING} {yybegin(LINE);}
{TYPE} {yybegin(NAMING);}
{END} {yybegin(AVOID);}
{PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);}
{SPACE} {}
\n {yybegin(NEW_LINE);}
. {yybegin(LINE);}
}
/************************/
/* LINE STATE */
/************************/
<LINE>
{
{COMMENT_WORD} {}
{STRING} {}
{TYPE} {yybegin(NAMING);}
{END} {yybegin(AVOID);}
{PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);}
{VAR} {}
\n {yybegin(NEW_LINE);}
. {}
}
/************************/
/* ERROR STATE */
/************************/
[^] {

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn);
}
154 changes: 154 additions & 0 deletions fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/************************************************************************************************/
/* i-Code CNES is a static code analyzer. */
/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */
/* http://www.eclipse.org/legal/epl-v10.html */
/************************************************************************************************/
/********************************************************************************************/
/* This file is used to generate a rule checker for COM.MET.ComplexitySimplified rule. */
/* For further information on this, we advise you to refer to RNC manuals. */
/* As many comments have been done on the ExampleRule.lex file, this file */
/* will restrain its comments on modifications. */
/* */
/********************************************************************************************/
package fr.cnes.icode.fortran77.rules;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.File;
import java.util.List;
import java.util.LinkedList;
import fr.cnes.icode.data.AbstractChecker;
import fr.cnes.icode.data.CheckResult;
import fr.cnes.icode.exception.JFlexException;
%%
%class COMMETComplexitySimplified
%extends AbstractChecker
%public
%column
%line
%function run
%yylexthrow JFlexException
%type List<CheckResult>
%state COMMENT, NAMING, NEW_LINE, LINE, AVOID
COMMENT_WORD = \! | c | C | \*
FUNC = FUNCTION | function
PROC = PROCEDURE | procedure
SUB = SUBROUTINE | subroutine
PROG = PROGRAM | program
MOD = MODULE | module
INTER = INTERFACE | interface
TYPE = {PROG} | {MOD} | {INTER}
PROCEDURES = {FUNC} | {PROC} | {SUB}
UNION = \.AND\. | \.and\. | \.OR\. | \.or\.
CICLO = DO | do | IF | if | ELSE[\ ]*IF | else[\ ]*if
CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do
VAR = [a-zA-Z][a-zA-Z0-9\_]*
END = END | end
STRING = \'[^\']*\' | \"[^\"]*\"

%{
String location = "MAIN PROGRAM";
private String parsedFileName;
int numCyclomatic = 1;
int procedureLine = 0;

public COMMETComplexitySimplified(){
}

@Override
public void setInputFile(final File file) throws FileNotFoundException {
super.setInputFile(file);
this.parsedFileName = file.toString();
this.zzReader = new FileReader(new File(file.getAbsolutePath()));
}

private void checkTotalComplexity() {
if(numCyclomatic > 20 ) {
setError(location,"The cyclomatic complexity of this function is more than 20: " +numCyclomatic, procedureLine+1);
}
}

%}
%eofval{
return getCheckResults();
%eofval}
%eofclose
%%
/************************/

/************************/
/* COMMENT STATE */
/************************/
<COMMENT>
{
\n {yybegin(NEW_LINE);}
. {}
}
/************************/
/* AVOID STATE */
/************************/
<AVOID> \n {yybegin(NEW_LINE);}
<AVOID> . {}
/************************/
/* NAMING STATE */
/************************/
<NAMING>
{
{VAR} {location = location + " " + yytext(); yybegin(AVOID);}
\n {yybegin(NEW_LINE);}
. {}
}
/************************/
/* YYINITIAL STATE */
/************************/
<YYINITIAL>
{
{COMMENT_WORD} {yybegin(COMMENT);}
{STRING} {yybegin(LINE);}
{TYPE} {yybegin(AVOID);}
{PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);}
\n {yybegin(NEW_LINE);}
. {yybegin(LINE);}
}
/************************/
/* NEW_LINE STATE */
/************************/
<NEW_LINE>
{
{COMMENT_WORD} {yybegin(COMMENT);}
{STRING} {yybegin(LINE);}
{TYPE} {yybegin(AVOID);}
{PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);}
{CICLO} {numCyclomatic++; yybegin(LINE);}
{UNION} {numCyclomatic++; yybegin(LINE);}
{CLOSING} {yybegin(LINE);}
{END} {checkTotalComplexity();}
{VAR} {yybegin(LINE);}
\n {}
. {yybegin(LINE);}
}
/************************/
/* LINE STATE */
/************************/
<LINE>
{
{COMMENT_WORD} {yybegin(COMMENT);}
{STRING} {}
{TYPE} {yybegin(AVOID);}
{PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);}
{CICLO} {numCyclomatic++;}
{UNION} {numCyclomatic++;}
{CLOSING} {}
{END} {checkTotalComplexity();}
{VAR} {}
\n {yybegin(NEW_LINE);}
. {}
}
/************************/
/* ERROR STATE */
/************************/
[^] {

final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format.";
throw new JFlexException(this.getClass().getName(), parsedFileName,
errorMessage, yytext(), yyline, yycolumn);
}
Loading

0 comments on commit f7bf365

Please sign in to comment.