jimetevenard / Sonar-XSL-Plugin

A Schematron-based SonarQube plugin for XSL code quality measurement.

Home Page:http://www.sonarxsl.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sonar-XSL-Plugin

A Schematron-based SonarQube plugin for XSL code quality measurement.

Modifications

it brings the benefits of SonarQube to XSL projects :

  • Continuous Quality measurement
  • Interactive documentation of best-practices

How it works

This plugin runs an XSL-related Best-practice Schematron on each XSLT file of your project.

It embeds the xslt-quality schematron from @mricaud.
That Schematron Script, based on Mukul Gandhi's work, checks some common XSL pitfalls.

A few examples of rules :

  • Variables should be typed
  • The use of wildcard namespaces *: in xpath statements should be avoided
  • Using xsl:for-each on nodes may be a clue of procedural programming ; You should maybe consider using xsl:apply-templates instead
  • boolean true() or false()value should be used instead of litteral strings'true'and'false'`
  • Costly double-slash operator should be used with caution
  • Global variables (...) should have a namespace to improve the portability of your stylesheet
  • etc.

Since this plugin is open source, one can embed any additional Schematron script to support custom rules.

Build and install

The Sonar-XSL-Plugin is built via Maven.

Running mvn package will invoke the sonar-packaging-maven-plugin to build a SonarQube-Ready JAR file.

The JAR to be installed in SonarQube will be delivered at /sonar-xsl-plugin/target/sonar-xsl-plugin-1.x.x.jar

The process of installing a SonarQube plugin is documented here :
https://docs.sonarqube.org/latest/setup/install-plugin/, see § Manual Installation

Architecture / Extending

It embeds two main modules

Sonar-Schematron-Reactor

Makes the link between Schematron and the SonarQube API.

Cf. https://github.com/sonar-xsl/Sonar-Schematron-Reactor

Some Schematrons modules

Out of the box, the unique xslt-quality

Packaged for this plugin, via the dedicated Maven Plugin. (See module ./sonar-schematron-packaging-plugin)

This mechanism can be used to extend this plugin :

  1. Write some XSL-Related Schematron rules
  2. Package them with the plugin
  3. Add the resulting artifact as a dependency

So, does it actually works ?

👍 Yes, it works !

Still, there is some TODOs to fix :

See Issues and next Milestones

Realese and pushish !

As for now, if you wana try it, you have to build it locally from the sources.

The execution is quite slow...

NB : The actual implementation is based on the Skeleton XSLT implementation of ISO-Schematron.

Improve the integration with SonarQube

  • The native Code Duplication Detection does not work.
  • Highlighting from SonarSource/sonar-xml integrated in a quick-lazy way...

Improve the integration of xslt-quality ruleSet.

  • I need to package it and add some SonarQube-specific annotation.
  • For that purpose, I temporarily forked it
  • I'm working on a cleaner integration : Importing it as a Maven dependency, and then adding the annotations via XSLT.
  • The schematron may have itself some dependencies that needs to be resolved, so there is a little bit of work

Integration with the XSPEC Maven plugin

To bring XSLT code coverage into SonarQube

About

A Schematron-based SonarQube plugin for XSL code quality measurement.

http://www.sonarxsl.org/


Languages

Language:XSLT 74.4%Language:HTML 14.7%Language:Java 10.9%