Full documentation for SonarQube has moved to a new location: http://docs.sonarqube.org/display/SONAR

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 5 Next »

Name

Web Plugin

Authors

Matthijs Galesloot

Jira

http://jira.codehaus.org/browse/SONARPLUGINS/component/14423

Requires Sonar version

2.2 or higher (check version compatibility )

Latest version

0.1-SNAPSHOT (august 2010)

License

Apache 2.0

Sources

http://svn.codehaus.org/sonar-plugins/trunk/web/

Download

(not available yet) http://repository.codehaus.org/org/codehaus/sonar-plugins/web/

Features

The plugin enables analysis of web files within Sonar. Currently JSP and JSF are supported. Some initial support is provided for Ruby templating (erb files). 

The following metrics are supported:

  • sizing (files, lines of code)
  • rules compliancy
  • complexity
  • duplication
  • documentation

The plugin leverages Sonar to provide the following functionalities:

  • Source code view of Web files with their metrics
  • Configuration of custom Rule sets

Usage & Installation

Installation

  1. Copy the jar into /extensions/plugins/ directory
  2. Restart Sonar Web server

Analysis
Create a maven pom for your project. Set the following properties:

  • sonar.language: web.
  • dynamicAnalysis: false
  • sourceDirectory: [folder of the web files]

Sample pom file:

Quick analysis
For an existing maven project, you might start an analysis by the following command:

Please note you can run sonar analysis for an artefact in only one language.

Rules

The ruleset is inspired on the following standards and guidelines:

The following rules are supported:

AvoidHtmlCommentCheck

bla bla bla

Configuration

The following properties of the plugin are configurable:

property

default value

sonar.web.sourceDirectory

 

sonar.web.fileExtensions

xhtml,jspf,jsp,erb

Plugin Architecture

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.

No further external tools or maven plugins are being used for analyzing the code.

Alpha Status and Testing

The plugin has alpha status: testing should focus on functionality and usability. Does the plugin deliver the required metrics? What is the quality of the rules library?

The plugin has been tested on JSP files from Alfresco (http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-client) and XHTML files from Nuxeo.

E.g. a quick test would be to check code from Alfresco, create a pom file and run the analysis.

  • No labels