SonarTsPlugin 1.0.0 released

In something of a milestone for the project SonarTsPlugin 1.0.0 has been released. While the last blog post that mentioned the plugin had it at v0.3, there have been a great many changes since then to the point that I might as well outline the total feature set:

  • Analyses TypeScript code using tslint, or consumes existing tslint output¬†and reports issues to the SonarQube interface
  • Analyses code coverage information in LCOV format
    • Also supports Angular-CLI output
  • Derives lines-of-code in your TypeScript project
  • Supports user-defined rule breach reporting
  • Supports custom tslint rule specification
  • Compatible with Windows and Linux, supports various CI environments including VSTS
  • Compatible with SonarQube 5.6 LTS and above
  • A demo site exists
  • Sample projects demonstrating setup of the plugin are available

The project readme has fairly detailed information on how to configure the plugin, which I’m shortly to turn into a wiki on GitHub with a little more structure.

The plugin has been downloaded over a thousand times now, and appears to be getting increasing use given the recent trend of issues and activity on the project. Hopefully it’s now in a good place to build upon, with the core functionality done.

The next big milestone is to get the plugin listed on the SonarQube Update Centre, which will require fixing a few code issues before going through a review process and addressing anything that comes out of that. Being on the Update Centre is the easiest way as a developer to consume the plugin and to receive updates, so is a real priority for the next few months.

2 thoughts on “SonarTsPlugin 1.0.0 released

  1. Iftekhar Azim

    Hi Paul,
    Thanks so mush for the plug in. We are using Typescripts for our front end piece and SONAR is showing zero coverage. I followed your examples but I am not sure what am I missing.
    Appreciate any suggestions or input.
    Thanks
    Iftekhar
    SonarQube Version: Version 5.6.5 – LGPL v3
    TSLInt: 4.x.x
    Webpack
    Karma
    Sonar Properties:
    -Dsonar.sources=”src/main”
    -Dsonar.javascript.coveragePlugin=”lcov”
    -Dsonar.ts.tslintconfigpath=”target/application/tslint.json”
    -Dsonar.ts.coverage.lcovReportPath=”target/application/coverage/lcov.info”
    -Dsonar.surefire.reportsPath=”target/application/coverage/reports/junit/TESTS-xunit.xml”
    -Dsonar.javascript.lcov.reportPath=”target/application/coverage/lcov.info”
    -Dsonar.javascript.jstestdriver.reportsPath=”target/application/coverage/reports/junit/TESTS-xunit.xml”

    Reply
  2. Pablissimo Post author

    I’d start by running the scanner with the -X flag – this will spit out a tonne of diagnostic output. Typically seeing zero coverage happens because:
    * The LCOV file relates to the generated JS files, and not the source TS files (you’ll see warnings in the output that the plugin is ignoring these lines)
    * The plugin just can’t find the LCOV file
    * The LCOV file is malformed

    I’m betting it is the first in the list – that the LCOV file needs to be remapped back to refer to the source TypeScript files. If you’re using Karma you can remap the coverage data back using something like karma-remap-istanbul: https://www.npmjs.com/package/karma-remap-istanbul

    Either way – run with the -X flag and see if the debugging output helps. Feel free to email it to me (if you’re comfortable doing so) if you need help.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *