Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-13782

It's not possible for a rule key to be deprecated twice

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 8.5
    • Component/s: Plugin API, Rules
    • Labels:
      None
    • Edition:
      Community
    • Production Notes:
      None

      Description

      Let's take the following versions of an analyzer plugin that declare a rule.

      1. This rule is originally declared with key "Legacy" :

          execute(context -> {
            NewRepository repo = context.createRepository("sq", "js");
            repo.createRule("Legacy")
              .setName(name)
              .setHtmlDescription(description);
            repo.done();
          });
      

      2. Then this rule is renamed to "NewTypo" in a next version :

          execute(context -> {
            NewRepository repo = context.createRepository("js", "js");
            repo.createRule("NewTypo")
              .setName(name)
              .setHtmlDescription(description)
              .addDeprecatedRuleKey("sq", "Legacy");
            repo.done();
          });
      

      3. Finally, the rule is renamed one last time to "NewCorrected" :

          execute(context -> {
            NewRepository repo = context.createRepository("js2", "js");
            repo.createRule("NewCorrected")
              .setName(name)
              .setHtmlDescription(description)
              .addDeprecatedRuleKey("sq", "Legacy")
              .addDeprecatedRuleKey("js", "NewTypo");
            repo.done();
          });
      

      (In this last case, the API need to reference the 2 previous keys in order to handle the use case when a user has moved directly from the first version to the latest one, without using the second one).

      With the last version, the startup of SonarQube will fail with the following error :

      java.lang.IllegalStateException: An incorrect state of deprecated rule keys has been detected.
       The deprecated rule key [sq:Legacy] was previously deprecated by [js:NewTypo]. [js:NewTypo] should be a deprecated key of [js2:NewCorrected],
      

        Attachments

          Activity

            People

            Assignee:
            duarte.meneses Duarte Meneses
            Reporter:
            julien.lancelot Julien Lancelot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: