File tree Expand file tree Collapse file tree
main/java/org/sonar/plugins/python
test/java/org/sonar/plugins/python Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121
2222import org .sonar .api .Plugin ;
2323import org .sonar .api .PropertyType ;
24+ import org .sonar .api .SonarProduct ;
2425import org .sonar .api .config .PropertyDefinition ;
2526import org .sonar .api .resources .Qualifiers ;
27+ import org .sonar .api .utils .Version ;
2628import org .sonar .plugins .python .coverage .PythonCoverageSensor ;
2729import org .sonar .plugins .python .pylint .PylintConfiguration ;
2830import org .sonar .plugins .python .pylint .PylintImportSensor ;
@@ -142,14 +144,16 @@ public void define(Context context) {
142144 PythonProfile .class ,
143145
144146 PythonSquidSensor .class ,
145- new PythonRuleRepository (context .getSonarQubeVersion ()),
146-
147- PylintConfiguration .class ,
148- PylintSensor .class ,
149- PylintImportSensor .class ,
150- PylintRuleRepository .class ,
151-
152- PythonXUnitSensor .class );
147+ new PythonRuleRepository (context .getSonarQubeVersion ()));
148+
149+ if (!context .getSonarQubeVersion ().isGreaterThanOrEqual (Version .create (6 , 0 )) || context .getRuntime ().getProduct () != SonarProduct .SONARLINT ) {
150+ context .addExtensions (
151+ PylintConfiguration .class ,
152+ PylintSensor .class ,
153+ PylintImportSensor .class ,
154+ PylintRuleRepository .class ,
155+ PythonXUnitSensor .class );
156+ }
153157 }
154158
155159}
Original file line number Diff line number Diff line change 1919 */
2020package org .sonar .plugins .python ;
2121
22+ import java .util .List ;
2223import org .junit .Test ;
2324import org .sonar .api .Plugin ;
2425import org .sonar .api .SonarQubeSide ;
@@ -32,10 +33,17 @@ public class PythonPluginTest {
3233
3334 @ Test
3435 public void testGetExtensions () {
35- SonarRuntime runtime = SonarRuntimeImpl .forSonarQube (Version .create (5 , 6 ), SonarQubeSide .SERVER );
36+ Version v56 = Version .create (5 , 6 );
37+ Version v60 = Version .create (6 , 0 );
38+ assertThat (extensions (SonarRuntimeImpl .forSonarQube (v56 , SonarQubeSide .SERVER ))).hasSize (19 );
39+ assertThat (extensions (SonarRuntimeImpl .forSonarQube (v60 , SonarQubeSide .SERVER ))).hasSize (19 );
40+ assertThat (extensions (SonarRuntimeImpl .forSonarLint (v60 ))).hasSize (14 );
41+ }
42+
43+ private List extensions (SonarRuntime runtime ) {
3644 Plugin .Context context = new Plugin .Context (runtime );
3745 new PythonPlugin ().define (context );
38- assertThat ( context .getExtensions ()). hasSize ( 19 );
46+ return context .getExtensions ();
3947 }
4048
4149}
You can’t perform that action at this time.
0 commit comments