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

« Previous Version 13 Next »

Features

FeatureScreenshot
Static code analysis with JSLint
 Expand...

Unit test and code coverage reports with JsTestDriver
 Expand...

 

Code metrics:

  • sizing (files, lines of code)
  • duplication
  • comments
  • cyclomatic complexity (function complexity, file complexity, complexity density)
 Expand...

 

Version information

Plugin

jslint4java

jstd-maven-plugin

0.3

1.4.6

 

0.4

1.4.6

1.3.2.5

Usage & Installation

Installation

  1. Install JavaScript plugin through Update Center
  2. Restart Sonar

Analysis with Maven

Create a maven pom for your project and run "mvn sonar:sonar" to run analysis and import JsTestDriver results

Sample pom.xml

Sample JavaScript project analysis with Maven

  1. Checkout http://javascript-plugin-for-sonar.googlecode.com/svn/trunk/sample

  2. Update <browser> in pom.xml to point to browser where JavaScript unit tests should be run

  3. Run "mvn test" to execute JsTestDriver unit tests and gather code coverage statistics
  4. Run "mvn sonar:sonar" to analyse JavaScript code and import unit test results

Analysis with simple Java runner

  1. Download latest version of Simple Java Runner
  2. Create sonar-project.properties file for your project

 

Sample sonar-project.properties

Sample JavaScript project analysis with Simple Java Runner

  1. Checkout https://javascript-plugin-for-sonar.googlecode.com/svn/trunk/sample-simple-runner

  2. Change "<base_dir>" placeholders to actual path in sample JsTestDriver coverage file "jstestdriver/jsTestDriver.conf-coverage.dat"

  3. Run "sonar-runner"

Configuration

System wide/Project wide settings

Setting

Key

Corresponding parameter for JSLint

File suffixes

sonar.javascript.file.suffixes

 

Assume a browser

sonar.javascript.lslint.browser

browser

Assume console, alert, ...

sonar.javascript.lslint.devel

devel

Assume a Yahoo Widget

sonar.javascript.lslint.widget

widget

Assume Windows

sonar.javascript.lslint.windows

windows

Assume Rhino

sonar.javascript.lslint.rhino

rhino

Safe Subset

sonar.javascript.lslint.safe

safe

Predefined variables

sonar.javascript.lslint.predef

predef

Maximum number of errors

sonar.javascript.lslint.maxerr

maxerr (default value: 50)

JsTestDriver Output Foldersonar.javascript.lslint.jstestdriverfolder

Folder where JsTestDriver unit test and code coverage reports are stored

Rules

Rule

Corresponding parameter for JSLint

ADsafe rules should be enforced. See http://www.ADsafe.org

adsafe

Allow one var statement per function

onevar

Do Not Tolerate debugger statements

!debug

Do Not Tolerate eval

!evil

Do Not Tolerate sloppy line breaking

!laxbreak

Do Not Tolerate unfiltered for in

!forin

Do Not Tolerate inefficient subscripting

!sub

Do Not Tolerate CSS workarounds

!css

Do Not Tolerate HTML case

!cap

Do Not Tolerate HTML event handlers

!on

Do Not Tolerate HTML fragments

!fragments

Do Not Tolerate ES5 syntax

!es5

Allow one var statement per function

onevar

Disallow undefined variables (has parameter "Predefined ( , separated)")

undef: true, predef:<set value>

Disallow dangling _ in identifiers

nomen

Disallow == and !=

eqeqeq

Disallow ++ and –

plusplus

Disallow bitwise operators

bitwise

Disallow insecure . and [^...] in /RegExp/

regexp

Require Initial Caps for constructors

newcap

Require parens around immediate invocations

immed

Require "use strict";

strict

Maximum line length

maxlen

Strict white space (has parameter "Strict white space indentation")

white:true, indent:<set value>

Unsafe character.

 

Use the array literal notation [].

 

Use the object literal notation {}.

 

Missing semicolon.

 

Mixed spaces and tabs.

 

Other Rules

 

Unused names

 

Do not use wrapper forms

 

Cyclomatic complexity (has parameter "maximum threshold allowed. Default is 10."

 

  • parameters marked with ! are set if corresponding rule is not enabled
  • rules that do not have parameter can not do not have special parameter in JSLint

Plugin Architecture

Code Analysis

JSLint as Javascript static analysis tool. Integrated through jslint4java

Unit Tests and Code Coverage Reports

Unit test and code coverage reports produced by JsTestDriver. Integrated through jstd-maven-plugin.

Code Duplication

For duplication detection plugin uses CPD with ANTLR Lexer generated from ECMAScript Grammar

Cyclomatic complexity

ANTLR based AST generated with ECMAScript Grammar used to count branching statements

Changelog

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

com.atlassian.confluence.macro.MacroExecutionException: JIRA project does not exist or you do not have permission to view it.

Roadmap Ideas

  • No labels