Deactivate custom rules in SonarLint for Eclipse

java
eclipse
custom_rules
(Thanh Luong Giang) #1

Hello Community,

is it possible to deactivate a custom rule in SonarLint but not in SonarQube? Any advice would be very helpful.

I am using
SonarQube 6.7.2
SonarLint 4.1

Thanks in advance!

1 Like
(Julien Henry) #2

Hi @tlg ,

In the code of your custom rule, you should be able to get access to the org.sonar.api.SonarRuntime class (using constructor injection) and test weither you are running in SonarLint to decide if the check should raise issues.

1 Like
(Gilbert Rebhan) #3

Hi,

beside the answer of @Julien_HENRY it might be simpler to deactivate the Sonarlint support in
the pom of your Maven project, i.e.

[...]
<build>
  <plugins>
    <plugin>
      <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
      <artifactId>sonar-packaging-maven-plugin</artifactId>
      <version>1.17</version>
      <extensions>true</extensions>
      <configuration>
        <pluginClass>com.foobar.java.JavaRulesPlugin</pluginClass>
        <sonarLintSupported>false</sonarLintSupported>
        <sonarQubeMinVersion>6.7</sonarQubeMinVersion>
      </configuration>
    </plugin>
[...]

see sonarLintSupported

Regards,
Gilbert

2 Likes