File exclusions arent applied when commiting in IntelliJ

When having the following Exclusions in SonarLint and the project is synchronized with a sonarQube server having the same Exclusions
image

when i try to commit i still get the warning about errors in my test classes:

I also have the same exclusions globally in my SonarQube installation

I don’t understand why i still get the warning about the SonarQube issues although i excluded the class from scanning.

I am using IntelliJ 2019.3.1 and SonarLint 4.4.

Hi,

When having the following Exclusions in SonarLint

This is maybe confusing, but exclusions you configure in IntelliJ are only taken into account if you are not in connected mode. In connected mode we are trying to be as close as we can to server configuration, so we are only using server side exclusions configuration.

I also have the same exclusions globally in my SonarQube

Can you give us the key of the property configured on server side? Is it sonar.exclusions or sonar.global.exclusions?
Is the file possibly classified as a test by SonarLint and not by SonarQube (or the other way around?).

Hi Julien,

Thank you for the reply, we have the following configuration on the SonarQube server:

Are the file exclusion applied when running analysis manually on the file?

If not, could you please enable verbose logs in the SonarLint panel, trigger an analysis, and give me logs. Should be something like:

Configuring analysis with org.sonarlint.intellij.analysis.JavaAnalysisConfigurator
Using configuration of 'org.sonarsource.sonarlint.intellij:sonarlint-intellij' in server 'Dory'
Analysing 'ConnectedSonarLintFacade.java'...
Starting analysis with configuration:
[
  projectKey: org.sonarsource.sonarlint.intellij:sonarlint-intellij
  baseDir: /home/julien/Prog/Projects/sonar-intellij
  extraProperties: {dont_care}
  inputFiles: [
    file:///home/julien/Prog/Projects/sonar-intellij/src/main/java/org/sonarlint/intellij/core/ConnectedSonarLintFacade.java (UTF-8)
  ]
]

When i run the check manually on the file the exclusions are not applied.

When i run the check on the VCS modified files the exclusion is applied.

When i run the check on the VCS modified files after not clearing the manual results from the Testfile the exclusion is applied but the issues remain visible in the VCS changed file view.

When i commit and the pre-commit check is executed, the exclusion is not applied.

In this case the log says:

Trigger: CHECK_IN
[Pre-commit check] 5 file(s) submitted

inputFiles: [
file:// … FooTest.java (UTF-8) [test]
]

Available languages:

  • Python => “py”
  • Java => “java”
  • XML => “xml”
  • JavaScript => “js”
    Start analysis
    Declared extensions of language Python were converted to py: /.py
    Declared extensions of language Java were converted to java: **/
    .java,
    /.jav
    Declared extensions of language XML were converted to xml: **/
    .xml,/*.xsd,/.xsl
    Declared extensions of language JavaScript were converted to js: **/
    .js,/*.jsx,/*.vue
    Index files
    Language of file ‘file://FooTest.java’ is detected to be ‘java’
    0/0 source files have been analyzed
    1 file indexed
    Quality profiles:

Java Main Files AST scan
0 source files to be analyzed
Java Main Files AST scan (done) | time=0ms
Java Test Files AST scan
0/0 source files have been analyzed
1 source files to be analyzed
Initializing metadata of file file://FooTest.java
1/1 source files have been analyzed
Java Test Files AST scan (done) | time=74ms
‘Python Squid Sensor’ skipped because there is no related file in current project
Execute Sensor: JavaXmlSensor
‘XML Sensor’ skipped because there is no related file in current project
‘SonarJS’ skipped because there is no related file in current project
‘ESLint-based SonarJS’ skipped because there is no related file in current project
Processed 41 issues in 98 ms
Found 41 issues

Without the issues in the Testclass it would be 39 issues.

Thanks, I managed to reproduce, and this is already tracked in this ticket:
https://jira.sonarsource.com/browse/SLI-356

We will fix it in the next sprint.