Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current ·  View Page History
Live 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 plugin enables analysis of JavaScript projects within Sonar.

Installation

  1. Install the JavaScript plugin through the Update Center or download it into the SONAR_HOME/extensions/plugins directory
  2. Restart the Sonar server

Usage

Run a Sonar Analysis with the Sonar Runner (Recommended Way)

To launch a Sonar analysis of your JavaScript project, use the Sonar Runner.

A sample project is available on GitHub that can be browsed or downloaded: /projects/languages/javascript/javascript-sonar-runner.

Run a Sonar Analysis with the other Analyzers

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

Unit Tests and Code Coverage Reports

Reports from JsTestDriver can be imported into Sonar.

Sample projects are available on github that can be browsed or downloaded:

  1. JavaScript project analyzed with the Sonar Runner reusing unit tests and code coverage reports generated with JsTestDriver: /projects/languages/javascript/javascript-sonar-runner-JsTestDriver
  2. JavaScript project analyzed with Maven running unit tests and code coverage reports with JsTestDriver (integrated through jstd-maven-plugin): /projects/languages/javascript/javascript-maven-JsTestDriver

Extending Coding Rules using XPath

New coding rules can be added using XPath. See the related documentation.

To navigate the AST, download the SSLR JavaScript Toolkit.

Change Log

Release 1.2 (33 issues)
Type Key Summary Priority Status
New Feature SONARPLUGINS-2545 Rule: Avoid redeclaration of functions Major Closed
New Feature SONARPLUGINS-2546 Rule: Avoid usage of the same name for the declarations of both a function and a variable Major Closed
New Feature SONARPLUGINS-2538 Rule: Use Javascript strict mode with caution Major Closed
New Feature SONARPLUGINS-2536 Rule: Avoid trailing whitespaces Major Closed
New Feature SONARPLUGINS-2537 Rule: Newline at the end of file Major Closed
New Feature SONARPLUGINS-2533 Rule: Avoid redeclaration of variables Major Closed
New Feature SONARPLUGINS-2532 Rule: "eval" and "arguments" must not be bound or assigned Major Closed
New Feature SONARPLUGINS-2530 Rule: Do not use octal numbers Major Closed
New Feature SONARPLUGINS-2527 Rule: Function argument names should be unique Major Closed
New Feature SONARPLUGINS-2526 Rule: Duplicate property names not allowed in object literals Major Closed
New Feature SONARPLUGINS-2529 Rule: Do not use additional "future reserved words" as identifiers Major Closed
Bug SONARPLUGINS-2519 Parser: Regular expression can contain empty class Major Closed
Bug SONARPLUGINS-2518 Parser: Incorrect definition of grammar rule identifier Major Closed
Bug SONARPLUGINS-2517 Parser: "future reserved words" can be used as identifiers in non-strict code Major Closed
Bug SONARPLUGINS-2516 Parser: incorrect definition of grammar rule identifierName Major Closed
Task SONARPLUGINS-2515 Update the SQALE mapping for new rules Major Closed
New Feature SONARPLUGINS-2514 Rule: Do not use Internet Explorer's conditional comments Major Closed
Bug SONARPLUGINS-2513 Misleading position of violation for rule AlwaysUseCurlyBraces Major Closed
Bug SONARPLUGINS-2511 Empty violation message in LabelPlacementCheck Major Closed
New Feature SONARPLUGINS-2512 Rule: Avoid trailing comment Major Closed
New Feature SONARPLUGINS-2506 Rule: Avoid use of constructor functions for side-effects Major Closed
New Feature SONARPLUGINS-2503 Rule: Collapsible If statements Major Closed
New Feature SONARPLUGINS-2502 Rule: Avoid use of tabulation character Major Closed
New Feature SONARPLUGINS-2500 Rule: Avoid empty block Major Closed
New Feature SONARPLUGINS-2498 Rule: If ... else if constructs shall be terminated with an else clause Major Closed
New Feature SONARPLUGINS-2497 Rule: Avoid function with too many parameters Major Closed
Bug SONARPLUGINS-2551 Incorrect computation of metrics in case of anonymous functions on same line Major Closed
Improvement SONARPLUGINS-2289 Parsing javascript running under linux Major Closed
Improvement SONARPLUGINS-2352 Use lexerless parser Major Closed
Improvement SONARPLUGINS-2524 The Coverage/Unit Tests widget should not be displayed by default on Javascript projects Major Closed
Improvement SONARPLUGINS-2520 Update properties descriptions Minor Closed
Improvement SONARPLUGINS-2464 An unconditional break statement shall terminate every non-empty case-clause except latest Minor Closed
Bug SONARPLUGINS-2307 Incorrect complexity computation Minor Closed

 

