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

Setting a profile to default via the API doesn't seem to work

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.11
    • Fix Version/s: 3.0
    • Component/s: Plugin API, Quality Profile
    • Labels:
      None

      Description

      I made tests with the PHP plugin, where I have several profiles. Here's the code of the profile I want to be the defualt one:

      ...
      public final class SonarWayProfile extends ProfileDefinition {
      
        private final XMLProfileParser parser;
      
        public SonarWayProfile(XMLProfileParser parser) {
          this.parser = parser;
        }
      
        @Override
        public RulesProfile createProfile(ValidationMessages messages) {
          RulesProfile profile = parser.parseResource(getClass().getClassLoader(), "org/sonar/plugins/php/profiles/sonar-way-profile.xml", messages);
          profile.setDefaultProfile(true);
          return profile;
        }
      }
      

      The only way I managed to make the Sonar PHP way profile to be the default one when starting Sonar on a fresh DB was:

      • to rename it to "Sonar Way"
      • and to declare the class in the first position in the Plugin#getExtensions (I mean before the other profile classes)

        Attachments

          Activity

            People

            Assignee:
            fabemn OLD - Fabrice Bellingard
            Reporter:
            fabemn OLD - Fabrice Bellingard
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: