Skip to content

Commit 4c5aa48

Browse files
Merge pull request #82 from cnescatlab/feature/shell-separation
Remove shell from Icode plugin
2 parents c43db80 + d77742d commit 4c5aa48

27 files changed

+425
-1510
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ buildNumber.properties
2828

2929
# Ignore IntelliJ files
3030
.idea
31-
*.iml
31+
*.iml
32+
.vscode

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
SonarQube plugin for the code analysis tool: i-Code CNES.
99

10-
SonarQube is an open platform to manage code quality. This plugin adds the ability to check Fortran (77 & 90) & Shell with i-Code or import pre-existing results of i-Code.
10+
SonarQube is an open platform to manage code quality. This plugin adds the ability to check Fortran (77 & 90) with i-Code or import pre-existing results of i-Code.
1111

1212
This plugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
1313

14-
You can get i-Code CNES on GitHub: [lequal/i-CodeCNES](https://github.com/lequal/i-CodeCNES).
14+
You can get i-Code CNES on GitHub: [cnescatlab/i-CodeCNES](https://github.com/cnescatlab/i-CodeCNES).
1515

1616
### Quickstart
1717
- Setup a SonarQube instance.
18-
- **[Optional]** Install i-Code command line application as described in [official documentation](https://github.com/lequal/i-CodeCNES/wiki/Installation-Manual).
18+
- **[Optional]** Install i-Code command line application as described in [official documentation](https://github.com/cnescatlab/i-CodeCNES/wiki/Installation-Manual).
1919
- Install `sonaricode-*.jar` in `<SONARQUBE_HOME>/extensions/plugins/`.
2020
- **[Optional]** Run i-Code manually or configure auto-launch in plugin configuration.
2121
- Run an analysis with *sonar-scanner*, *maven*, *gradle*, *msbuild*, etc.
@@ -33,30 +33,28 @@ Here is the compatibility matrix of the plugin:
3333
| 2.0.2 | 4.1.0 | 7.9 -> 8.2 |
3434

3535
#### Run i-Code manually
36-
If you need help to run i-Code please refer to the [official user manual](https://github.com/lequal/i-CodeCNES/wiki/User-Manual) or [i-Code issue tracker](https://github.com/lequal/i-CodeCNES/issues).
36+
If you need help to run i-Code please refer to the [official user manual](https://github.com/cnescatlab/i-CodeCNES/wiki/User-Manual) or [i-Code issue tracker](https://github.com/cnescatlab/i-CodeCNES/issues).
3737

3838
#### Run a specific i-Code version through sonaricode plugin
3939
If embedded version of i-Code does not match your need, you can set the execution of another installed version of i-Code through the following properties:
4040
- `sonar.icode.launch`: Activate autolaunch for i-Code if `true`. Default: `false`.
4141
- `sonar.icode.path`: Define i-Code CNES executable path to auto-launch it on analysis. Default: `${HOME}/icode-cnes/icode.exe`.
4242

4343
#### Other plugin's properties
44-
- `sonar.icode.shell.file.suffixes`: List of suffixes for Shell files to analyze. Default: `.sh,.ksh,.bash`.
4544
- `sonar.icode.f77.file.suffixes`: List of suffixes for F77 files to analyze. Default: `.f,.f77,.for,.fpp,.ftn,.F,.F77,.FOR,.FPP,.FTN`.
4645
- `sonar.icode.f90.file.suffixes`: List of suffixes for F90 files to analyze. Default: `.f90,.F90`.
4746
- `sonar.icode.reports.path`: Path to the i-Code reports. Multiple path can be provided. Default: `result.res`.
4847

4948
### Features
5049
- Fortran 77 analysis
5150
- Fortran 90 analysis
52-
- Shell analysis
5351
- Import i-Code results
5452

5553
#### Get i-Code help
5654
Use `icode -h` to get the following help about i-Code:
5755
````
5856
usage: icode [<FILE> [...]] [-c <arg>] [-e] [-f <arg>] [-h] [-l] [-o <arg>] [-p <arg>] [-q <arg>] [-r] [-x <arg>]
59-
Analyze Shell, F77 & F90 code to find defects & bugs.
57+
Analyze F77 & F90 code to find defects & bugs.
6058
6159
-c,--checked-languages <arg> Comma separated list of languages checked during analysis. All by default.
6260
-e,--exporters Display all available exporters.
@@ -70,20 +68,20 @@ Analyze Shell, F77 & F90 code to find defects & bugs.
7068
-r,--rules Display all available rules.
7169
-x,--excluded-rules <arg> Comma separated list of rules id to exclude from analysis. None by default.
7270
73-
Please report issues at https://github.com/lequal/i-CodeCNES/issues
71+
Please report issues at https://github.com/leqcnescatlabual/i-CodeCNES/issues
7472
````
7573

7674
### How to contribute
7775
If you experienced a problem with the plugin please open an issue. Inside this issue please explain us how to reproduce this issue and paste the log.
7876

7977
If you want to do a PR, please put inside of it the reason of this pull request. If this pull request fix an issue please insert the number of the issue or explain inside of the PR how to reproduce this issue.
8078

81-
All details are available in [CONTRIBUTING](https://github.com/lequal/sonar-icode-cnes-plugin/CONTRIBUTING.md).
79+
All details are available in [CONTRIBUTING](https://github.com/cnescatlab/sonar-icode-cnes-plugin/blob/master/CONTRIBUTING.md).
8280

8381
### Feedback and Support
8482
8583

86-
Bugs and Feature requests: https://github.com/lequal/sonar-icode-cnes-plugin/issues
84+
Bugs and Feature requests: https://github.com/cnescatlab/sonar-icode-cnes-plugin/issues
8785

8886
### License
8987
Licensed under the [GNU General Public License, Version 3.0](https://www.gnu.org/licenses/gpl.txt)

pom.xml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<groupId>fr.cnes.sonar.plugins</groupId>
77
<artifactId>sonar-icode-cnes-plugin</artifactId>
88
<packaging>sonar-plugin</packaging>
9-
<version>2.0.2</version>
9+
<version>3.0.0-SNAPSHOT</version>
1010

1111
<name>Sonar i-Code CNES plugin</name>
1212

1313
<description>i-Code CNES plugin for SonarQube</description>
14-
<url>https://github.com/lequal/sonar-icode-cnes-plugin</url>
14+
<url>https://github.com/cnescatlab/sonar-icode-cnes-plugin</url>
1515
<inceptionYear>2017</inceptionYear>
1616

1717
<licenses>
@@ -24,7 +24,7 @@
2424

2525
<organization>
2626
<name>CNES</name>
27-
<url>http://cnes.fr</url>
27+
<url>https://cnes.fr</url>
2828
</organization>
2929

3030
<developers>
@@ -61,12 +61,12 @@
6161
<commons-lang.version>3.7</commons-lang.version>
6262
<gson.version>2.8.2</gson.version>
6363
<slf4j.version>1.7.25</slf4j.version>
64-
<junit.version>4.12</junit.version>
64+
<junit.version>4.13.2</junit.version>
6565
<jacoco.version>0.8.4</jacoco.version>
6666
<sonar.pluginKey>icode</sonar.pluginKey>
6767
<sonar.pluginClass>fr.cnes.sonar.plugins.icode.ICodePlugin</sonar.pluginClass>
68-
<sonar.pluginUrl>https://github.com/lequal/sonar-icode-cnes-plugin</sonar.pluginUrl>
69-
<sonar.pluginSourcesUrl>https://github.com/lequal/sonar-icode-cnes-plugin</sonar.pluginSourcesUrl>
68+
<sonar.pluginUrl>https://github.com/cnescatlab/sonar-icode-cnes-plugin</sonar.pluginUrl>
69+
<sonar.pluginSourcesUrl>https://github.com/cnescatlab/sonar-icode-cnes-plugin</sonar.pluginSourcesUrl>
7070
<sonar.pluginOrganizationName>CNES</sonar.pluginOrganizationName>
7171
<sonar.sources>src/main/java</sonar.sources>
7272
<sonar.test>src/test/java</sonar.test>
@@ -106,7 +106,6 @@
106106
<dependency>
107107
<groupId>junit</groupId>
108108
<artifactId>junit</artifactId>
109-
<version>${junit.version}</version>
110109
<scope>test</scope>
111110
</dependency>
112111
<dependency>
@@ -118,7 +117,7 @@
118117
<dependency>
119118
<groupId>com.thoughtworks.xstream</groupId>
120119
<artifactId>xstream</artifactId>
121-
<version>1.4.11.1</version>
120+
<version>1.4.18</version>
122121
</dependency>
123122
</dependencies>
124123

@@ -214,4 +213,15 @@
214213

215214
</plugins>
216215
</build>
216+
217+
218+
<dependencyManagement>
219+
<dependencies>
220+
<dependency>
221+
<groupId>junit</groupId>
222+
<artifactId>junit</artifactId>
223+
<version>${junit.version}</version>
224+
</dependency>
225+
</dependencies>
226+
</dependencyManagement>
217227
</project>

src/main/java/fr/cnes/sonar/plugins/icode/ICodePlugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import fr.cnes.sonar.plugins.icode.languages.Fortran77Language;
2121
import fr.cnes.sonar.plugins.icode.languages.Fortran90Language;
2222
import fr.cnes.sonar.plugins.icode.languages.ICodeQualityProfiles;
23-
import fr.cnes.sonar.plugins.icode.languages.ShellLanguage;
2423
import fr.cnes.sonar.plugins.icode.measures.ICodeNestingMetric;
2524
import fr.cnes.sonar.plugins.icode.rules.ICodeRulesDefinition;
2625
import fr.cnes.sonar.plugins.icode.settings.ICodePluginProperties;
@@ -39,7 +38,7 @@ public class ICodePlugin implements Plugin {
3938
@Override
4039
public void define(Context context) {
4140
// Setting plugin ICode
42-
context.addExtensions(ShellLanguage.class, Fortran77Language.class, Fortran90Language.class);
41+
context.addExtensions(Fortran77Language.class, Fortran90Language.class);
4342
context.addExtension(ICodeQualityProfiles.class);
4443
context.addExtensions(ICodePluginProperties.getProperties());
4544

src/main/java/fr/cnes/sonar/plugins/icode/check/ICodeSensor.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import fr.cnes.sonar.plugins.icode.exceptions.ICodeException;
2323
import fr.cnes.sonar.plugins.icode.languages.Fortran77Language;
2424
import fr.cnes.sonar.plugins.icode.languages.Fortran90Language;
25-
import fr.cnes.sonar.plugins.icode.languages.ShellLanguage;
2625
import fr.cnes.sonar.plugins.icode.measures.ICodeMetricsProcessor;
2726
import fr.cnes.sonar.plugins.icode.model.AnalysisFile;
2827
import fr.cnes.sonar.plugins.icode.model.AnalysisProject;
@@ -63,6 +62,11 @@ public class ICodeSensor implements Sensor {
6362
*/
6463
private static final Logger LOGGER = Loggers.get(ICodeSensor.class);
6564

65+
/**
66+
* Languages used by I-Code
67+
*/
68+
private final String[] languages = {Fortran77Language.KEY, Fortran90Language.KEY};
69+
6670
/**
6771
* Give information about this sensor.
6872
*
@@ -71,7 +75,7 @@ public class ICodeSensor implements Sensor {
7175
@Override
7276
public void describe(final SensorDescriptor sensorDescriptor) {
7377
// Prevents sensor to be run during all analysis.
74-
sensorDescriptor.onlyOnLanguages(ShellLanguage.KEY, Fortran77Language.KEY, Fortran90Language.KEY);
78+
sensorDescriptor.onlyOnLanguages(languages);
7579

7680
// Defines sensor name
7781
sensorDescriptor.name("Sonar i-Code");
@@ -80,10 +84,11 @@ public void describe(final SensorDescriptor sensorDescriptor) {
8084
sensorDescriptor.onlyOnFileType(InputFile.Type.MAIN);
8185

8286
// This sensor is activated only if a rule from the following repo is activated.
83-
sensorDescriptor.createIssuesForRuleRepositories(
84-
ICodeRulesDefinition.getRepositoryKeyForLanguage(ShellLanguage.KEY),
85-
ICodeRulesDefinition.getRepositoryKeyForLanguage(Fortran77Language.KEY),
86-
ICodeRulesDefinition.getRepositoryKeyForLanguage(Fortran90Language.KEY));
87+
for (String Lang : languages) {
88+
sensorDescriptor.createIssuesForRuleRepositories(
89+
ICodeRulesDefinition.getRepositoryKeyForLanguage(Lang));
90+
}
91+
8792
}
8893

8994
/**
@@ -382,10 +387,12 @@ protected List<File> getReportFiles(final Configuration config, final FileSystem
382387
* @return True if the rule is active and false if not or not exists.
383388
*/
384389
protected boolean isRuleActive(final ActiveRules activeRules, final String rule) {
385-
final RuleKey ruleKeyShell = RuleKey.of(ICodeRulesDefinition.getRepositoryKeyForLanguage(ShellLanguage.KEY), rule);
386-
final RuleKey ruleKeyF77 = RuleKey.of(ICodeRulesDefinition.getRepositoryKeyForLanguage(Fortran77Language.KEY), rule);
387-
final RuleKey ruleKeyF90 = RuleKey.of(ICodeRulesDefinition.getRepositoryKeyForLanguage(Fortran90Language.KEY), rule);
388-
return activeRules.find(ruleKeyShell)!=null || activeRules.find(ruleKeyF77)!=null || activeRules.find(ruleKeyF90)!=null;
390+
boolean isActive = false;
391+
for (String Lang : languages) {
392+
RuleKey ruleKey = RuleKey.of(ICodeRulesDefinition.getRepositoryKeyForLanguage(Lang), rule);
393+
isActive = activeRules.find(ruleKey)!=null || isActive;
394+
}
395+
return isActive;
389396
}
390397

391398
}

src/main/java/fr/cnes/sonar/plugins/icode/languages/ICodeLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.List;
2525

2626
/**
27-
* Declared language i-Code as the parent language for Fortran 77, Fortran 90 & Shell.
27+
* Declared language i-Code as the parent language for Fortran 77, Fortran 90.
2828
*/
2929
public abstract class ICodeLanguage extends AbstractLanguage {
3030

src/main/java/fr/cnes/sonar/plugins/icode/languages/ICodeQualityProfiles.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public final class ICodeQualityProfiles implements BuiltInQualityProfilesDefinit
4444
*/
4545
@Override
4646
public void define(final Context context) {
47-
createBuiltInProfile(context, ShellLanguage.KEY, ICodeRulesDefinition.PATH_TO_SHELL_RULES_XML);
4847
createBuiltInProfile(context, Fortran77Language.KEY, ICodeRulesDefinition.PATH_TO_F77_RULES_XML);
4948
createBuiltInProfile(context, Fortran90Language.KEY, ICodeRulesDefinition.PATH_TO_F90_RULES_XML);
5049
}

src/main/java/fr/cnes/sonar/plugins/icode/languages/ShellLanguage.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/main/java/fr/cnes/sonar/plugins/icode/measures/ICodeMetricsProcessor.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,14 @@ public static void saveMeasure(final SensorContext context, final Map<String, In
7878
if(metricScope.equals(CLASS)) {
7979
// Get i-Code rule id to test if issue must be saved here.
8080
final String metricKey = icodeMeasure.getAnalysisRuleId();
81-
// Take SHELL / F77 / F90 ncloc into account
81+
// Take F77 / F90 ncloc into account
8282
if (metricKey.contains("MET.LineOfCode")) {
8383
saveSonarQubeNewMeasure(context, files, CoreMetrics.NCLOC, icodeMeasure);
8484
}
85-
// Take SHELL / F77 / F90 number of comment lines into account
85+
// Take F77 / F90 number of comment lines into account
8686
else if (metricKey.contains("MET.LineOfComment")) {
8787
saveSonarQubeNewMeasure(context, files, CoreMetrics.COMMENT_LINES, icodeMeasure);
8888
}
89-
// Take SHELL complexity into account
90-
else if (metricKey.contains("SH.MET.ComplexitySimplified")) {
91-
saveSonarQubeNewMeasure(context, files, CoreMetrics.COMPLEXITY, icodeMeasure);
92-
}
9389
}
9490

9591
}
@@ -151,7 +147,7 @@ public static void saveExtraMeasures(final SensorContext context, final Map<Stri
151147
}
152148
}
153149

154-
// Compute nesting for shell and fortran.
150+
// Compute nesting for Fortran.
155151
computeNesting(context, scannedFiles, measures);
156152
// Compute complexity for Fortran.
157153
computeComplexity(context, scannedFiles, measures);
@@ -186,7 +182,7 @@ public static void saveExtraMeasures(final SensorContext context, final Map<Stri
186182
}
187183
}
188184

189-
// Compute nesting for shell and fortran.
185+
// Compute nesting for Fortran.
190186
computeNesting(context, scannedFiles, measures);
191187
// Compute complexity for Fortran.
192188
computeComplexity(context, scannedFiles, measures);

src/main/java/fr/cnes/sonar/plugins/icode/model/XmlHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ public boolean shouldSerializeMember(final Class definedIn, final String fieldNa
5454
}
5555
};
5656
xStream.processAnnotations(cls);
57+
58+
/*
59+
See https://stackoverflow.com/a/67288175 for more informations about this.
60+
In few words, It's a security feature,
61+
We need to explicitly authorize class that uses XStream to avoid unwanted injections.
62+
*/
63+
xStream.allowTypesByWildcard(new String[] {
64+
"fr.cnes.sonar.plugins.icode.model.**",
65+
});
5766
return xStream.fromXML(file);
5867
}
5968

60-
}
69+
}

0 commit comments

Comments
 (0)