Release 1.1 (20 issues)
Type Key Summary Priority
Improvement SONARPLUGINS-2047 Upgrade to SSLR 1.14 Major
Improvement SONARPLUGINS-2045 When a JavaScript file starts with the BOM(Byte Order Mark) character, the source code can't be parsed Major
Improvement SONARPLUGINS-2043 The Javascript analyser doesn't support the HTML comment embedded into the javascript source code Major
Bug SONARPLUGINS-2079 Rule AlwaysUseCurlyBracesCheck should not produce false-positive in case of 'if-else-if' Major
Bug SONARPLUGINS-1957 Compound and labelled statements should not be included into metric 'statements' Major
Improvement SONARPLUGINS-1955 Improve performance of parser by refactoring of grammar Major
Improvement SONARPLUGINS-1951 Follow best-practice: replace NOK by Non-Compliant and OK by Compliant in descriptions of rules Major
Bug SONARPLUGINS-1949 Unable to lex regular expression literal which contains "/" Major
New Feature SONARPLUGINS-2183 Make the Javascript plugin support the Developer Cockpit plugin by providing the measures comments and loc by line Major
New Feature SONARPLUGINS-2235 Rule: Avoid switch without default clause Major
Bug SONARPLUGINS-2213 Prevent conflicts in l10n of description for JavaScript rules Major
New Feature SONARPLUGINS-2208 Embed the sonar-common-rules library Major
Bug SONARPLUGINS-2200 Misleading position of violation for rule AlwaysUseCurlyBraces Major
Task SONARPLUGINS-2197 Remove metric comment_blank_lines Major
Bug SONARPLUGINS-2292 Rule CommentedCode should not produce false-positive in JSDoc comments Major
New Feature SONARPLUGINS-2290 Rule: Do not use HTML comments, because they are not part of EcmaScript specification Major
New Feature SONARPLUGINS-2282 Rule: Avoid using 'continue' branching statement Major
New Feature SONARPLUGINS-2249 Provide new version of sslr-javascript-toolkit instead of javascript-devkit Major
New Feature SONARPLUGINS-2236 Rule: An unconditional break statement shall terminate every non-empty switch-clause Major
Bug SONARPLUGINS-2178 Rule NestedIfDepthCheck should not produce false-positive in case of 'if-else-if' Minor

 

Release 1.0 (36 issues)
Type Key Summary Priority
New Feature SONARPLUGINS-1842 Rule: Avoid use of parentheses where not required by syntax or semantics Major
New Feature SONARPLUGINS-1841 Rule: Detect conditional operators Major
New Feature SONARPLUGINS-1840 Rule: "UnreachableCore" - return, break, continue, or throw statements should be followed by a } or case or default. Major
Task SONARPLUGINS-1829 Do not use jslint4java Major
New Feature SONARPLUGINS-1828 Rule: Avoid trailing comma in array and object literals Major
New Feature SONARPLUGINS-1826 Rule: Avoid doing assignments in the condition part of if/while/for statements Major
New Feature SONARPLUGINS-1827 Rule: Only while/do/for statements can be labelled Major
New Feature SONARPLUGINS-1823 Rule: Use single quote for string literals Major
New Feature SONARPLUGINS-1822 Rule: Do not allow function declarations within blocks Major
New Feature SONARPLUGINS-1820 Rule: Do not use wrapper objects for primitive types Major
New Feature SONARPLUGINS-1817 Rule: Do not use Array and Object constructors Major
New Feature SONARPLUGINS-1816 Rule: Avoid multiline string literals Major
New Feature SONARPLUGINS-1819 Rule: For-in statement must filter items Major
New Feature SONARPLUGINS-1818 Rule: Avoid usage of bitwise operators Major
New Feature SONARPLUGINS-1814 Rule: Each statement must end with a semicolon Major
New Feature SONARPLUGINS-1815 Rule: Always use curly braces for if/else/for/while/do statements Major
New Feature SONARPLUGINS-1813 Rule: Avoid usage of with statement Major
New Feature SONARPLUGINS-1812 Rule: One statement per line Major
New Feature SONARPLUGINS-1811 Rule: Regular expression on comment Major
New Feature SONARPLUGINS-1808 Rule: Avoid usage of == and != Major
New Feature SONARPLUGINS-1806 Rule: Avoid usage of eval Major
New Feature SONARPLUGINS-1809 Rule: Line too long Major
New Feature SONARPLUGINS-1807 Rule: Avoid usage of debugger statement Major
New Feature SONARPLUGINS-1799 Rule: Avoid too complex function Major
New Feature SONARPLUGINS-1855 Rule: Avoid deeply nested if statements Major
Bug SONARPLUGINS-1703 Problem in the calculation of cyclomatic complexity Major
New Feature SONARPLUGINS-1702 Support for JsTest unit test execution and code coverage reports should be added Major
New Feature SONARPLUGINS-1794 Rule: When there is a parsing error, this error should be added like a violation on that JavaScript file Major
New Feature SONARPLUGINS-1795 Rule: Detect commented-out lines of code Major
New Feature SONARPLUGINS-1790 Metric: blank comments Major
New Feature SONARPLUGINS-1792 Provide "Sonar Way" profile for JavaScript Major
New Feature SONARPLUGINS-1791 Metric: statements Major
New Feature SONARPLUGINS-1793 Rule: Generic JavaScript rule to define some homemade checks with an XPath expression Major
New Feature SONARPLUGINS-1789 Integrate JavaScript parser based on SSLR Major
New Feature SONARPLUGINS-1788 Provide JavaScript rule engine based on SSLR Major
New Feature SONARPLUGINS-1796 Provide a default SQALE mapping for the JavaScript rules Major

 

Release 0.4 (5 issues)
Type Key Summary Priority
Bug SONARPLUGINS-1625 NullPointer on loading test file Major
New Feature SONARPLUGINS-1587 Support of JsTestDriver unit test execution and code coverage reports should be added Major
Bug SONARPLUGINS-1139 Cannot define multiple predefined variables Major
Bug SONARPLUGINS-1319 Doesn't work with SCM Plugin Major
Bug SONARPLUGINS-1295 Cannot specify sonar.javascript.lslint.predef in POM Major

 

Release 0.3 (1 issues)
Type Key Summary Priority
New Feature SONARPLUGINS-1006 Migrate JavaScript plugin from code.google.com to Codehaus Minor

Labels
  • None