Tabnine Logo
Rule.getSeverity
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: SonarSource/sonarqube

/**
 * @deprecated visibility should be reduced to protected or package
 */
@Deprecated
public ActiveRule(RulesProfile profile, Rule rule, RulePriority severity) {
 this.rule = rule;
 this.overriddenSeverity = severity;
 if (severity == null && rule != null) {
  this.severity = rule.getSeverity();
 } else {
  this.severity = severity;
 }
 this.rulesProfile = profile;
}
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 rule_without_key() {
 List<Rule> rules = parseAnnotatedClass(RuleWithoutKey.class);
 assertThat(rules).hasSize(1);
 Rule rule = rules.get(0);
 assertThat(rule.getKey()).isEqualTo(RuleWithoutKey.class.getCanonicalName());
 assertThat(rule.getName()).isEqualTo("foo");
 assertThat(rule.getDescription()).isNull();
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
}
origin: SonarSource/sonarqube

@Test
public void overridden_rule() {
 List<Rule> rules = parseAnnotatedClass(OverridingRule.class);
 assertThat(rules).hasSize(1);
 Rule rule = rules.get(0);
 assertThat(rule.getKey()).isEqualTo("overriding_foo");
 assertThat(rule.getName()).isEqualTo("Overriding Foo");
 assertThat(rule.getDescription()).isNull();
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
 assertThat(rule.getParams()).hasSize(2);
}
origin: SonarSource/sonarqube

@Test
public void rule_without_name_nor_description() {
 List<Rule> rules = parseAnnotatedClass(RuleWithoutNameNorDescription.class);
 assertThat(rules).hasSize(1);
 Rule rule = rules.get(0);
 assertThat(rule.getKey()).isEqualTo("foo");
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
 assertThat(rule.getName()).isNull();
 assertThat(rule.getDescription()).isNull();
}
origin: SonarSource/sonarqube

@Test
public void rule_with_property() {
 List<Rule> rules = parseAnnotatedClass(RuleWithProperty.class);
 assertThat(rules).hasSize(1);
 Rule rule = rules.get(0);
 assertThat(rule.getKey()).isEqualTo("foo");
 assertThat(rule.getName()).isEqualTo("bar");
 assertThat(rule.getDescription()).isEqualTo("Foo Bar");
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.BLOCKER);
 assertThat(rule.getStatus()).isEqualTo(Rule.STATUS_READY);
 assertThat(rule.getParams()).hasSize(1);
 RuleParam prop = rule.getParam("property");
 assertThat(prop.getKey()).isEqualTo("property");
 assertThat(prop.getDescription()).isEqualTo("Ignore ?");
 assertThat(prop.getDefaultValue()).isEqualTo("false");
 assertThat(prop.getType()).isEqualTo(PropertyType.STRING.name());
}
origin: SonarSource/sonarqube

 private void verifyRule(Rule rule, RuleDefinitionDto ruleDefinition, RuleParamDto ruleParam) {
  assertThat(rule).isNotNull();

  assertThat(rule.getName()).isEqualTo(ruleDefinition.getName());
  assertThat(rule.getLanguage()).isEqualTo(ruleDefinition.getLanguage());
  assertThat(rule.getKey()).isEqualTo(ruleDefinition.getRuleKey());
  assertThat(rule.getConfigKey()).isEqualTo(ruleDefinition.getConfigKey());
  assertThat(rule.isTemplate()).isEqualTo(ruleDefinition.isTemplate());
  assertThat(rule.getCreatedAt().getTime()).isEqualTo(ruleDefinition.getCreatedAt());
  assertThat(rule.getUpdatedAt().getTime()).isEqualTo(ruleDefinition.getUpdatedAt());
  assertThat(rule.getRepositoryKey()).isEqualTo(ruleDefinition.getRepositoryKey());
  assertThat(rule.getSeverity().name()).isEqualTo(ruleDefinition.getSeverityString());
  assertThat(rule.getSystemTags()).isEqualTo(ruleDefinition.getSystemTags().stream().toArray(String[]::new));
  assertThat(rule.getTags()).isEmpty();
  assertThat(rule.getId()).isEqualTo(ruleDefinition.getId());
  assertThat(rule.getDescription()).isEqualTo(ruleDefinition.getDescription());

  assertThat(rule.getParams()).hasSize(1);
  org.sonar.api.rules.RuleParam param = rule.getParams().iterator().next();
  assertThat(param.getRule()).isSameAs(rule);
  assertThat(param.getKey()).isEqualTo(ruleParam.getName());
  assertThat(param.getDescription()).isEqualTo(ruleParam.getDescription());
  assertThat(param.getType()).isEqualTo(ruleParam.getType());
  assertThat(param.getDefaultValue()).isEqualTo(ruleParam.getDefaultValue());
 }
}
origin: SonarSource/sonarqube

newRule.setInternalKey(rule.getConfigKey());
newRule.setTemplate(rule.isTemplate());
newRule.setSeverity(rule.getSeverity().toString());
newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
origin: org.codehaus.sonar/sonar-plugin-api

/**
 * @deprecated visibility should be reduced to protected or package
 */
@Deprecated
public ActiveRule(RulesProfile profile, Rule rule, RulePriority severity) {
 this.rule = rule;
 if (severity == null && rule != null) {
  this.severity = rule.getSeverity();
 } else {
  this.severity = severity;
 }
 this.rulesProfile = profile;
}
origin: org.sonarsource.sonarqube/sonar-plugin-api

