SonarLint connected mode COBOL on VSCode doesn't ignore false positives

Please provide

  • Operating system: Windows 11
  • SonarLint plugin version: 4.8.0
  • Programming language you’re coding in: COBOL
  • Is connected mode used: Yes
    • Connected to SonarCloud or SonarQube (and which version): SonarQube 10.6.0.92116

And a thorough description of the problem / question:

I’ve set up SonarLint yesterday and there is one thing that doesn’t work properly.
As said in the documentation, Automatically suppress issues that are marked as Accepted or False Positive in SonarQube or on SonarCloud so that locally reported issues match those found on the server.

But when I go into some files that get false positives, they are still showed in problems.

SonarQube version :

SonarLint version :
image

There is only 1 file opened in my VSCode and it is the same file as shown on SonarQube screenshot

Do I need to do a specific setup ?

Hi @ldebonnet!

This should work out of the box and not require any additional setup other than setting up the Connected Mode (which you already did).

Do I understand correctly that in the screenshots you shared, SonarQube also detected 16 issues in total, but 2 of them were marked as False Positives on the server? And in VSCode, you still see those 2 issues highlighted? :thinking:?

Whatever the case, we would need SonarLint logs. You can find the instructions on how to get them here.

Thanks in advance,
Sophio

Hello Sophio,

Yes, 2 of them are false positive but they are still highlighted in VSCode

Here are the logs :
I replaced path and file name by FILE

[Debug - 10:32:15.289] Start analysis
[Info - 10:32:15.292] Index files
[Debug - 10:32:15.292] Language of file "FILE" is set to "COBOL"
[Info - 10:32:15.292] 1 file indexed
[Debug - 10:32:15.375] Setting filesystem encoding: UTF-8
[Debug - 10:32:15.383] 'JavaSensor' skipped because there are no related files in the current project
[Debug - 10:32:15.383] Execute Sensor: CobolSquidSensor
[Info - 10:32:15.384] About to analyse COBOL Programs using 'microfocus-cobol' dialect and 'fixed' source code format.
[Debug - 10:32:15.384] Analysis cache is disabled, we are in SonarLint context
[Info - 10:32:15.387] 1 source file to be analyzed
[Warn - 10:32:15.568] Unable to find copybook 'ORACA' (at line=422 in file='FILE'.)
[Debug - 10:32:15.698] Initializing metadata of file FILE
[Debug - 10:32:15.698] Evaluate issue exclusions for 'FILE'
[Info - 10:32:15.739] 1/1 source file has been analyzed
[Info - 10:32:15.739] Analysis time: 356ms
[Info - 10:32:15.739] Decoration time: 0ms
[Debug - 10:32:15.739] 'Python Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.739] 'IPython Notebooks Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.740] 'Code Quality and Security for Go' skipped because there are no related files in the current project
[Debug - 10:32:15.740] 'IaC Terraform Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.740] 'IaC CloudFormation Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.740] 'IaC Kubernetes Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.740] 'IaC AzureResourceManager Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.740] Execute Sensor: Java Config Sensor
[Info - 10:32:15.740] 0 source files to be analyzed
[Info - 10:32:15.740] 0/0 source files have been analyzed
[Debug - 10:32:15.741] 'T-SQL Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.741] 'Apex Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.741] 'PL/SQL Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.741] 'OmniSharp' skipped because there are no related files in the current project
[Debug - 10:32:15.741] Execute Sensor: HTML
[Debug - 10:32:15.741] 'XML Sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.741] 'PHP sensor' skipped because there are no related files in the current project
[Debug - 10:32:15.741] 'Analyzer for "php.ini" files' skipped because there are no related files in the current project
[Debug - 10:32:15.741] Execute Sensor: IaC Docker Sensor
[Info - 10:32:15.748] 0 source files to be analyzed
[Info - 10:32:15.748] 0/0 source files have been analyzed
[Debug - 10:32:15.748] 'CFamily' skipped because there are no related files in the current project
[Debug - 10:32:15.748] Execute Sensor: javabugs
[Debug - 10:32:15.748] Execute Sensor: pythonbugs
[Debug - 10:32:15.748] Execute Sensor: EnterpriseSecretsSensor
[Info - 10:32:15.748] Available processors: 20
[Info - 10:32:15.748] Using 20 threads for analysis.
[Info - 10:32:15.748] The property "sonar.tests" is not set. To improve the analysis accuracy, we categorize a file as a test file if any of the following is true:
  * The filename starts with "test"
  * The filename contains "test." or "tests."
  * Any directory in the file path is named: "doc", "docs", "test" or "tests"
  * Any directory in the file path has a name ending in "test" or "tests"

[Debug - 10:32:15.749] Execute Sensor: TextAndSecretsSensor
[Info - 10:32:15.749] Available processors: 20
[Info - 10:32:15.749] Using 20 threads for analysis.
[Info - 10:32:15.792] The property "sonar.tests" is not set. To improve the analysis accuracy, we categorize a file as a test file if any of the following is true:
  * The filename starts with "test"
  * The filename contains "test." or "tests."
  * Any directory in the file path is named: "doc", "docs", "test" or "tests"
  * Any directory in the file path has a name ending in "test" or "tests"

[Info - 10:32:15.793] Analyzing all except non binary files
[Info - 10:32:15.796] 1 source file to be analyzed
[Info - 10:32:15.832] 1/1 source file has been analyzed
[Info - 10:32:15.833] Analysis detected 16 issues and 0 Security Hotspots in 952ms
[Debug - 10:32:15.834] Skip downloading file issues on SonarQube 
[Debug - 10:32:15.834] Skip downloading file hotspots on SonarQube 10.1+

Léo

Thanks for the logs!

I was not able to reproduce the issue locally :confused: What I tried:

  • Scan a project containing COBOL files on SonarQube
  • Open the same project locally and bind it to SonarQube
  • See the same issues detected in SonarLint and SonarQube
  • Resolve one of the issues as False Positive on SonarQube
  • Observe the issue resolution event received in the SonarLint logs:
Received event: event: IssueChanged
data: {"projectKey":"cobol-sample","issues":[{"issueKey":"d22265wd-43c6-40a0-aa45-6d18087feeaf","branchName":"main"}],"resolved":true}
  • Observe issue is no longer highlighted in SonarLint
  • Reload the VSCode window and still see that FP is not highlighted in the file

Basically, SonarQube pushes issue change events to SonarLint, and then SonarLint is responsible for updating views accordingly. In case this does not work as seamlessly, the VSCode window reload should force SonarLint to re-synchronize with the server.

In case even after reloading VSCode window you still observe the same behavior, please provide the full SonarLint logs, the first line should look something like this

Executing /Users/sophio/.vscode/extensions/sonarsource.sonarlint-vscode-4.8.0-darwin-arm64/jre/21.0.4-macosx-aarch64.tar/bin/java

I can also initiate a private message on this forum so you can share the logs more privately if needed :slight_smile:

Hope that helps,
Sophio

Hello,

Sorry for the answer time, I had a lot do to recently.

I just found out why it didn’t work, and the problem was between the keyboard and the chair…

On VSCode, the linked branch is pre-release, but on SonarQube, the default branch is master
When I switched to pre-release on SonarQube, everything was good

Sorry for inconvenience

Léo

1 Like

Awesome!

I am glad to hear your issue is resolved :partying_face: If you have two minutes to spare, we would really appreciate your review of SonarLint on the VSCode Marketplace.

Enjoy coding with SonarLint!

Sophio from :sonarlint_vscode:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.