Coder Social home page Coder Social logo

cnescatlab / i-codecnes Goto Github PK

View Code? Open in Web Editor NEW
61.0 61.0 16.0 34.91 MB

i-Code CNES is a static code analysis tool to help developpers write code compliant with CNES coding rules.

License: Eclipse Public License 1.0

Java 1.80% Forth 0.02% Fortran 95.45% Lex 2.72% D 0.01% Shell 0.01% Batchfile 0.01% C 0.01%
analysis bash developpers-write fortran77 fortran90 icode-cnes metrics shell violations

i-codecnes's People

Contributors

begarco avatar brigittehuynh avatar diegorodriguez31 avatar dupuisa avatar furmanc avatar louisjdmartin avatar opcoach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

i-codecnes's Issues

Out of bound arrays in Lex files

In some of the lex files, array are being used without verifying the size allocated to it. This might cause index out of bound errors.

Fortran 77

Metrics

  • F77METComplexitySimplified.lex
  • F77METLineOfCode.lex
  • F77METNesting.lex
  • F77METRatioComment.lex

Rules

  • COMDATAFloatCompare.lex
  • COMDATAInitialisation.lex
  • COMDATAInvariant.lex
  • COMDATALoopCondition.lex
  • COMDATANotUsed.lex
  • COMDESIGNActiveWait.lex
  • COMDESIGNAlloc.lex
  • COMFLOWAbort.lex
  • COMFLOWBooleanExpression.lex
  • COMFLOWCheckCodeReturn.lex
  • COMFLOWCheckUser.lex
  • COMFLOWExit.lex
  • COMFLOWExitLoop.lex
  • COMFLOWFileExistence.lex
  • COMFLOWFilePath.lex
  • COMINSTBoolNegation.lex
  • COMINSTBrace.lex
  • COMINSTCodeComment.lex
  • COMINSTGoTo.lex
  • COMINSTLoopCondition.lex
  • COMNAMEHomonymy.lex
  • COMPRESIndent.lex
  • COMPRESLengthLine.lex
  • COMPROJECTHeader.lex
  • COMTYPEExpression.lex
  • F77BLOCCommon.lex
  • F77BLOCElse.lex
  • F77BLOCFunction.lex
  • F77BLOCLoop.lex
  • F77DATAArray.lex
  • F77DATACommon.lex
  • F77DATADouble.lex
  • F77DATAInitialisation.lex
  • F77DATAIO.lex
  • F77DATALoopDO.lex
  • F77DATAParameter.lex
  • F77ERROpenRead.lex
  • F77INSTAssign.lex
  • F77INSTDimension.lex
  • F77INSTEquivalence.lex
  • F77INSTFunction.lex
  • F77INSTIf.lex
  • F77INSTInclude.lex
  • F77INSTPause.lex
  • F77INSTReturn.lex
  • F77INSTSave.lex
  • F77METLine.lex
  • F77NAMEGenericIntrinsic.lex
  • F77NAMEIntrinsic.lex
  • F77NAMEKeyWords.lex
  • F77NAMELabel.lex
  • F77PROTODeclaration.lex
  • F77REFIO.lex
  • F77REFOpen.lex
  • F77REFParameter.lex
  • F77TYPEBasic.lex
  • F77TYPEHollerith.lex

Fortran 90

Metrics

  • F90METComplexitySimplified.lex
  • F90METLineOfCode.lex
  • F90METNesting.lex
  • F90METRatioComment.lex

