congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Rule.getParam
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: SonarSource/sonarqube

public ActiveRule setParameter(String key, String value) {
 RuleParam ruleParameter = rule.getParam(key);
 if (ruleParameter != null) {
  activeRuleParams.add(new ActiveRuleParam(this, ruleParameter, value));
 }
 return this;
}
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

@Test
public void rule_with_text_property() {
 List<Rule> rules = parseAnnotatedClass(RuleWithTextProperty.class);
 RuleParam prop = rules.get(0).getParam("property");
 assertThat(prop.getDescription()).isEqualTo("text");
 assertThat(prop.getDefaultValue()).isEqualTo("Long text");
 assertThat(prop.getType()).isEqualTo(PropertyType.TEXT.name());
}
origin: SonarSource/sonarqube

ActiveRule activeRule = profile.activateRule(rule, priority);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
 if (rule.getParam(entry.getKey()) == null) {
  messages.addWarningText("The parameter '" + entry.getKey() + "' does not exist in the rule: " + ruleToString(repositoryKey, key));
 } else {
origin: SonarSource/sonarqube

@Test
public void rule_with_integer_property() {
 List<Rule> rules = parseAnnotatedClass(RuleWithIntegerProperty.class);
 RuleParam prop = rules.get(0).getParam("property");
 assertThat(prop.getDescription()).isEqualTo("Max");
 assertThat(prop.getDefaultValue()).isEqualTo("12");
 assertThat(prop.getType()).isEqualTo(PropertyType.INTEGER.name());
}
origin: org.sonarsource.sonarqube/sonar-plugin-api

public ActiveRule setParameter(String key, String value) {
 RuleParam ruleParameter = rule.getParam(key);
 if (ruleParameter != null) {
  activeRuleParams.add(new ActiveRuleParam(this, ruleParameter, value));
 }
 return this;
}
origin: org.codehaus.sonar/sonar-plugin-api

public ActiveRule setParameter(String key, String value) {
 RuleParam ruleParameter = rule.getParam(key);
 if (ruleParameter != null) {
  activeRuleParams.add(new ActiveRuleParam(this, ruleParameter, value));
 }
 return this;
}
origin: org.codehaus.sonar.common-rules/sonar-common-rules

DefaultCommonRulesRepository enableRule(String ruleKey, Map<String, String> params) {
 Rule rule = supportedRulesByKey.get(ruleKey);
 if (rule == null) {
  throw new IllegalStateException("Unknown rule: " + ruleKey);
 }
 for (Map.Entry<String, String> entry : params.entrySet()) {
  String paramKey = entry.getKey();
  RuleParam param = rule.getParam(paramKey);
  if (param == null) {
   throw new IllegalStateException(String.format("Rule '%s' has no parameter named '%s'", ruleKey, paramKey));
  }
  param.setDefaultValue(entry.getValue());
 }
 rules.add(rule);
 return this;
}
origin: org.codehaus.sonar-plugins/sonar-php-plugin

/**
 * @param messages
 * @param pmdRule
 * @param key
 * @param rule
 * @param activeRule
 */
private void createRule(ValidationMessages messages, PmdRule pmdRule, String key, Rule rule, ActiveRule activeRule) {
 for (PmdProperty prop : pmdRule.getProperties()) {
  String name = prop.getName();
  if (rule.getParam(name) != null) {
   String value = prop.getValue();
   String ruleValue = prop.isCdataValue() && isBlank(value) ? prop.getCdataValue() : value;
   activeRule.setParameter(name, ruleValue);
  } else {
   StringBuilder message = new StringBuilder("The property '").append(name);
   message.append("' is not supported in the PhpCodeSniffer rule: ").append(key);
   messages.addWarningText(message.toString());
  }
 }
}
origin: org.codehaus.sonar/sonar-plugin-api

ActiveRule activeRule = profile.activateRule(rule, priority);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
 if (rule.getParam(entry.getKey()) == null) {
  messages.addWarningText("The parameter '" + entry.getKey() + "' does not exist in the rule: " + ruleToString(repositoryKey, key));
 } else {
origin: org.codehaus.sonar-plugins/sonar-php-plugin

/**
 * @param messages
 * @param profile
 * @param pmdRule
 * @param configKey
 * @param rule
 */
private void createRule(ValidationMessages messages, RulesProfile profile, PmdRule pmdRule, String configKey, Rule rule) {
 PmdRulePriorityMapper mapper = new PmdRulePriorityMapper();
 ActiveRule activeRule = profile.activateRule(rule, mapper.from(pmdRule.getPriority()));
 if (pmdRule.getProperties() != null) {
  for (PmdProperty prop : pmdRule.getProperties()) {
   String name = prop.getName();
   if (rule.getParam(name) != null) {
    String value = prop.getValue();
    String ruleValue = prop.isCdataValue() && isBlank(value) ? prop.getCdataValue() : value;
    activeRule.setParameter(name, ruleValue);
   } else {
    StringBuilder message = new StringBuilder("The property '").append(name);
    message.append("' is not supported in the pmd rule: ").append(configKey);
    messages.addWarningText(message.toString());
   }
  }
 }
}
origin: jensgerdes/sonar-pmd

private void setParameters(ActiveRule activeRule, PmdRule pmdRule, Rule rule, ValidationMessages messages) {
  for (PmdProperty prop : pmdRule.getProperties()) {
    String paramName = prop.getName();
    if (rule.getParam(paramName) == null) {
      messages.addWarningText("The property '" + paramName + "' is not supported in the pmd rule: " + pmdRule.getRef());
    } else {
      activeRule.setParameter(paramName, prop.getValue());
    }
  }
}
origin: mrprince/sonar-p3c-pmd

private static void setParameters(ActiveRule activeRule, PmdRule pmdRule, Rule rule, ValidationMessages messages) {
 for (PmdProperty prop : pmdRule.getProperties()) {
  String paramName = prop.getName();
  if (rule.getParam(paramName) == null) {
   messages.addWarningText("The property '" + paramName + "' is not supported in the pmd rule: " + pmdRule.getRef());
  } else {
   activeRule.setParameter(paramName, prop.getValue());
  }
 }
}
origin: org.sonarsource.sonarqube/sonar-plugin-api

ActiveRule activeRule = profile.activateRule(rule, priority);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
 if (rule.getParam(entry.getKey()) == null) {
  messages.addWarningText("The parameter '" + entry.getKey() + "' does not exist in the rule: " + ruleToString(repositoryKey, key));
 } else {
origin: org.codehaus.sonar.plugins/sonar-pmd-plugin

protected RulesProfile createRuleProfile(PmdRuleset pmdRuleset, ValidationMessages messages) {
 RulesProfile profile = RulesProfile.create();
 for (PmdRule pmdRule : pmdRuleset.getPmdRules()) {
  if (PmdConstants.XPATH_CLASS.equals(pmdRule.getClazz())) {
   messages.addWarningText("PMD XPath rule '" + pmdRule.getName()
     + "' can't be imported automatically. The rule must be created manually through the Sonar web interface.");
   continue;
  }
  if (pmdRule.getRef() == null) {
   messages.addWarningText("A PMD rule without 'ref' attribute can't be imported. see '" + pmdRule.getClazz() + "'");
   continue;
  }
  Rule rule = ruleFinder.find(RuleQuery.create().withRepositoryKey(PmdConstants.REPOSITORY_KEY).withConfigKey(pmdRule.getRef()));
  if (rule != null) {
   ActiveRule activeRule = profile.activateRule(rule, PmdLevelUtils.fromLevel(pmdRule.getPriority()));
   if (pmdRule.getProperties() != null) {
    for (PmdProperty prop : pmdRule.getProperties()) {
     if (rule.getParam(prop.getName()) == null) {
      messages.addWarningText("The property '" + prop.getName() + "' is not supported in the pmd rule: " + pmdRule.getRef());
      continue;
     }
     activeRule.setParameter(prop.getName(), prop.getValue());
    }
   }
  } else {
   messages.addWarningText("Unable to import unknown PMD rule '" + pmdRule.getRef() + "'");
  }
 }
 return profile;
}
org.sonar.api.rulesRulegetParam

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
  • getSeverity
  • createParameter,
  • getSeverity,
  • setTags,
  • <init>,
  • getParams,
  • setKey,
  • setStatus,
  • getDescription,
  • setRepositoryKey

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • 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
  • JTable (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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