mulesoft-catalyst / mule-sonarqube-plugin

The Mule SonarQube Plugin provides the capability to do code inspecting and taking project metrics from a mule project using SonarQube.
The Unlicense
46 stars 68 forks source link

Support for using javax.xml #49

Open trentbowman opened 2 years ago

trentbowman commented 2 years ago

This PR adds support for rules which use the standard javax.xml XML libraries instead of jdom2. This directly addresses two issues in the issue tracker (https://github.com/mulesoft-catalyst/mule-sonarqube-plugin/issues/23, https://github.com/mulesoft-catalyst/mule-sonarqube-plugin/issues/15) and possibly several others. Benefits include:

  1. Writing one XPath to both find rule-violating nodes (elements, attributes, etc.) and to determine their locations
  2. Multiple violations per rule per file can be tracked and displayed in sonar

Major changes to the plugin include:

  1. Introducing versioning to the rules themselves. Rules that previously existed are implicitly considered 1.0 rules and continue to use the jdom2 code paths and should should work exactly as before. Rules that explicitly declare a version of 1.1 use the javax.xml code paths. This versioning allows users to upgrade the plugin and incrementally move their rules over to 1.1.
  2. Defining a new rule scope called node, and then slightly changing the interpretation of the existing scopes for v1.1 rules:
    • application scope rules must evaluate to true for at least one file, or an issue will be created.
    • file scope rules must evaluate to true or an issue at the file level will be create.
    • node scope rules should select nodes (elements, attributes, comments, etc.) which are not in compliance. An issue will be created for each node returned.
  3. Existing rules in rules-4.xml have been migrated to v1.1
  4. An additional rules file, named rules-4-custom.xml, is loaded. along with the standard rules file. This allows users to write their own built-in rules without needing to change a source file.