Rules

  • COMDATAFloatCompare.lex
  • COMDATAInitialisation.lex
  • COMDATAInvariant.lex
  • COMDATALoopCondition.lex
  • COMDATANotUsed.lex
  • COMDESIGNActiveWait.lex
  • COMDESIGNAlloc.lex
  • COMFLOWAbort.lex
  • COMFLOWBooleanExpression.lex
  • COMFLOWCaseSwitch.lex
  • COMFLOWCheckCodeReturn.lex
  • COMFLOWCheckUser.lex
  • COMFLOWExit.lex
  • COMFLOWExitLoop.lex
  • COMFLOWFileExistence.lex
  • COMFLOWFilePath.lex
  • COMFLOWRecursion.lex
  • COMINSTBoolNegation.lex
  • COMINSTBrace.lex
  • COMINSTCodeComment.lex
  • COMINSTGoTo.lex
  • COMINSTLine.lex
  • COMINSTLoopCondition.lex
  • COMNAMEHomonymy.lex
  • COMPRESIndent.lex
  • COMPRESLengthLine.lex
  • COMPROJECTHeader.lex
  • COMTYPEExpression.lex
  • F90BLOCFile.lex
  • F90DATAArray.lex
  • F90DATAArrayAccess.lex
  • F90DATAConstant.lex
  • F90DATAConstantFloat.lex
  • F90DATADeclaration.lex
  • F90DATAFloat.lex
  • F90DATAParameter.lex
  • F90DESIGNFree.lex
  • F90DESIGNInclude.lex
  • F90DESIGNInterface.lex
  • F90DESIGNIO.lex
  • F90DESIGNObsolete.lex
  • F90DESIGNObsoleteArithmeticalIf.lex
  • F90DESIGNObsoleteDoEnding.lex
  • F90DESIGNObsoleteDoReal.lex
  • F90DESIGNObsoleteDoShared.lex
  • F90ERRAllocate.lex
  • F90ERROpenRead.lex
  • F90INSTAssociated.lex
  • F90INSTEntry.lex
  • F90INSTEquivalence.lex
  • F90INSTIf.lex
  • F90INSTIntent.lex
  • F90INSTNullify.lex
  • F90INSTOnly.lex
  • F90INSTOperator.lex
  • F90INSTPointer.lex
  • F90NAMEGenericIntrinsic.lex
  • F90NAMEKeyWords.lex
  • F90PROTOOverload.lex
  • F90REFArray.lex
  • F90REFInterface.lex
  • F90REFLabel.lex
  • F90REFOpen.lex
  • F90REFVariable.lex
  • F90TYPEDerivate.lex
  • F90TYPEInteger.lex
  • F90TYPEReal.lex

Shell

Metrics

  • SHMETComplexitySimplified.lex
  • SHMETLineOfCode.lex
  • SHMETNesting.lex
  • SHMETRatioComment.lex

Rules

  • COMDATAInitialisation.lex
  • COMDATAInvariant.lex
  • COMDATALoopCondition.lex
  • COMDATANotUsed.lex
  • COMDESIGNActiveWait.lex
  • COMFLOWAbort.lex
  • COMFLOWBooleanExpression.lex
  • COMFLOWCaseSwitch.lex
  • COMFLOWExit.lex
  • COMFLOWExitLoop.lex
  • COMFLOWFileExistence.lex
  • COMFLOWFilePath.lex
  • COMFLOWRecursion.lex
  • COMINSTBoolNegation.lex
  • COMINSTBrace.lex
  • COMINSTCodeComment.lex
  • COMINSTLine.lex
  • COMINSTLoopCondition.lex
  • COMNAMEHomonymy.lex
  • COMPRESHeader.lex
  • COMPRESIndent.lex
  • COMPRESLengthLine.lex
  • COMTYPEExpression.lex
  • SHDATAIFS.lex
  • SHDATAInteger.lex
  • SHDESIGNBash.lex
  • SHDESIGNOptions.lex
  • SHERRHelp.lex
  • SHERRNoPipe.lex
  • SHERRString.lex
  • SHFLOWCheckArguments.lex
  • SHFLOWCheckCodeReturn.lex
  • SHFLOWCheckUser.lex
  • SHINSTBasename.lex
  • SHINSTContinue.lex
  • SHINSTFind.lex
  • SHINSTGetOpts.lex
  • SHINSTInterpreter.lex
  • SHINSTKeywords.lex
  • SHINSTLogical.lex
  • SHINSTPOSIX.lex
  • SHINSTSetShift.lex
  • SHINSTVariables.lex
  • SHIORedirect.lex
  • SHMETLimitAWK.lex
  • SHMETLimitSed.lex
  • SHMETPipeLine.lex
  • SHREFExport.lex
  • SHSYNCSignals.lex

Remove warning 'locally units have been used' during maven build

During build we get this message :

[WARNING] The following locally built units have been used to resolve project dependencies:

This is due to the usage of static versions in MANIFEST.MF and pom.xml. Instead of using 2.0.0 we should use 2.0.0.qualifier in Manifest and 2.0.0-SNAPSHOT in pom files

Interface for export should be enhanced

The IExport interface is :

public void export(List checkResults, File outputFile) throws IOException

It should define additional constants like : AUTHOR, DATE, EXPORT_NAME, etc... to be used in the export implementations.

An additional optional parameter map should be added as an additional parameter

public void export(List checkResults, File outputFile, Map<String, String> param)

Externalize exports

Inventory

Currently i-Code UI plugin is responsible of the analysis results export, the export code is included the ViolationsView and MetricsView for each formats available and the user must use dedicated Wizards hardcoded to run an export.
This design causes difficulties to add any new export format into i-Code.

Enhancement

We would like to use a dedicated and externalized export plugin to export lists of Violation and FileValue objects in some different formats plugged to the export plugin. It implies to also externalize the XML and CSV exports into two dedicated plugins.

