Skip to content

Instantly share code, notes, and snippets.

@tsjensen
Last active August 25, 2017 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsjensen/9b34ed190de90a7c7b91 to your computer and use it in GitHub Desktop.
Save tsjensen/9b34ed190de90a7c7b91 to your computer and use it in GitHub Desktop.
How to sort exported SonarQube profile by repository and rule key

Sort exported SonarQube profile by repository and rule key

  1. Export SQ profile
  2. remove <profile> element, so that <rules> element is top level
  3. paste into http://www.freeformatter.com/xsl-transformer.html or http://integrationexpert.net/online-xslt-tool/
  4. paste xsl from below
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="rules">
    <xsl:copy>
      <xsl:apply-templates>
        <xsl:sort select="repositoryKey" data-type="text" order="ascending"/>
        <xsl:sort select="key" data-type="text" order="ascending"/>
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment