Package org.sonar.api.profiles

Examples of org.sonar.api.profiles.RulesProfile


      this.asDefault = asDefault;
    }

    @Override
    public RulesProfile createProfile(ValidationMessages validation) {
      RulesProfile profile = RulesProfile.create(name, "xoo");
      profile.setDefaultProfile(asDefault);
      return profile;
    }
View Full Code Here


  private ListMultimap<QProfileName, RulesProfile> loadDefinitionsGroupedByName(String language) {
    ListMultimap<QProfileName, RulesProfile> profilesByName = ArrayListMultimap.create();
    for (ProfileDefinition definition : definitions) {
      ValidationMessages validation = ValidationMessages.create();
      RulesProfile profile = definition.createProfile(validation);
      if (language.equals(profile.getLanguage())) {
        processValidationMessages(validation);
        profilesByName.put(new QProfileName(profile.getLanguage(), profile.getName()), profile);
      }
    }
    return profilesByName;
  }
View Full Code Here

      return new String[]{"xoo"};
    }

    @Override
    public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
      RulesProfile rulesProfile = RulesProfile.create();
      Rule rule = Rule.create("xoo", "R1");
      rule.createParameter("acceptWhitespace");
      org.sonar.api.rules.ActiveRule activeRule = rulesProfile.activateRule(rule, RulePriority.CRITICAL);
      activeRule.setParameter("acceptWhitespace", "true");
      return rulesProfile;
    }
View Full Code Here

  }

  public static class XooProfileDefinition extends ProfileDefinition {
    @Override
    public RulesProfile createProfile(ValidationMessages validation) {
      RulesProfile profile = RulesProfile.create("P1", "xoo");
      profile.activateRule(new Rule("xoo", "R1"), RulePriority.BLOCKER).setParameter("acceptWhitespace", "true");
      return profile;
    }
View Full Code Here

      return new String[] {"xoo"};
    }

    @Override
    public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
      RulesProfile rulesProfile = RulesProfile.create();
      rulesProfile.activateRule(Rule.create("xoo", "R1"), RulePriority.CRITICAL);
      return rulesProfile;
    }
View Full Code Here

  @Test
  public void merge_profiles() throws Exception {
    QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java");
    when(qProfiles.findAll()).thenReturn(Arrays.asList(qProfile));

    RulesProfile profile = provider.provide(qProfiles, activeRules, ruleFinder, settings);

    // merge of all profiles
    assertThat(profile).isNotNull().isInstanceOf(RulesProfileWrapper.class);
    assertThat(profile.getLanguage()).isEqualTo("");
    assertThat(profile.getName()).isEqualTo("SonarQube");
    assertThat(profile.getActiveRules()).isEmpty();
    try {
      profile.getId();
      fail();
    } catch (IllegalStateException e) {
      // id must not be used at all
    }
  }
View Full Code Here

    settings.setProperty("sonar.language", "java");

    QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java");
    when(qProfiles.findByLanguage("java")).thenReturn(qProfile);

    RulesProfile profile = provider.provide(qProfiles, activeRules, ruleFinder, settings);

    // no merge, directly the old hibernate profile
    assertThat(profile).isNotNull();
    assertThat(profile.getLanguage()).isEqualTo("java");
    assertThat(profile.getName()).isEqualTo("Sonar way");
    ;
  }
View Full Code Here

    moduleB = new Project("moduleB").setParent(project);
    when(projectTree.getProjectDefinition(moduleB)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB")));
    moduleB1 = new Project("moduleB1").setParent(moduleB);
    when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1")));

    RulesProfile rulesProfile = RulesProfile.create();
    rule = Rule.create("repoKey", "ruleKey", "Rule");
    rule.setId(1);
    rulesProfile.activateRule(rule, null);
    index.setCurrentProject(project, mock(ModuleIssues.class));
    index.doStart(project);
  }
View Full Code Here

  @org.junit.Rule
  public ExpectedException thrown = ExpectedException.none();

  @Test
  public void createCheckWithoutProperties() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    ActiveRule activeRule = profile.activateRule(Rule.create("repo", "org.sonar.api.checks.CheckWithoutProperties", ""), null);
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithoutProperties.class));

    Object check = factory.getCheck(activeRule);
    assertNotNull(check);
    assertThat(check).isInstanceOf(CheckWithoutProperties.class);
View Full Code Here

    assertThat(check).isInstanceOf(CheckWithoutProperties.class);
  }

  @Test
  public void createCheckWithStringProperty() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", "");
    rule.createParameter("pattern");

    ActiveRule activeRule = profile.activateRule(rule, null);
    activeRule.setParameter("pattern", "foo");
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithStringProperty.class));

    Object check = factory.getCheck(activeRule);
    assertNotNull(check);
View Full Code Here

TOP

Related Classes of org.sonar.api.profiles.RulesProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.