Also, we would like also the code to be evolutionary enough to prepare i-Code import feature and include it in the modifications.

This imply both to manage :

  • The creation of a plugin dependant only of the analyzer for the analysis, and it's plugin to export in different formats
  • Modify UI to be able to use this exports

⚠️ Warning : This enhancement intended to the version 3.0 is part dependant of #16 issue progress as the Violation and FileValue classes exported in the future dedicated plugins might be merged in a common class.

[SHELL] Variable regular expression and handling

Problem

In most of the Shell analyzers, variables are defined by regular expressions which aren't handling some case like expanded variables. Regular expressions should be redefined to include all variables.

plugin fr.cnes.analysis.tools.analyzer should not depend on org.eclipse.ui

This plugin is a core plugin without any UI concerns.

It must absolutely not depend on org.eclipse.ui. If we remove this dependency there is only one error on : PlatformUI.getPreferenceStore() to get ANALYZER_EP_CONTRIBUTOR_CHECK_ID.

It is better to use the IEclipsePreferenceService class like this (example found in FileHelper.class) :

	String defaultLineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME,
			Platform.PREF_LINE_SEPARATOR, platformDefaultLineDelimiter, null);

Limitation : Lex rules can parse only one file by analysis.

⚠️ The method setInputFile(File file) of lexical files must be restricted to only one file.
It would have been possible to reset the reader and all attributes of the class to solve this problematic however i-Code CNES is currently using multi-threading to run each files analysis by a rule concurrently.

Must create a 'language' extension point

Analyzer are defining file extensions that are duplicated for instance for f77.metric and f77.rule.

It would be easier to have :

  • a 'language' extension point that contains : Id, name and expected file extensions
  • analyzer refer to language ref ID (use language/@id for refID).

Then a kind of LanguageUtil class could find the language for a file or give the existing analyzer for a language...

Id for extension point should be simplified

In the plugin.xml tools.analyzer for instance we have :

This is an old usage. When an extension point is created the ID and the name can be the same.

It should be :

even if in the code we still use 'fr.cnes.analysis.tools.analyzer'

Should use this naming convention also for the previous issue #32 about language extension point

Simplification of the analyzer

Inventory

Currently i-Code Analyzer is designed to run an analysis with :

  • A list of IPath to run the analysis on;
  • A configuration based on the plugin preferences;
    It's is also using IPath in it's Violation & FileValue objects returned by the analysis.

Enhancement

We would like to improve it to be able to run an analysis on non-eclipse based thirds, and retrieving only one list of results instead of returning a List<Violation> and a List<FileValue>. This imply to have a common object for both metrics and violations analysis's result and should be realized with a fusion of the two analysis which are independant for now.

Add a quick access button to run analysis

Currently, running an analysis is accessible only from the menu ** i-Code CNES > Check Code **. A new button should be added directly with an icon to run the analysis similar to the Eclipse's run button.

The export extension point should also provide the parameters

It could be a good idea to manage the parameters in the extension point definition rather than in the code with a 'hasParameters' method to be implemented (without providing a method to know what are the parameters...).

Actually parameters are guessed by calling 'getParameters', if they have been initialized in the exporter's constructor.

If the exporter extension point provides the parameter definition, in its schema, it would be easier to manage them and to define the comment for each. A parameter could contain : name, required/optional, description, ....

Then this list of parameters can be reused to initialize the export wizard and to initialize properly the expected parameters list for export...

This issue concerns also importers when they will be defined.

Using ImageFactory class to access Image or ImageDescriptor in the UI plug-in

Although the ImageFactory class was added to put images in preferences pages complying the new extension points created in #33 issues, some class are still reaching images in resources folder by their file path which might cause evolution problem.

All images and resources pictures should be accessed thanks to the ImageFactory class.

Preferences page's table viewer do not refresh it's checkbox

When changing configuration, the checkbox of the rules and of the table aren't updated and keep their old status while the checker is being enabled.

This should be fixed to let the user aknowledge configuration chosen when applying the configuration.

Export crash

XML export is craching (nullpointerException)
Map "parameters" in CheckerFileCreationExportWizardPage is not initialized and not set with user values in ExportXml.

Lex files should throw more informative exception on failure

Currently, annalysis failure result by throwing a JFlexException, however :

  • Some lex do not relate any message with the exception;
  • Some of the message included in the exception are not informative;
  • In case a file is badly encoded for the parser, it's impossible to be known by the user.

Metrics view improvement

The metrics view is difficult to read because it's both too colorfull and not informative enough.

This view should be edited to show severity set on the metric and also to show if the metric was violated or not.

Errors on function's locations

