Skip to end of metadata
Go to start of metadata
Live example

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.

Description / Features

The plugin enables analysis of Web projects within SonarQube. 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.

Installation

  1. Install the plugin through the Update Center or download it into the SONARQUBE_HOME/extensions/plugins directory
  2. Restart the SonarQubeserver

Usage

Run an Analysis with the SonarQubeRunner (Recommended Way)

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

A sample project is available on github that can be browsed or downloaded/projects/languages/web/web-sonar-runner.

Run an Analysis with the other Analyzers

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

Advanced Properties

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

Metrics

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.

Rules

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 .

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.

Roadmap Ideas

  • More support for WCAG, webrichtlijnen
  • Enhanced validation of unified expressions (using JSFUnit?)
  • Dependency analysis

Change Log

Release 1.2 (13 issues)
Type Key Summary Priority
Bug SONARPLUGINS-1201 Struts tags suport: wrongly report Invalid OGNL Expression Critical
Task SONARPLUGINS-1973 Replace all the Web profiles by a single Sonar Way Profile Major
Improvement SONARPLUGINS-1903 Add Greek Localization Major
New Feature SONARPLUGINS-1897 Add commented-out code detection capability Major
Improvement SONARPLUGINS-1890 Most violations don't have any message Major
Improvement SONARPLUGINS-1889 By default, all rules are declared to have mutliple cardinality but this shouldn't be the case Major
Bug SONARPLUGINS-1888 Impossible to set property "taglibs" on IllegalTagLibsCheck rule Major
Task SONARPLUGINS-1887 Add L10n mechanism to the Web plugin Major
Improvement SONARPLUGINS-1878 Improve syntax highlighting Major
Improvement SONARPLUGINS-1874 Source headers should not be counted as comments Major
Task SONARPLUGINS-1873 Deprecate the specific "sonar.web.sourceDirectory" property in favor of the standard properties Major
Bug SONARPLUGINS-1858 Make the Sonar Web plugin compatible with Sonar 2.12+ Major
Improvement SONARPLUGINS-1187 Allow configuration via sonar-project.properties rather than pom.xml Minor

 

Release 1.1 (6 issues)
Type Key Summary Priority
Bug SONARPLUGINS-867 ArrayIndexOutOfBoundsException when running analysis Major
Improvement SONARPLUGINS-866 Plugin does not accept absolute path as src directory Major
New Feature SONARPLUGINS-853 Feature to monitor usage of escape="false" attribute on pages. Major
Bug SONARPLUGINS-1195 Code colorizing in sonar source view does not work Major
New Feature SONARPLUGINS-1184 Provide API for other plugins acting on web files Major
Bug SONARPLUGINS-1088 Sonar not able to recognize the OGNL "#{true:''}" Major

 

Release 1.0.2 (1 issues)
Type Key Summary Priority
Bug SONARPLUGINS-857 XMLProfileParser shouldn't be instantiated by plugin Major

 

Release 1.0.1 (1 issues)
Type Key Summary Priority
Bug SONARPLUGINS-858 Sonar with web plugin fails to start on Oracle database Critical

 

Release 1.0 (21 issues)
Type Key Summary Priority
Bug SONARPLUGINS-680 Rule : Avoid Html Comment - Issue Major
Bug SONARPLUGINS-681 Rule : Enclosed Tags Major
Bug SONARPLUGINS-679 Rule : Double Quotes - Issue Major
Bug SONARPLUGINS-678 Rule : Labels Internationalization - Issue Major
Bug SONARPLUGINS-677 Rule Invalid Expression - Issue Major
New Feature SONARPLUGINS-639 New web rule : Each <head> element should contain a <title> element Major
New Feature SONARPLUGINS-632 Add a new Web rule to prevent use of SQL inside JSP Major
New Feature SONARPLUGINS-633 New web rule to check the file length Major
New Feature SONARPLUGINS-626 Multiple instances of the same check Major
New Feature SONARPLUGINS-656 RequiredAttribute check Major
Bug SONARPLUGINS-704 Directory src/main/java is always checked as sourceDirectory Major
Bug SONARPLUGINS-690 Problem with invalid expression Major
New Feature SONARPLUGINS-844 Analysis fails when complexity check is disabled. Major
Improvement SONARPLUGINS-836 Add file complexity distribution Major
Bug SONARPLUGINS-835 Add missing directory metric Major
New Feature SONARPLUGINS-833 Implement NOSONAR Major
Task SONARPLUGINS-828 Add plugin to SonarSource radar Major
Task SONARPLUGINS-811 Migrate to parent-7 Major
Task SONARPLUGINS-800 Code cleanup and Unit tests Major
Improvement SONARPLUGINS-801 Add integration tests Major
Bug SONARPLUGINS-650 Length is misspelt in analysis data generated by sonar-web-plugin 0.1 Minor

 

Release 0.1 (5 issues)
Type Key Summary Priority
New Feature SONARPLUGINS-130 SONAR : JSP & HTML Analysis Major
New Feature SONARPLUGINS-638 New web rule : Every image should be provided with a proper alternative text Major
New Feature SONARPLUGINS-628 Create a first implementation of the CodeColorizer extension point to highlight the HTML syntax in the Sonar Code Viewer Major
Improvement SONARPLUGINS-625 Configurable file extensions Major
Task SONARPLUGINS-624 WebPlugin: Alpha Release 1 Major

Labels
  • None