RulesProfile.getActiveRule
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.sonar.api.profiles.RulesProfile.getActiveRule(Showing top 15 results out of 315)

  • Common ways to obtain RulesProfile
private void myMethod () {
RulesProfile r =
  • new RulesProfile()
  • String name;RulesProfile.create(name, language)
  • AI code suggestions by Codota
}
origin: SonarSource/sonarqube

@Override
public ActiveRule getActiveRule(Rule rule) {
 for (RulesProfile profile : profiles) {
  ActiveRule activeRule = profile.getActiveRule(rule);
  if (activeRule != null) {
   return activeRule;
  }
 }
 return null;
}
origin: SonarSource/sonarqube

@Test
public void importProfileWithRuleParameters() {
 ValidationMessages validation = ValidationMessages.create();
 RulesProfile profile = parse("importProfileWithRuleParameters.xml", validation);
 assertThat(validation.hasErrors()).isFalse();
 assertThat(validation.hasWarnings()).isFalse();
 ActiveRule rule = profile.getActiveRule("checkstyle", "IllegalRegexp");
 assertThat(rule.getParameter("format")).isEqualTo("foo");
 assertThat(rule.getParameter("message")).isEqualTo("with special characters < > &");
}
origin: SonarSource/sonarqube

 @Test
 public void support_rule_templates() {
  QProfile qProfile = new QProfile("java-sw", "Sonar way", "java", null);
  when(qProfiles.findAll()).thenReturn(Arrays.asList(qProfile));
  ActiveRulesBuilder activeRulesBuilder = new ActiveRulesBuilder();
  activeRulesBuilder.create(RuleKey.of("java", "S001")).setTemplateRuleKey("T001").setLanguage("java").activate();

  RulesProfile profile = provider.provide(qProfiles, activeRulesBuilder.build(), settings.asConfig());

  assertThat(profile.getActiveRule("java", "S001").getRule().getTemplate().getKey()).isEqualTo("T001");
 }
}
origin: SonarSource/sonarqube

@Test
public void activateRuleWithSpecificPriority() {
 RulesProfile profile = RulesProfile.create();
 Rule rule = Rule.create("repo", "key1", "name1").setSeverity(RulePriority.CRITICAL);
 profile.activateRule(rule, RulePriority.MINOR);
 assertThat(profile.getActiveRule("repo", "key1").getSeverity()).isEqualTo(RulePriority.MINOR);
}
origin: SonarSource/sonarqube

@Test
public void importProfile() {
 ValidationMessages validation = ValidationMessages.create();
 RulesProfile profile = parse("importProfile.xml", validation);
 assertThat(profile.getLanguage()).isEqualTo("java");
 assertThat(profile.getName()).isEqualTo("sonar way");
 assertThat(validation.hasErrors()).isFalse();
 assertThat(profile).isNotNull();
 assertThat(profile.getActiveRule("checkstyle", "IllegalRegexp").getSeverity()).isEqualTo(RulePriority.CRITICAL);
}
origin: SonarSource/sonarqube

/**
 * Note: disabled rules are excluded.
 */
@CheckForNull
public ActiveRule getActiveRule(Rule rule) {
 return getActiveRule(rule.getRepositoryKey(), rule.getKey());
}
origin: SonarSource/sonarqube

@Test
public void importProfileWithUnknownRuleParameter() {
 ValidationMessages validation = ValidationMessages.create();
 RulesProfile profile = parse("importProfileWithUnknownRuleParameter.xml", validation);
 assertThat(validation.getWarnings()).hasSize(1);
 ActiveRule rule = profile.getActiveRule("checkstyle", "IllegalRegexp");
 assertThat(rule.getParameter("unknown")).isNull();
}
origin: SonarSource/sonarqube

 @Test
 public void shouldParseOnlyWantedProfile() {
  RuleFinder ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
   public Rule answer(InvocationOnMock iom) throws Throwable {
    return Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
   }
  });

  ValidationMessages messages = ValidationMessages.create();
  RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.<Class>newArrayList(FakeRule.class, RuleOnOtherProfile.class), messages);

  assertThat(profile.getActiveRule("squid", "fake")).isNotNull();
  assertThat(profile.getActiveRule("squid", "other")).isNull();
 }
}
origin: SonarSource/sonarqube