Some functions locations in lex files (except metrics) is not defined correctly, this is especially the case for :

  • Nested functions;
  • Main program function after a function was declared.

Clean metric's view abstract class

In the version 1.0, both ViolationView and MetricsView were both extending the same class which was extending manifold classes making views editing and independencies difficult. ViolationView was edited to not use it anymore however MetricsView which is independent of any other view is still extending numerous abstract classes instead of ViewPart.

This class should be edited to limit complexity of the MetricsView and clarify the architecture of the plug-in UI.

[SHELL] Do not ignore case in lex files

Some of the Shell's lex files contains %ignorecase parameter which make the parser identifying regular expression ignoring the case while the case must be active on shell.

Shell metrics

The following metrics should be corrected to be available in version 3.0 :

  • SH.MET.ComplexitySimplified
  • SH.MET.LineOfCode
  • SH.MET.Nesting
  • SH.MET.RatioComment

Function declaration not handled

Problem

For shell languages, it's possible to declare a new function by several ways. However, some analyzers require the shell function to be declared with the keyword function before the function's name while it's optional.

How to fix

Adding a new transition FUNCT to handle this declaration independantly to the keyword one on function declaration to retrieve function's name.

Also, make FUNCT identifier using FNAME identifier as function's name instead of VAR one.

Fix status

  • COM.DATA.LoopCondition (FUNCT declarations handling)
  • COM.DESIGN.ActiveWait (FUNCT declarations handling)
  • COM.FLOW.Abort (FUNCT declarations handling)
  • COM.FLOW.CaseSwitch (FUNCT declarations handling)
  • All rules : Verify FUNCT identifier to comply with FNAME.

Versioned checkstyle configuration file

In some project, the presence of .checkstyle which is dependent of user's configuration is versioned in git. This configuration file shouldn't be included in the project.

Analyzers should handle more files extensions

Inventory

In it's version 2.0, i-Code CNES analyzers are running analysis for the following files extensions :

  • fr.cnes.analysis.tools.fortran77.analyzer : .f
  • fr.cnes.analysis.tools.fortran90.analyzer : .f90
  • fr.cnes.analysis.tools.shell.analyzer : .sh, .bash, .ksh

Evolution

The different standard of fortran 77[1][2], fortran 90[3], and Shell[4] do not define file extensions, however following the gfortran[5] & PGI Fortran[6] compilers documentation, and CNES-RNC-SHELL Rule SH.DESIGN.Bash, the following files extensions should be defined :

  • fr.cnes.analysis.tools.fortran77.analyzer : .f, .for, .fpp, .ftn, .F, .FOR, .FPP,.FTN
  • fr.cnes.analysis.tools.fortran90.analyzer : .f90, .F90
  • fr.cnes.analysis.tools.shell.analyzer : .sh, .bash, .ksh

[1]Departement of Defense Military standard for Fortran 77 : ftp://ftp.nag.co.uk/sc22wg5/ARCHIVE/mil_std_1753.html
[2]Fortran 77 ISO Standard
[3]Fortran 90 ISO Standard : ftp://ftp.nag.co.uk/sc22wg5/N001-N1100/N692.pdf
[4]IEEE Std 1003.1
[5]gfortran documentation
[6]PGI Fortran 77 documentation
[6bis]PGI Fortran 90 documentation

Import/Export class names are really confusing

The names for export management are confusing. We have :

  • Export : the service to select the right IExport instance or the right IImport instance
  • IExport : the interface to be implemented to export
  • ExportXML : an implementation of IExport
  • ExportCSV : another implementation of Export
  • IImport : the interface to be implemented to import but actually never implemented...

These names would be more convenient :

  • IExportService : the interface for the export service -> should provide minimal interface to export
  • IImportService : the same for import
  • ExportService (internal), our implementation to export by reading extension points
  • ImportService (internal) the same for import
  • IExporter : the interface to be implemented for an exporter
  • ExporterXML : the XML implementation for XML (implements IExporter)
  • ExporterCSV : the CVS implementation for CSV (implements Exporter)
  • ImporterXML : the XML implementation for XML import
    ...

If we use the pure E4 injection context, we will provide both services in the context. If we still use E3 development, we will provide a singleton in services to get the default implementation. For instance : IExportService.getDefault() will return the internal implementation or better, the ExportService is declared in an OSGi component file. This will simplify also the tests if we want to provide other importer/exporter.

JFlex code generation for shell project works only with flex 1.4.3

JFlex is used to generate java code in *rules and *metrics project.

The default version used for f77 and f90 projects is flex 1.6.1. Unfortunately this version can not be used once for all projects.

The shell project must be updated to use the 1.6.1 jflex version and the jflex1.4.1 can then be removed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.