Codota Logo
Rule.create
Code IndexAdd Codota to your IDE (free)

How to use
create
method
in
org.sonar.api.rules.Rule

Best Java code snippets using org.sonar.api.rules.Rule.create (Showing top 20 results out of 315)

  • Common ways to obtain Rule
private void myMethod () {
Rule r =
  • Codota IconRuleFinder ruleFinder;String repositoryKey;String key;ruleFinder.findByKey(repositoryKey, key)
  • Codota IconRule.create()
  • Codota Iconnew Rule()
  • Smart code suggestions by Codota
}
origin: SonarSource/sonarqube

 @Override
 public RulesProfile createProfile(ValidationMessages validation) {
  final RulesProfile profile = RulesProfile.create("Sonar way", Xoo.KEY);

  profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR);
  profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, OneIssuePerLineSensor.RULE_KEY), RulePriority.INFO);
  profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, OneIssuePerFileSensor.RULE_KEY), RulePriority.CRITICAL);
  profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HotspotSensor.RULE_KEY), RulePriority.CRITICAL);

  return profile;
 }
}
origin: SonarSource/sonarqube

 @Override
 public List<Rule> createRules() {
  Rule rule = Rule.create("checkstyle", "ConstantName");
  rule.createParameter("format");
  return Arrays.asList(rule);
 }
}
origin: SonarSource/sonarqube

 @Override
 public RulesProfile createProfile(ValidationMessages messages) {
  RulesProfile profile = RulesProfile.create("Sonar way", Xoo2.KEY);

  profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR);
  profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, OneIssuePerLineSensor.RULE_KEY), RulePriority.MINOR);

  return profile;
 }
}
origin: SonarSource/sonarqube

 public Rule answer(InvocationOnMock iom) throws Throwable {
  Rule rule = Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
  rule.createParameter("format");
  rule.createParameter("message");
  return rule;
 }
});
origin: SonarSource/sonarqube

 @Override
 public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
  RulesProfile rulesProfile = RulesProfile.create();
  rulesProfile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, "x1"), RulePriority.CRITICAL);
  return rulesProfile;
 }
}
origin: SonarSource/sonarqube

 @Override
 public List<Rule> createRules() {
  Rule rule = Rule.create("checkstyle", "ConstantName", "Constant Name");
  rule.setDescription("Checks that constant names conform to the specified format");
  rule.setConfigKey("Checker/TreeWalker/ConstantName");
  rule.setSeverity(RulePriority.BLOCKER);
  rule.setStatus(Rule.STATUS_BETA);
  rule.setTags(new String[] {"style", "clumsy"});
  rule.createParameter("format").setDescription("Regular expression").setDefaultValue("A-Z").setType("REGULAR_EXPRESSION");
  return Arrays.asList(rule);
 }
}
origin: SonarSource/sonarqube

 @Override
 public RulesProfile createProfile(ValidationMessages messages) {
  RulesProfile profile = RulesProfile.create("Basic", Xoo2.KEY);
  profile.setDefaultProfile(true);

  // so UGLY
  profile.activateRule(Rule.create(XooRulesDefinition.XOO2_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR);

  return profile;
 }
}
origin: SonarSource/sonarqube

 @Override
 public RulesProfile createProfile(ValidationMessages validation) {
  final RulesProfile profile = RulesProfile.create("Basic", Xoo.KEY);
  profile.setDefaultProfile(true);

  profile.activateRule(Rule.create(XooRulesDefinition.XOO_REPOSITORY, HasTagSensor.RULE_KEY), RulePriority.MAJOR);

  return profile;
 }
}
origin: SonarSource/sonarqube

@Test
public void should_set_valid_status() {
 Rule rule = Rule.create().setStatus(Rule.STATUS_DEPRECATED);
 assertThat(rule.getStatus()).isEqualTo(Rule.STATUS_DEPRECATED);
 rule = Rule.create().setStatus(Rule.STATUS_REMOVED);
 assertThat(rule.getStatus()).isEqualTo(Rule.STATUS_REMOVED);
 rule = Rule.create().setStatus(Rule.STATUS_BETA);
 assertThat(rule.getStatus()).isEqualTo(Rule.STATUS_BETA);
 rule = Rule.create().setStatus(Rule.STATUS_READY);
 assertThat(rule.getStatus()).isEqualTo(Rule.STATUS_READY);
}
origin: SonarSource/sonarqube

 @Override
 public RulesProfile createProfile(ValidationMessages validation) {
  RulesProfile profile1 = RulesProfile.create("Profile 1", "xoo");
  profile1.activateRule(Rule.create("repo1", "defaultSeverity"), null);
  profile1.activateRule(Rule.create("repo1", "overrideSeverity"), RulePriority.CRITICAL);
  Rule ruleWithParam = Rule.create("repo1", "overrideParam");
  ruleWithParam.setParams(Arrays.asList(new RuleParam(ruleWithParam, "param", "", "")));
  ActiveRule arWithParam = profile1.activateRule(ruleWithParam, null);
  arWithParam.setParameter("param", "value");
  return profile1;
 }
}
origin: SonarSource/sonarqube