@Test
public void shouldParseAnnotatedClasses() {
 RuleFinder ruleFinder = mock(RuleFinder.class);
 when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
  public Rule answer(InvocationOnMock iom) throws Throwable {
   return Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
  }
 });
 ValidationMessages messages = ValidationMessages.create();
 RulesProfile profile = new AnnotationProfileParser(ruleFinder).parse("squid", "Foo way", "java", Lists.<Class>newArrayList(FakeRule.class), messages);
 assertThat(profile.getName()).isEqualTo("Foo way");
 assertThat(profile.getLanguage()).isEqualTo("java");
 assertThat(profile.getActiveRule("squid", "fake").getSeverity()).isEqualTo(RulePriority.BLOCKER);
 assertThat(messages.hasErrors()).isFalse();
}
origin: SonarSource/sonarqube

@Override
public ActiveRule getActiveRule(String repositoryKey, String ruleKey) {
 for (RulesProfile profile : profiles) {
  ActiveRule activeRule = profile.getActiveRule(repositoryKey, ruleKey);
  if (activeRule != null) {
   return activeRule;
  }
 }
 return null;
}
origin: SonarSource/sonarqube

@Test
public void activateRuleWithDefaultPriority() {
 RulesProfile profile = RulesProfile.create();
 Rule rule = Rule.create("repo", "key1", "name1").setSeverity(RulePriority.CRITICAL);
 profile.activateRule(rule, null);
 assertThat(profile.getActiveRule("repo", "key1").getSeverity()).isEqualTo(RulePriority.CRITICAL);
}
origin: org.codehaus.sonar/sonar-plugin-api

/**
 * Note: disabled rules are excluded.
 */
@CheckForNull
public ActiveRule getActiveRule(Rule rule) {
 return getActiveRule(rule.getRepositoryKey(), rule.getKey());
}
origin: org.sonarsource.sonarqube/sonar-plugin-api

/**
 * Note: disabled rules are excluded.
 */
@CheckForNull
public ActiveRule getActiveRule(Rule rule) {
 return getActiveRule(rule.getRepositoryKey(), rule.getKey());
}
origin: org.codehaus.sonar/sonar-batch

@Override
public ActiveRule getActiveRule(String repositoryKey, String ruleKey) {
 for (RulesProfile profile : profiles) {
  ActiveRule activeRule = profile.getActiveRule(repositoryKey, ruleKey);
  if (activeRule != null) {
   return activeRule;
  }
 }
 return null;
}
origin: org.codehaus.sonar/sonar-batch

@Override
public ActiveRule getActiveRule(Rule rule) {
 for (RulesProfile profile : profiles) {
  ActiveRule activeRule = profile.getActiveRule(rule);
  if (activeRule != null) {
   return activeRule;
  }
 }
 return null;
}
org.sonar.api.profilesRulesProfilegetActiveRule

Javadoc

Note: disabled rules are excluded.

Popular methods of RulesProfile

  • activateRule
  • create
  • getActiveRules
  • getName
  • getLanguage
  • setName
    Set the profile name.
  • setLanguage
    Set the profile language
  • setDefaultProfile
    Set whether this is the default profile for the language. The default profile is used when none is e
  • <init>
  • getDefaultProfile
  • getActiveRulesByRepository
    Get the active rules of a specific repository. Only enabled rules are selected. Disabled rules are e
  • getId
  • getActiveRulesByRepository,
  • getId,
  • equals,
  • hashCode,
  • setActiveRules,
  • addActiveRule,
  • getActiveRuleByConfigKey,
  • getParentName,
  • setParentName

Popular classes and methods

  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • getExternalFilesDir (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • ArrayList (java.util)
    Resizable-array implementation of the List interface.
  • LinkedList (java.util)
    Linked list implementation. [Sun docs] [http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)