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
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.
- 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 usingxsl: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.
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
It embeds two main modules
Makes the link between Schematron and the SonarQube API.
Cf. https://github.com/sonar-xsl/Sonar-Schematron-Reactor
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 :
- Write some XSL-Related Schematron rules
- Package them with the plugin
- Add the resulting artifact as a dependency
👍 Yes, it works !
See Issues and next Milestones
- Make a release
- Publish it somewhere (Maven central ?)
- Produce a Docker image to test fastly, and publish it on Docker Hub (see https://github.com/sonar-xsl/Sonar-XSL-Plugin/milestone/1)
As for now, if you wana try it, you have to build it locally from the sources.
NB : The actual implementation is based on the Skeleton XSLT implementation of ISO-Schematron.
- 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
To bring XSLT code coverage into SonarQube