Skip to content

Commit 6fbf688

Browse files
authored
Merge pull request #63 from lequal/dev
Release version 2.0.2
2 parents 9e7cc65 + e645a2a commit 6fbf688

32 files changed

+511
-263
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,28 @@ assignees: ''
77

88
---
99

10-
**Describe the bug**
11-
A clear and concise description of what the bug is.
10+
#### Describe the bug
11+
> _A clear and concise description of what the bug is._
1212
13-
**To reproduce**
14-
Steps to reproduce the behavior:
13+
#### To reproduce
14+
> _Steps to reproduce the behavior._
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
1818
4. See error
1919

20-
**Expected behavior**
21-
A clear and concise description of what you expected to happen.
20+
#### Expected behavior
21+
> _A clear and concise description of what you expected to happen._
2222
23-
**Screenshots & log**
24-
If applicable, add screenshots to help explain your problem. Then, append SonarQube and i-Code log and **do not forget to obfuscate them**.
23+
#### Screenshots & log
24+
> _If applicable, add screenshots to help explain your problem. Then, append SonarQube and i-Code log and **do not forget to obfuscate them**._
2525
26-
**User environment (please complete the following information):**
26+
#### User environment
27+
> _Please complete the following information._
2728
- OS: [e.g. Windows 10]
2829
- Java version: [e.g. 1.8]
2930
- i-Code version: [e.g. 3.1.0]
3031
- Plugin version: [e.g. 2.0.0]
3132

32-
**Additional context**
33-
Add any other context about the problem here.
33+
#### Additional context
34+
> _Add any other context about the problem here._

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ assignees: ''
77

88
---
99

10-
**Is your feature request related to a problem? Please describe.**
11-
> A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
10+
#### Is your feature request related to a problem? Please describe.**
11+
> _A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]_
1212
13-
**Describe the solution you'd like**
14-
> A clear and concise description of what you want to happen.
13+
#### Describe the solution you'd like
14+
> _A clear and concise description of what you want to happen._
1515
16-
**Describe alternatives you've considered**
17-
> A clear and concise description of any alternative solutions or features you've considered.
16+
#### Describe alternatives you've considered
17+
> _A clear and concise description of any alternative solutions or features you've considered._
1818
19-
**Additional context**
20-
> Add any other context or screenshots about the feature request here.
19+
#### Additional context
20+
> _Add any other context or screenshots about the feature request here._

.github/ISSUE_TEMPLATE/question.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ assignees: ''
77

88
---
99

