Issue while running sonarlint on cobol program

We have integrated the Sonarlint Plugin with our Topaz Workbench IDE (Cobol Editor). Cobol Editor consist of 3 areas which are, column no 1-6 Sequential number area, column no 8-72 Main area and column no 73-80 Identification number area. We can lock the Sequential and Identification areas in the editor, as we write the code inside Main editor, so when we lock the Sequential area, the Sonarlint Plugin does not analyze the Cobol code but works fine in the unlock mode. We need to understand why it is not working with Sequential area locked and how to resolve this Issue?

Versions used:

Topaz Workbench - 20.13v
Sonarlint - 6.0.0.34844v

When Sequential area is unlocked: analysis given

When Sequential area is locked: 0 items
Sonarlint2.png

Hi @pankajbachhav

This is only a guess, since I don’t have access to Topaz: for our Cobol analyzer to work, it has to be aware of the source code format, in order to ignore the characters present in area1 and area3 (what you call sequential number area and identification number area).
It is very possible that your project is configured to be in “fixed source format” in SonarQube, and SonarLint will automatically use the same format. This explains why everything works fine in unlock mode: SonarLint will “see” the entire source content (including columns 1-6 and 73-80) and “exclude” them as it is configured to be in fixed source format.

Now, this is the part where I’m guessing: when you switch your editor to lock mode, I assume the columns 1-6 and 73-80 are already excluded from the text editor buffer. So SonarLint “see” only columns 8-72. But since it is still configured to be in “fixed source format”, it will fail to parse the code.

One thing you can try to confirm my hypothesis is to force the source format in SonarLint to “free”. Right-click on your project in the project explorer, go to properties, SonarLint, Analyzer Properties, and add a new property: sonar.cobol.sourceFormat: free

This should fix your parsing issue when you are in lock mode, but make it fail when you are in unlocked mode.

Can you confirm this assumption?

Hello, I have applied this property in analyzer properties, and your assumption was correct, it is working in locked mode and not working in unlock mode. Is there any way, sonarlint can give same analysis in both locked and unlocked mode?
Thanks for all the help.

1 Like

Thanks for confirming my hypothesis.

I see two options:

  1. Our SonarCobol analyzer become able to automatically detect the source format. I don’t know if this is possible. I will try to share this use case with my colleagues, but I guess that it is not trivial (or it will be already done :slight_smile: ).
  2. Have the property sonar.cobol.sourceFormat automatically passed to the analyzer, based on the current editor mode. This would require extra integration between Topaz and SonarLint. This is something we have already done in the past for example to configure copybook paths, so in my opinion this is the easiest option. The only requirement is to collaborate with Topaz developers, since this is a close source product, I don’t know how we can query the editor mode.

If you have a way to open a feature request on the Topaz side, it might help to make the topic move forward.

We can go forward with your suggestion. If you are available for discussion, then we can schedule a call.
Thanks!