{iframe:src=http://update.sonarsource.org/plugins/web.html|width=700|height=250|frameborder=0}
Your browser does not support iframes.
{iframe} |
If you want to see a live example of the capabilities of the Web plugin, you can have a look at the analysis of the Shopizer project on Nemo. |
The plugin enables analysis of Web projects within Sonar. Currently JSP and JSF are supported. Some initial support is provided for Ruby templating (erb files).
It is compatible with the Issues Report plugin to run pre-commit local analysis.
To launch a Sonar analysis of your Web project, use the Sonar Runner.
A sample project is available on github that can be browsed or downloaded: /projects/languages/web/web-sonar-runner.
Maven and Ant can also be used to launch analysis on Web projects.
The following properties of the plugin are configurable:
Property | Default value |
|---|---|
sonar.web.sourceDirectory |
|
sonar.web.fileExtensions | xhtml,jspf,jsp |
sonar.cpd.web.minimumTokens | 70 |
See Metrics documentation page.
Complexity
Complexity of the web page is measured by counting the decision tags (such as if and forEach) and boolean operators in expressions ("&&" and "||"), plus one for the body of the document. It is a measure of the minimum number possible paths to render the page.
The decision tags and the operators are configurable. For details see rules library
Duplication
Duplication is counted by comparing tokens. Duplication is reported if more than a minimum amount of tokens are replicated (in the same file or another file). The default minimum tokens is set to 70.
Comments
Comments are counted by adding the lines for server side and client side comments.
There are about 20 checks in the library. Please read the documentation of the checks on the page Web Rules Library.
The ruleset is inspired on the following standards and guidelines:
A complete explanation of the available checks is given here .
The plugin uses a simple tokenizer to parse the web pages. The tokenizer is based on the sonar-channel library. The output of the tokenizer is analyzed by a set of analyzers and checks. Expressions written in the Unified Expression Language (EL) are validated with JBoss EL.