@Test
public void default_priority_is_major() {
 Rule rule = Rule.create();
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
 rule = new Rule("name", "key");
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
 rule.setSeverity(RulePriority.BLOCKER);
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.BLOCKER);
 rule.setSeverity(null);
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
}
origin: SonarSource/sonarqube

@Test
public void should_remove_new_line_characters_in_name_with_setter() {
 Rule rule = Rule.create();
 for (String example : getExamplesContainingNewLineCharacter()) {
  rule.setName(example);
  assertThat(rule.getName()).isEqualTo("test");
 }
}
origin: SonarSource/sonarqube

@Test
public void searchRulesByConfigKey() {
 RulesProfile profile = RulesProfile.create();
 profile.activateRule(Rule.create("repo", "key1", "name1"), null);
 profile.activateRule(Rule.create("repo", "key2", "name2").setConfigKey("config2"), null);
 assertThat(profile.getActiveRuleByConfigKey("repo", "unknown")).isNull();
 assertThat(profile.getActiveRuleByConfigKey("repo", "config2").getRuleKey()).isEqualTo("key2");
}
origin: SonarSource/sonarqube

@Test
public void shouldMatchRule() {
 RuleKey rule = Rule.create("checkstyle", "IllegalRegexp", "").ruleKey();
 assertThat(new IssuePattern("*", "*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "checkstyle:*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "checkstyle:IllegalRegexp").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "checkstyle:Illegal*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "*:*Illegal*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "pmd:IllegalRegexp").matchRule(rule)).isFalse();
 assertThat(new IssuePattern("*", "pmd:*").matchRule(rule)).isFalse();
 assertThat(new IssuePattern("*", "*:Foo*IllegalRegexp").matchRule(rule)).isFalse();
}
origin: SonarSource/sonarqube

@Test
public void match_rule() {
 RuleKey rule = Rule.create("checkstyle", "IllegalRegexp", "").ruleKey();
 assertThat(new IssuePattern("*", "*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "checkstyle:*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "checkstyle:IllegalRegexp").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "checkstyle:Illegal*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "*:*Illegal*").matchRule(rule)).isTrue();
 assertThat(new IssuePattern("*", "pmd:IllegalRegexp").matchRule(rule)).isFalse();
 assertThat(new IssuePattern("*", "pmd:*").matchRule(rule)).isFalse();
 assertThat(new IssuePattern("*", "*:Foo*IllegalRegexp").matchRule(rule)).isFalse();
}
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: 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 exportProfile() throws IOException, SAXException {
 Writer writer = new StringWriter();
 RulesProfile profile = RulesProfile.create("sonar way", "java");
 profile.activateRule(Rule.create("checkstyle", "IllegalRegexp", "illegal regexp"), RulePriority.BLOCKER);
 new XMLProfileSerializer().write(profile, writer);
 assertSimilarXml("exportProfile.xml", writer.toString());
}
origin: SonarSource/sonarqube

 @Override
 public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
  RulesProfile rulesProfile = RulesProfile.create();
  rulesProfile.activateRule(Rule.create(rule.getRepositoryKey(), rule.getRuleKey()), RulePriority.CRITICAL);
  return rulesProfile;
 }
}
origin: SonarSource/sonarqube

@Test
public void description_should_be_cleaned() {
 Rule rule = Rule.create().setDescription("    my description         ");
 Assert.assertEquals("my description", rule.getDescription());
 rule.setDescription(null);
 assertThat(rule.getDescription()).isNull();
}
org.sonar.api.rulesRulecreate

Javadoc

Create with all required fields

Popular methods of Rule

  • getKey
  • getConfigKey
  • setConfigKey
    Sets the configuration key
  • setName
    Sets the rule name
  • setSeverity
  • getName
  • getRepositoryKey
  • ruleKey
  • setDescription
    Sets the rule description
  • createParameter
  • getSeverity
  • setTags
    For definition of rule only
  • getSeverity,
  • setTags,
  • <init>,
  • getParam,
  • getParams,
  • setKey,
  • setStatus,
  • getDescription,
  • setRepositoryKey

Popular in Java

  • Updating database using SQL prepared statement
  • getSharedPreferences (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • Notification (javax.management)
  • JFrame (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now