Skip to content

Commit 78281a5

Browse files
committed
Use maven for SonarCloud analysis
1 parent 69e9f8b commit 78281a5

File tree

6 files changed

+15
-28
lines changed

6 files changed

+15
-28
lines changed

.github/workflows/java-continuous-integration.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
name: Java CI
99

1010
on: [push, pull_request]
11+
env:
12+
MVN_USR: dummy
13+
MVN_PWD: ${{ secrets.GITHUB_TOKEN }}
14+
1115

1216
jobs:
1317

@@ -39,10 +43,7 @@ jobs:
3943
path: "**/target/"
4044
key: ${{ runner.os }}-cache-java-${{ matrix.java }}-${{ github.sha }}
4145
- name: Build with Maven
42-
run: mvn -B clean install -s settings.xml
43-
env:
44-
MVN_USR: dummy
45-
MVN_PWD: ${{ secrets.GITHUB_TOKEN }}
46+
run: mvn -B clean verify -s settings.xml
4647

4748
code-analysis:
4849
permissions:
@@ -65,14 +66,8 @@ jobs:
6566
path: "**/target/"
6667
fail-on-cache-miss: true
6768
key: ${{ runner.os }}-cache-java-21-${{ github.sha }}
68-
# the latest version at https://github.com/marketplace/actions/official-sonarqube-scan
69-
# Triggering SonarQube analysis as results of it are required by Quality Gate check.
7069
- name: SonarQube Scan
71-
uses: SonarSource/sonarqube-scan-action@v6
72-
with:
73-
args: >
74-
-Dsonar.qualitygate.wait=true
75-
-Dsonar.qualitygate.timeout=600
70+
run: mvn -s settings.xml -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Turiok_sonar-icode-cnes-plugin
7671
env:
7772
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7873

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<sonar.pluginOrganizationName>CNES</sonar.pluginOrganizationName>
7272
<sonar.sources>src/main/java</sonar.sources>
7373
<sonar.test>src/test/java</sonar.test>
74+
<sonar.organization>turiok</sonar.organization>
7475
</properties>
7576

7677
<dependencies>

sonar-project.properties

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

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ private void executeEmbeddedICode(final SensorContext sensorContext) {
200200
filesMap.put(inputFile.uri().getPath(), inputFile);
201201
}
202202

203-
204203
// Run all checkers on all files.
205204
final List<CheckResult> results = analyzer.stableCheck(files, LanguageService.getLanguagesIds(), null);
206205

@@ -333,9 +332,9 @@ static void saveIssue(final SensorContext context, final Map<String, InputFile>
333332
newIssue.at(newIssueLocation);
334333
newIssue.save();
335334
} else {
336-
LOGGER.error(String.format(
337-
"Issue '%s' on file '%s' has not been saved because source file was not found.",
338-
issue.getAnalysisRuleId(), issue.getResult().getFileName()));
335+
LOGGER.error(
336+
"Issue '{}' on file '{}' has not been saved because source file was not found.",
337+
issue.getAnalysisRuleId(), issue.getResult().getFileName());
339338
}
340339

341340
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void createBuiltInProfile(final Context context, final String repository
7171
}
7272
profile.setDefault(true);
7373
profile.done();
74-
LOGGER.info(String.format("%s rules are activated for the repository %s.", profile.activeRules().size(),
75-
repository));
74+
LOGGER.info("{} rules are activated for the repository {}.", profile.activeRules().size(),
75+
repository);
7676
}
7777
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ private static void saveMeasure(final SensorContext context, final Map<String, I
317317
// Finally save the measure.
318318
newMeasure.save();
319319
} else {
320-
LOGGER.error(String.format(
321-
"Measure '%s' on file '%s' has not been saved because source file was not found.",
322-
metric.getName(), filename));
320+
LOGGER.error(
321+
"Measure '{}' on file '{}' has not been saved because source file was not found.",
322+
metric.getName(), filename);
323323
}
324324
}
325325

0 commit comments

Comments
 (0)