Search code examples
sonarqubesonarqube-4.5sonarqube-web

SonarQube: Copy of Quality Profile is Missing Rules


I tried to create an exact copy of of our default SonarQube quality profile by clicking on the "Copy" link in the "Quality Profiles" page, but some of the rules are not copied. We use SonarQube version 4.5.6 and the profile I tried to copy does not inherit from any other profiles.

According to the SonarQube documentation, the new profile is an exact copy of the original profile, including inheritance (parent) relationships. However, my copied profile is missing the following 9 rules out of 487 and I don't see any reason why (they are all 'checkstyle' rules, but there's many more with the same label that got copied correctly):

  1. Boolean Expression Complexity (checkstyle)
  2. Comment pattern matcher (checkstyle)
  3. Constant Name (checkstyle)
  4. Hidden Field (checkstyle)
  5. Inner Assignment (checkstyle)
  6. Local Variable Name (checkstyle)
  7. Magic Number (checkstyle)
  8. Member name (checkstyle)
  9. Static Variable Name (checkstyle)

Solution

  • The rules you name are all template rules, i.e. rule "cookie cutters" from which you can stamp many rule variations. Unfortunately, rules created from templates, a.k.a. "custom rules", aren't properly handled in profile backup and restore.

    This is currently scheduled for the 6.x series. The Jira ticket is SONAR-5366.