/**
 * @deprecated visibility should be reduced to protected or package
 */
@Deprecated
public ActiveRule(RulesProfile profile, Rule rule, RulePriority severity) {
 this.rule = rule;
 this.overriddenSeverity = severity;
 if (severity == null && rule != null) {
  this.severity = rule.getSeverity();
 } else {
  this.severity = severity;
 }
 this.rulesProfile = profile;
}
origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-gendarme-plugin

private Violation createViolationOnResource(Resource<?> resource, Integer lineNumber) {
 if (StringUtils.isNotEmpty(currentSource) && resource == null) {
  LOG.debug("Ignoring violation on file outside current project ({})", currentSource);
  return null;
 }
 if (resource != null && !resourceHelper.isResourceInProject(resource, project)) {
  LOG.debug("Ignoring violation on file outside current project ({})", resource.getKey());
  return null;
 }
 Violation violation = Violation.create(currentRule, resource);
 if (lineNumber != null) {
  violation.setLineId(lineNumber);
 }
 if (StringUtils.isEmpty(currentMessage)) {
  violation.setMessage(currentDefaultViolationMessage);
 } else {
  violation.setMessage(currentMessage);
 }
 violation.setSeverity(currentRule.getSeverity());
 context.saveViolation(violation);
 return violation;
}
origin: org.codehaus.sonar/sonar-plugin-api

/**
 * @param optionalSeverity if null, then the default rule severity is used
 */
public ActiveRule activateRule(final Rule rule, @Nullable RulePriority optionalSeverity) {
 if (Iterables.any(activeRules, new Predicate<ActiveRule>() {
  @Override
  public boolean apply(ActiveRule input) {
   return input.getRule().equals(rule);
  }
 })) {
  throw MessageException.of(String.format(
   "The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.",
   getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey()));
 }
 ActiveRule activeRule = new ActiveRule();
 activeRule.setRule(rule);
 activeRule.setRulesProfile(this);
 activeRule.setSeverity(optionalSeverity == null ? rule.getSeverity() : optionalSeverity);
 activeRules.add(activeRule);
 return activeRule;
}
origin: fabriciocolombo/sonar-delphi

private static ActiveRule createActiveRule(DelphiRule fRule, List<Rule> rulesRepository) {
 String name = fRule.getName();
 RulePriority fRulePriority = severityFromLevel(fRule.getPriority());
 for (Rule rule : rulesRepository) {
  if (rule.getKey().equals(name)) {
   RulePriority priority = fRulePriority != null ? fRulePriority : rule.getSeverity();
   ActiveRule activeRule = new ActiveRule(null, rule, priority);
   activeRule.setActiveRuleParams(buildActiveRuleParams(fRule, rule, activeRule));
   return activeRule;
  }
 }
 return null;
}
origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-fxcop-plugin

private void createViolationFromMessageAtProjectLevel(SMInputCursor messagesCursor) throws XMLStreamException {
 Rule currentRule = ruleFinder.find(RuleQuery.create().withRepositoryKey(repositoryKey)
   .withKey(messagesCursor.getAttrValue(TYPENAME)));
 if (currentRule != null) {
  // the violation is saved at project level, not on a specific resource
  Violation violation = Violation.create(currentRule, project);
  violation.setMessage(messagesCursor.collectDescendantText().trim());
  violation.setSeverity(currentRule.getSeverity());
  context.saveViolation(violation);
 } else {
  LOG.debug("Could not find the following rule in the FxCop rule repository: " + messagesCursor.getAttrValue(TYPENAME));
 }
}
origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-fxcop-plugin

violation.setSeverity(currentRule.getSeverity());
context.saveViolation(violation);
origin: fabriciocolombo/sonar-delphi

@Override
public void define(Context context) {
 NewRepository repository = context
  .createRepository(DelphiPmdConstants.REPOSITORY_KEY, DelphiLanguage.KEY)
  .setName(DelphiPmdConstants.REPOSITORY_NAME);
 List<org.sonar.api.rules.Rule> rules = DelphiRulesUtils.getInitialReferential();
 // TODO Review
 // https://github.com/SonarCommunity/sonar-pmd/blob/master/src/main/java/org/sonar/plugins/pmd/PmdRulesDefinition.java
 for (org.sonar.api.rules.Rule rule : rules) {
  NewRule newRule = repository.createRule(rule.getKey())
   .setName(rule.getName())
   .setHtmlDescription(rule.getDescription())
   .setInternalKey(rule.getConfigKey())
   .setSeverity(rule.getSeverity().name());
  for (RuleParam param : rule.getParams()) {
   newRule.createParam(param.getKey())
    .setDefaultValue(param.getDefaultValue())
    .setType(RuleParamType.parse(param.getType()))
    .setDescription(param.getDescription());
  }
 }
 SqaleXmlLoader.load(repository, "/org/sonar/plugins/delphi/sqale/delphi-model.xml");
 repository.done();
}
origin: org.sonarsource.sonarqube/sonar-server

newRule.setInternalKey(rule.getConfigKey());
newRule.setTemplate(rule.isTemplate());
newRule.setSeverity(rule.getSeverity().toString());
newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
org.sonar.api.rulesRulegetSeverity

Popular methods of Rule

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

Popular in Java

  • Creating JSON documents from java classes using gson
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Path (java.nio.file)
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • JFrame (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now