www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What is the recommend tool for D linting from CI pipelines? Does such

reply Carsten Schlote <carsten.schlote gmx.net> writes:
Hi,

many companies started to use CI pipelines, and as part of their 
pipelines they introduced mandatory linting for source code.

There are tools for many languages, esp. for C/C++. These tools 
usually return '0' on success, and something else on linting 
errors. That is pretty much the standard POSIX way to return a 
resultcode  back to the calling programm/shell. The CI pipeline 
aborts, when something else then '0' is returned.

However, for the D language I found only 'dscanner'. It has a 
report option, but seems to return always a '0'. I have to check 
the JSON style output to find out, if any issues are reported or 
not. This makes things more complicated than needed.

So, my simple question are:
  * What is the recommended way to do automated linting for D 
sources in CI pipelines or similiar?
  * Is there any other tool than dscanner to do serious linting 
for D language?

Carsten
Oct 11 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Saturday, 12 October 2019 at 04:55:02 UTC, Carsten Schlote 
wrote:
 Hi,

 many companies started to use CI pipelines, and as part of 
 their pipelines they introduced mandatory linting for source 
 code.

 There are tools for many languages, esp. for C/C++. These tools 
 usually return '0' on success, and something else on linting 
 errors. That is pretty much the standard POSIX way to return a 
 resultcode  back to the calling programm/shell. The CI pipeline 
 aborts, when something else then '0' is returned.

 However, for the D language I found only 'dscanner'. It has a 
 report option, but seems to return always a '0'. I have to 
 check the JSON style output to find out, if any issues are 
 reported or not. This makes things more complicated than needed.

 So, my simple question are:
  * What is the recommended way to do automated linting for D 
 sources in CI pipelines or similiar?
  * Is there any other tool than dscanner to do serious linting 
 for D language?

 Carsten
There were many additions in this area in the recent time. - Jenkins Next Generation Warnings Plugin now supports D-Scanner JSON output. Therefore you can instrument the Jenkins plugin to stop if there are errors. - D-Scanner allows you (upcoming version) to output SonarQube generic issues json instead of the default json. You can import it into a bare SonarQube (no d plugin needed). And also SonarQube voter can stop your build depending on your findings. - With next Dub version, d-scanner is integrated. Just call dub lint within your dub project folder. This also makes the CI use case much greater. That said, we are just at the starting point of using d-scanner in CI. There might be here and there missing features. Contribution in form of suggestions or even pull requests are highly welcome. Kind regards Andre
Oct 12 2019
parent Carsten Schlote <carsten.schlote gmx.net> writes:
On Saturday, 12 October 2019 at 11:37:12 UTC, Andre Pany wrote:
 - With next Dub version, d-scanner is integrated. Just call dub 
 lint within your dub project folder. This also makes the CI use 
 case much greater.
Sound like the best solution. Using dub seems to be the best way for build D apps, libs and even ddox. Having built-in linting with a proper return value and some usable output formats would make it perfect.
 That said, we are just at the starting point of using d-scanner 
 in CI. There might be here and there missing features.
That would be no problem, as long as things are evolving ;-)
 Contribution in form of suggestions or even pull requests are 
 highly welcome.
Yes, there are still some ideas. E.g. some kind of support to directly compile C source files and link their objects with the rest would be fine. It turned out, that sometimes it is much easier to have some thin C layer to call other libs, and just call the extern(C) wrapper function. This gives better control. For now, we use the preBuild/preGenerate hooks to call make on such files. Carsten
Oct 12 2019