Skip to content

Commit 3f50bfd

Browse files
ivandalboscopynicolas
authored andcommitted
SONARPY-177 Upgrade provided dependency on sonar-plugin-api from 5.6 to 6.0 (SonarSource#86)
* Upgrade provided dependency on sonar-plugin-api from 5.6 to 6.0 * Fix unit test that failed due to sensor executed twice (no longer possible in 6.0)
1 parent a80543b commit 3f50bfd

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
<gitRepositoryName>sonar-python</gitRepositoryName>
7777
<!-- Release: enable publication to Bintray -->
7878
<artifactsToPublish>${project.groupId}:sonar-python-plugin:jar</artifactsToPublish>
79+
<!-- we depend on API ${sonar.version} but we keep backward compatibility with LTS -->
80+
<sonarQubeMinVersion>5.6</sonarQubeMinVersion>
7981

8082
<!-- versions -->
8183
<commons.io.version>2.5</commons.io.version>
@@ -86,7 +88,7 @@
8688
<maven.project.version>2.2.1</maven.project.version>
8789
<mockito.version>1.10.19</mockito.version>
8890
<slf4j.version>1.7.21</slf4j.version>
89-
<sonar.version>5.6</sonar.version>
91+
<sonar.version>6.0</sonar.version>
9092
<sonar.orchestrator.version>3.13</sonar.orchestrator.version>
9193
<sonarlint-core.version>2.4.1</sonarlint-core.version>
9294
<sslr.version>1.21</sslr.version>

python-squid/src/test/java/org/sonar/python/FileLinesVisitorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void test() {
5959
HashMap<InputFile, Set<Integer>> linesOfCode = new HashMap<>();
6060
SquidAstVisitor<Grammar> visitor = new FileLinesVisitor(fileLinesContextFactory, fileSystem, linesOfCode, false);
6161

62-
SourceFile sourceFile = PythonAstScanner.scanSingleFile(inputFile.getFile().getPath(), visitor);
62+
SourceFile sourceFile = PythonAstScanner.scanSingleFile(inputFile.file().getPath(), visitor);
6363

6464
assertThat(sourceFile.getInt(PythonMetric.LINES_OF_CODE)).isEqualTo(12);
6565
assertThat(linesOfCode).hasSize(1);
@@ -80,7 +80,7 @@ public void test_ignoreHeaderComments() {
8080
HashMap<InputFile, Set<Integer>> linesOfCode = new HashMap<>();
8181
SquidAstVisitor<Grammar> visitor = new FileLinesVisitor(fileLinesContextFactory, fileSystem, linesOfCode, true);
8282

83-
PythonAstScanner.scanSingleFile(inputFile.getFile().getPath(), visitor);
83+
PythonAstScanner.scanSingleFile(inputFile.file().getPath(), visitor);
8484

8585
assertThat(linesOfCode).hasSize(1);
8686
assertThat(linesOfCode.get(inputFile)).as("Lines of codes").containsOnly(2, 4);

sonar-python-plugin/pom.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
<tag>HEAD</tag>
2424
</scm>
2525

26-
<properties>
27-
<sonar.pluginClass>org.sonar.plugins.python.PythonPlugin</sonar.pluginClass>
28-
<sonar.pluginName>SonarPython</sonar.pluginName>
29-
<sonar.skipDependenciesPackaging>true</sonar.skipDependenciesPackaging>
30-
</properties>
31-
3226
<dependencies>
3327
<dependency>
3428
<groupId>org.sonarsource.sonarqube</groupId>
@@ -72,6 +66,18 @@
7266

7367
<build>
7468
<plugins>
69+
<plugin>
70+
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
71+
<artifactId>sonar-packaging-maven-plugin</artifactId>
72+
<configuration>
73+
<pluginName>SonarPython</pluginName>
74+
<pluginClass>org.sonar.plugins.python.PythonPlugin</pluginClass>
75+
<skipDependenciesPackaging>true</skipDependenciesPackaging>
76+
<sonarLintSupported>true</sonarLintSupported>
77+
<sonarQubeMinVersion>${sonarQubeMinVersion}</sonarQubeMinVersion>
78+
</configuration>
79+
</plugin>
80+
7581
<plugin>
7682
<artifactId>maven-shade-plugin</artifactId>
7783
<executions>

sonar-python-plugin/src/test/java/org/sonar/plugins/python/coverage/PythonCoverageSensorTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,22 @@ public void test_unresolved_path() {
134134
}
135135

136136
@Test
137-
public void test_force_zero_coverage_no_report() {
138-
Settings newSettings = new Settings().setProperty(PythonCoverageSensor.FORCE_ZERO_COVERAGE_KEY, "true");
137+
public void test_force_zero_coverage_without_report() {
138+
Settings newSettings = new Settings();
139+
newSettings.setProperty(PythonCoverageSensor.FORCE_ZERO_COVERAGE_KEY, "true");
139140
context.setSettings(newSettings);
140141
coverageSensor.execute(context, linesOfCode);
141142
assertThat(context.lineHits(FILE1_KEY, CoverageType.UNIT, 1)).isEqualTo(0);
142-
assertThat(context.lineHits(FILE3_KEY, CoverageType.UNIT, 1)).isEqualTo(0);
143+
}
143144

144-
context.setSettings(newSettings.setProperty(PythonCoverageSensor.REPORT_PATH_KEY, "coverage.xml"));
145+
@Test
146+
public void test_force_zero_coverage_with_report() {
147+
Settings newSettings = new Settings();
148+
newSettings.setProperty(PythonCoverageSensor.FORCE_ZERO_COVERAGE_KEY, "true");
149+
newSettings.setProperty(PythonCoverageSensor.REPORT_PATH_KEY, "coverage.xml");
150+
context.setSettings(newSettings);
145151
coverageSensor.execute(context, linesOfCode);
146152
assertThat(context.lineHits(FILE1_KEY, CoverageType.UNIT, 1)).isEqualTo(1);
147-
assertThat(context.lineHits(FILE3_KEY, CoverageType.UNIT, 1)).isEqualTo(0);
148153
}
149154

150155
@Test

0 commit comments

Comments
 (0)