Question: Sonarlint(IDE Eclipse MicroFocus Enterprise Editor 5.0 ) does not Analyze and provide any recommendations for COPY(.cpy) files, it works for COBOL(.cbl)

SonarQube 7.9.1
SonarLint for Eclipse 4.1.0.201901311043
IDE Eclipse
Question :Sonarlint Analyze does Not find any issues for COPYLIB(.cpy files),it scans for the source code(.cbl files) and provides the desired recommendations.

How ever SonarQube scans both .cbl and .cpy files and the config on Sonarlint is similar to SonarQube ,

I have the Analyzer properties updated
sonar.cobol.copy.directories=\includes(This is the project folder which has the .cpy files)
sonar.sources=COBOL
sonar.cobol.file.suffixes=cbl,cpy

Issue is only for Sonarlint scan for .cpy files.

Any suggestions ?

Hi @Girish_V

(Sorry, I know just a little about Cobol, so I may use the wrong words. I will assume copylibs are what we call copybooks).

SonarLint is not able to analyze copybooks files alone. Those files only make sense in the context of the actual file (.cbl) they are imported into.
In SonarQube, issues may be found in a .cpy while analyzing a .cbl. This doesn’t play well with SonarLint.
In theory, you should be able to use full project analysis to see issues on all files, including copybooks.

Have you try analyzing the entire Eclipse project (that should contain both .cpy and .cbl files)?

Hello , Thank you for your response.
yes I meant copybooks(.cpy files).

Yes I tried analyzing having all files(.cbl and .cpy) together in a single project folder, it seems to analyze .cpy and cbl files.
However our project structure for micro focus enterprise editor(IDE),there is a need to have separate project folders for copybook and cbl files, because the project settings for these folders are unique.

So this is what happens when I select both projects cbl and cpy files and scan
The location for these projects will be
D:\GitRepo\cobol-Repos\source
D:\GitRepo\cobol-Repos\copybook

Select both projects together and sonarlint >Analyze it begins

Starting analysis with configuration:
[
projectKey: MF-COBOL
baseDir: D:\GitRepo\cobol-Repos\source

It shows can’t find the copybook ,It is trying to find copybook in the same baseDir D:GitRepo\cobol-Repos\source\

Where it does not exist.

After scanning cbl files, it begins to scan .cpy files with the baseDir of the copybook

Starting analysis with configuration:
[
projectKey: MF-COBOL
baseDir: D:\GitRepo\cobol-Repos\copybook

Is it possible to associate and resolve the copybook(.cpy files) from different directories while scanning the cbl files in Sonarlint?.

while I was waiting for a response for this post, we performed several trials and realized .cpy files cannot be scanned as a standalone.
we made few changes to Analyzer properties at the workspace level to scan the copy files, it resulted in
parse error…
Link is here Parse Error while scanning COBOL copybooks(.cpy files) using Sonarlint

SonarLint currently analyze each Eclipse project independently. So there is no easy way to raise issues on copybooks that are not in the same project as the .cbl files. It would require a possibly deep integration with Microfocus, which we can’t do alone. For some other Cobol IDEs, we had a collaboration with their editor to have a nice integration.

SonarLint has a general lack regarding cross files analysis (a change in a file creates an issue in another file). I don’t think we will change that at short term, but the “positive” thing is that the very same problem is likely to occur for C/C++ source files including .h headers. In the end all those missing use cases might justify us to start improving this experience of “cross file analysis”.

So as a sum up, in the current situation, analysis of copybooks works only:

  • if sources and copybooks are in the same Eclipse project
  • using “analyze all files” feature

Thank you “For some other Cobol IDEs, we had a collaboration with their editor to have a nice integration”. I was expecting an addon plugin to the IDE, it looks like IDE need enhancement.

It sounds like with use more such cases, it may be possible to include cross file analysis at a later stage. Until that is available, we will use the sonarqube to scan .cbl and cpy files together. Thank you

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