10-
> **Before posting a new question, please read the documentation](https://github.com/lequal/i-CodeCNES/wiki) and check [existing issues](https://github.com/lequal/sonar-icode-cnes-plugin/issues)**
10+
> _Before posting a new question, please read the documentation](https://github.com/lequal/i-CodeCNES/wiki) and check [existing issues](https://github.com/lequal/sonar-icode-cnes-plugin/issues)_
1111
12-
**Describe what you need to know**
13-
> A clear and concise description of what your question is.
12+
#### Describe what you need to know
13+
> _A clear and concise description of what your question is._
1414
15-
**Screenshots & log**
16-
> If applicable, add screenshots to help explain your problem. Then, append i-Code log and **do not forget to obfuscate them**.
15+
#### Screenshots & log
16+
> _If applicable, add screenshots to help explain your problem. Then, append i-Code log and **do not forget to obfuscate them**._
1717
18-
**User environment (please complete the following information):**
18+
#### User environment
19+
> _Please complete the following information._
1920
- OS: [e.g. Windows 10]
2021
- Java version: [e.g. 1.8]
2122
- i-Code version: [e.g. 3.1.0]
2223
- Plugin version: [e.g. 2.0.0]
2324

24-
**Additional context**
25+
#### Additional context
2526
Add any other context about the problem here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Proposed changes
22

3-
> Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
3+
> _Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue._
44
55
## Types of changes
66

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ language: java
22
sudo: false
33
install: true
44

5+
os: linux
6+
dist: xenial
7+
58
addons:
69
sonarcloud:
710
organization: "lequal"
811

9-
jdk:
10-
- openjdk8
11-
- openjdk11
12+
jdk: openjdk11
1213

1314
script:
1415
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
@@ -23,13 +24,13 @@ notifications:
2324

2425
deploy:
2526
provider: releases
26-
api_key: "$GITHUB_TOKEN"
27+
token: "$GITHUB_TOKEN"
2728
file_glob: true
2829
file: "target/sonar-icode-cnes-plugin-*.jar"
2930
skip_cleanup: true
30-
name: "Sonar i-Code CNES plugin"
31+
name: "Sonar i-Code CNES plugin version $TRAVIS_TAG"
3132
draft: true
3233
on:
3334
branch: master
3435
tags: true
35-
jdk: 'openjdk11'
36+
jdk: openjdk11

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,25 @@ You can get i-Code CNES on GitHub: [lequal/i-CodeCNES](https://github.com/lequal
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/blob/master/documentation/i-Code%20CNES%20-%20Installation%20Manual%20-%20EN.pdf).
18+
- **[Optional]** Install i-Code command line application as described in [official documentation](https://github.com/lequal/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.
2222

2323
#### Run i-Code automatically
24-
This SonarQube plugin is now able to run automaticcaly an embedded version of i-Code. If you do not specify properties to run i-Code [manually](#run-i-Code-manually) or [from a specific version](#Run-a-specific-i-Code-version-through-sonaricode-plugin), embedded version of i-Code will be executed.
24+
This SonarQube plugin is now able to run automatically an embedded version of i-Code. If you do not specify properties to run i-Code [manually](#run-i-Code-manually) or [from a specific version](#Run-a-specific-i-Code-version-through-sonaricode-plugin), embedded version of i-Code will be executed.
2525

2626
Here is the compatibility matrix of the plugin:
2727

2828
| sonaricode version | embedded i-Code version | supported SonarQube version |
2929
|:------------------:|:-----------------------:|:---------------------------:|
3030
| < 2.0.0 | none | 6.7.x |
31-
| 2.0.0 | 4.0.0 | 7.9 -> 8.1 |
32-
| 2.0.1 | 4.0.0 | 7.9 -> 8.1 |
31+
| 2.0.0 | 4.0.0 | 7.9 -> 8.2 |
32+
| 2.0.1 | 4.0.0 | 7.9 -> 8.2 |
33+
| 2.0.2 | 4.1.0 | 7.9 -> 8.2 |
3334

3435
#### Run i-Code manually
35-
If you need help to run i-Code please refer to the [official user manual](https://github.com/lequal/i-CodeCNES/blob/master/documentation/i-Code%20CNES%20-%20User%20Manual.pdf) 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/lequal/i-CodeCNES/wiki/User-Manual) or [i-Code issue tracker](https://github.com/lequal/i-CodeCNES/issues).
3637

3738
#### Run a specific i-Code version through sonaricode plugin
3839
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:
@@ -77,6 +78,8 @@ If you experienced a problem with the plugin please open an issue. Inside this i
7778

7879
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.
7980

81+
All details are available in [CONTRIBUTING](https://github.com/lequal/sonar-icode-cnes-plugin/CONTRIBUTING.md).
82+
8083
### Feedback and Support
8184
8285

pom.xml

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

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

@@ -22,7 +22,6 @@
2222
</license>
2323
</licenses>
2424

25-
<!-- optional -->
2625
<organization>
2726
<name>CNES</name>
2827
<url>http://cnes.fr</url>
@@ -52,8 +51,8 @@
5251
<properties>
5352
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5453
<jdk.version>1.8</jdk.version>
55-
<jdk.min.version>1.8</jdk.min.version>
56-
<jdk.max.version>1.8</jdk.max.version>
54+
<jdk.min.version>11</jdk.min.version>
55+
<jdk.max.version>11</jdk.max.version>
5756
<maven.compiler.source>1.8</maven.compiler.source>
5857
<maven.compiler.target>1.8</maven.compiler.target>
5958
<sonar.apiVersion>6.7.7</sonar.apiVersion>
@@ -67,6 +66,7 @@
6766
<sonar.pluginKey>icode</sonar.pluginKey>
6867
<sonar.pluginClass>fr.cnes.sonar.plugins.icode.ICodePlugin</sonar.pluginClass>
6968
<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>
7070
<sonar.pluginOrganizationName>CNES</sonar.pluginOrganizationName>
7171
<sonar.sources>src/main/java</sonar.sources>
7272
<sonar.test>src/test/java</sonar.test>
@@ -89,7 +89,7 @@
8989
<dependency>
9090
<groupId>com.github.lequal.i-CodeCNES</groupId>
9191
<artifactId>icode-library</artifactId>
92-
<version>4.0.0</version>
92+
<version>v4.1.0</version>
9393
</dependency>
9494
<dependency>
9595
<groupId>commons-lang</groupId>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
/**
3030
* This class is the entry point for all extensions.
31-
*
32-
* @author lequal
3331
*/
3432
public class ICodePlugin implements Plugin {
3533

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

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import fr.cnes.icode.Analyzer;
2020
import fr.cnes.icode.data.CheckResult;
21-
import fr.cnes.icode.exception.JFlexException;
2221
import fr.cnes.icode.services.languages.LanguageService;
2322
import fr.cnes.sonar.plugins.icode.exceptions.ICodeException;
2423
import fr.cnes.sonar.plugins.icode.languages.Fortran77Language;
@@ -75,7 +74,7 @@ public void describe(final SensorDescriptor sensorDescriptor) {
7574
sensorDescriptor.onlyOnLanguages(ShellLanguage.KEY, Fortran77Language.KEY, Fortran90Language.KEY);
7675

7776
// Defines sensor name
78-
sensorDescriptor.name(getClass().getName());
77+
sensorDescriptor.name("Sonar i-Code");
7978

8079
// Only main files are concerned, not tests.
8180
sensorDescriptor.onlyOnFileType(InputFile.Type.MAIN);
@@ -130,13 +129,13 @@ protected void executeExternalResultsImport(final SensorContext sensorContext) {
130129
final ActiveRules activeRules = sensorContext.activeRules();
131130

132131
// Report files found in file system and corresponding to SQ property.
133-
final List<String> reportFiles = getReportFiles(config, fileSystem);
132+
final List<File> reportFiles = getReportFiles(config, fileSystem);
134133

135134
// If exists, unmarshal each xml result file.
136-
for(final String reportPath : reportFiles) {
135+
for(final File reportFile : reportFiles) {
137136
try {
138-
// Unmarshall the xml.
139-
final FileInputStream file = new FileInputStream(reportPath);
137+
// Unmarshal the xml.
138+
final FileInputStream file = new FileInputStream(reportFile);
140139
final AnalysisProject analysisProject = (AnalysisProject) XmlHandler.unmarshal(file, AnalysisProject.class);
141140
// Retrieve file in a SonarQube format.
142141
final Map<String, InputFile> scannedFiles = getScannedFiles(fileSystem, analysisProject);
@@ -178,34 +177,30 @@ private void executeEmbeddedICode(final SensorContext sensorContext) {
178177
final HashSet<File> files = new HashSet<>();
179178
final HashMap<String,InputFile> filesMap = new HashMap<>();
180179

181-
try {
182-
// Gather all files in a Set.
183-
for(final InputFile inputFile : inputFiles) {
184-
files.add(inputFile.file());
185-
filesMap.put(inputFile.file().getPath(), inputFile);
186-
}
180+
// Gather all files in a Set.
181+
for(final InputFile inputFile : inputFiles) {
182+
files.add(new File(inputFile.uri()));
183+
filesMap.put(inputFile.uri().getPath(), inputFile);
184+
}
187185

188-
// Run all checkers on all files.
189-
final List<CheckResult> results = analyzer.stableCheck(files, LanguageService.getLanguagesIds(), null);
190-
191-
// Add each issue to SonarQube.
192-
for(final CheckResult result : results) {
193-
if(isRuleActive(activeRules, result.getName())) { // manage active rules
194-
saveIssue(sensorContext, result);
195-
} else if (ICodeMetricsProcessor.isMetric(result.getName())) { // manage trivial measures
196-
ICodeMetricsProcessor.saveMeasure(sensorContext, result);
197-
} else { // log ignored data
198-
LOGGER.info(String.format(
199-
"An issue for rule '%s' was detected by i-Code but this rule is deactivated in current analysis.",
200-
result.getName()));
201-
}
186+
// Run all checkers on all files.
187+
final List<CheckResult> results = analyzer.stableCheck(files, LanguageService.getLanguagesIds(), null);
188+
189+
// Add each issue to SonarQube.
190+
for(final CheckResult result : results) {
191+
if(isRuleActive(activeRules, result.getName())) { // manage active rules
192+
saveIssue(sensorContext, result);
193+
} else if (ICodeMetricsProcessor.isMetric(result.getName())) { // manage trivial measures
194+
ICodeMetricsProcessor.saveMeasure(sensorContext, result);
195+
} else { // log ignored data
196+
LOGGER.info(String.format(
197+
"An issue for rule '%s' was detected by i-Code but this rule is deactivated in current analysis.",
198+
result.getName()));
202199
}
200+
}
203201

204-
ICodeMetricsProcessor.saveExtraMeasures(sensorContext, filesMap, results);
202+
ICodeMetricsProcessor.saveExtraMeasures(sensorContext, filesMap, results);
205203

206-
} catch (final JFlexException e) {
207-
LOGGER.warn(e.getMessage(), e);
208-
}
209204
}
210205

211206
/**
@@ -220,7 +215,7 @@ private void executeExternalICode(final SensorContext sensorContext) {
220215
final FilePredicates predicates = fileSystem.predicates();
221216
final Iterable<InputFile> inputFiles = fileSystem.inputFiles(predicates.hasType(InputFile.Type.MAIN));
222217
final StringBuilder files = new StringBuilder();
223-
inputFiles.forEach(file -> files.append(file.file().getPath()).append(" "));
218+
inputFiles.forEach(file -> files.append(file.uri().getPath()).append(" "));
224219
final String executable = config.get(ICodePluginProperties.ICODE_PATH_KEY).orElse(ICodePluginProperties.ICODE_PATH_DEFAULT);
225220
final String outputFile = config.get(ICodePluginProperties.REPORT_PATH_KEY).orElse(ICodePluginProperties.REPORT_PATH_DEFAULT);
226221
final String outputPath = Paths.get(sensorContext.fileSystem().baseDir().toString(),outputFile).toString();
@@ -263,7 +258,9 @@ static void saveIssue(final SensorContext sensorContext, final CheckResult resul
263258
final FileSystem fileSystem = sensorContext.fileSystem();
264259
final FilePredicates predicates = fileSystem.predicates();
265260
final NewIssue issue = sensorContext.newIssue();
266-
final InputFile file = fileSystem.inputFile(predicates.hasPath(result.getFile().getPath()));
261+
final String fileToFind = result.getFile().getPath();
262+
final FilePredicate predicate = predicates.or(predicates.hasPath(fileToFind), predicates.hasRelativePath(fileToFind));
263+
final InputFile file = fileSystem.inputFile(predicate);
267264
if(Objects.nonNull(file)) {
268265
final String repositoryKey = ICodeRulesDefinition.getRepositoryKeyForLanguage(file.language());
269266
final RuleKey ruleKey = RuleKey.of(repositoryKey, result.getName());
@@ -335,41 +332,39 @@ protected Map<String, InputFile> getScannedFiles(final FileSystem fileSystem, fi
335332
// Looks for each file in file system, print an error if not found.
336333
for(final AnalysisFile file : files) {
337334
// Checks if the file system contains a file with corresponding path (relative or absolute).
338-
FilePredicate predicate = fileSystem.predicates().hasPath(file.getFileName());
339-
InputFile inputFile = fileSystem.inputFile(predicate);
335+
final String fileToFind = new File(fileSystem.baseDir(), file.getFileName()).getPath();
336+
final FilePredicate predicate = fileSystem.predicates().hasRelativePath(fileToFind);
337+
final InputFile inputFile = fileSystem.inputFile(predicate);
340338
if(inputFile!=null) {
341339
result.put(file.getFileName(), inputFile);
342340
} else {
343-
LOGGER.error(String.format(
344-
"The source file '%s' was not found.",
345-
file.getFileName()
346-
));
341+
LOGGER.error(String.format("The source file '%s' was not found.", file.getFileName()));
347342
}
348343
}
349344

350345
return result;
351346
}
352347

353348
/**
354-
* Returns a list of processable result file's path.
349+
* Returns a list of processable result files.
355350
*
356351
* @param config Configuration of the analysis where properties are put.
357352
* @param fileSystem The current file system.
358353
* @return Return a list of path 'findable' in the file system.
359354
*/
360-
private List<String> getReportFiles(final Configuration config, final FileSystem fileSystem) {
355+
protected List<File> getReportFiles(final Configuration config, final FileSystem fileSystem) {
361356
// Contains the result to be returned.
362-
final List<String> result = new ArrayList<>();
357+
final List<File> result = new ArrayList<>();
363358

364359
// Retrieves the non-verified path list from the SonarQube property.
365360
final String[] pathArray = config.getStringArray(ICodePluginProperties.REPORT_PATH_KEY);
366361

367362
// Check if each path is known by the file system and add it to the processable path list,
368363
// otherwise print a warning and ignore this result file.
369-
for(String path : pathArray) {
364+
for(final String path : pathArray) {
370365
final File file = new File(fileSystem.baseDir(), path);
371366
if(file.exists() && file.isFile()) {
372-
result.add(path);
367+
result.add(file);
373368
LOGGER.info(String.format("Results file %s has been found and will be processed.", path));
374369
} else {
375370
LOGGER.warn(String.format("Results file %s has not been found and wont be processed.", path));

0 commit comments

Comments
 (0)