Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{iframe:src=http://update.sonarsource.org/plugins/javascript-confluence.html|width=700|height=250400|frameborder=0}
Your browser does not support iframes.
{iframe}
Tip
titleLive example

If you want to see a live example of the capabilities of the JavaScript plugin, you can have a look at the analysis of the jQuery project on Nemo.

Description / Features

The JavaScript plugin enables analysis of and reporting on JavaScript projects with SonarQube.It is compatible with the Issues Report plugin to run pre-commit local analysis.

Highlights
  • 75 predefined rules
  • custom coding rules with XPath
  • import of code coverage results with LCOV
  • import of unit test results provided by jstest & js-test-driver in XML format 
    Status
    colourGreen
    titlesince 2.2
    subtletrue


Info
titleSince version 2.0

Analysis support of ECMAScript 6 new constructs, see ES6 features (by Luke Hoban). See Angular Dependency Injection v2 analysis on Nemo.

Include Page
Include - Plugin Installation
Include - Plugin Installation

Usage

Run an Analysis with the SonarQube Runner (Recommended

...

method)

To run an analysis of your JavaScript project, use the SonarQube Runner.

...

Maven and Ant can also be used to launch analysis on JavaScript projects.

...

Code Coverage

...

SonarQube can read and import:

...

To display code coverage data:

  1. Prior to the SonarQube analysis, execute your unit tests and generate the LCOV report.
  2. Import this report while running the SonarQube analysis by setting the sonar.javascript.lcov.reportPath property to the path to the LCOV report. The path may be absolute or relative to the project base directory.

(info)  Since the plugin version 2.0, you can force coverage value to be set to "0" without providing any report. You just need to set the following property to "true": sonar.javascript.forceZeroCoverage. Also the property sonar.javascript.lcov.reportPath will prevail over sonar.javascript.forceZeroCoverage if both are set.

A sample project can be browsed or downloaded: this is a JavaScript project analyzed with the SonarQube Runner reusing unit tests and code coverage reports generated with JsTestDriver. It is located in /projects/languages/javascript/javascript-sonar-runner-JsTestDriver.lcov

Unit Tests 
Status
colourGreen
titlesince 2.2
subtletrue

To import unit test data:

  1. Prior to the SonarQube analysis, execute your unit tests in order to generate XML report. 2 formats are supported: jstest & js-test-driver
  2. Import generated XML report while running the SonarQube analysis by setting on of the 2 following properties to the path of the XML report. The path may be absolute or relative to the project base directory: 
    1. sonar.javascript.jstest.reportsPath
    2. sonar.javascript.jstestdriver.reportsPath

See examples for more details about how to configure.

Metrics

See Metrics documentation page.

...

To navigate the AST, download the SSLR JavaScript Toolkit.

Change Log

JIRA Issues
anonymoustrue
titleVersion 1.4
height60
renderModestatic
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=19145&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleVersion 1.3
height60
renderModestatic
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=19052&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleVersion 1.2
height60
renderModestatic
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=18832&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000

 

JIRA Issues
anonymoustrue
titleVersion 1.1
height60
renderModestatic
columnstype;key;summary;priority
urlhttp://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?fixfor=18572&pid=11911&sorter/field=priority&sorter/order=DESC&tempMax=1000