net.sourceforge.pmd.Rule.getProperty()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中net.sourceforge.pmd.Rule.getProperty方法的一些代码示例,展示了Rule.getProperty的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.getProperty方法的具体详情如下:
包路径:net.sourceforge.pmd.Rule
类名称:Rule
方法名:getProperty

Rule.getProperty介绍

暂无

代码示例

代码示例来源:origin: pmd/pmd

@Override
public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor) {
  return rule.getProperty(propertyDescriptor);
}

代码示例来源:origin: pmd/pmd

protected String getVariableValue(String name) {
  if ("variableName".equals(name)) {
    return variableName;
  } else if ("methodName".equals(name)) {
    return methodName;
  } else if ("className".equals(name)) {
    return className;
  } else if ("packageName".equals(name)) {
    return packageName;
  } else {
    final PropertyDescriptor<?> propertyDescriptor = rule.getPropertyDescriptor(name);
    return String.valueOf(rule.getProperty(propertyDescriptor));
  }
}

代码示例来源:origin: pmd/pmd

T value = rule.getProperty(typed);
String propertyValue = typed.asDelimitedString(value);
if (propertyValue == null) {

代码示例来源:origin: pmd/pmd

public XmlParserOptions(Rule rule) {
  this.coalescing = rule.getProperty(COALESCING_DESCRIPTOR);
  this.expandEntityReferences = rule.getProperty(EXPAND_ENTITY_REFERENCES_DESCRIPTOR);
  this.ignoringComments = rule.getProperty(IGNORING_COMMENTS_DESCRIPTOR);
  this.ignoringElementContentWhitespace = rule.getProperty(IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR);
  this.namespaceAware = rule.getProperty(NAMESPACE_AWARE_DESCRIPTOR);
  this.validating = rule.getProperty(VALIDATING_DESCRIPTOR);
  this.xincludeAware = rule.getProperty(XINCLUDE_AWARE_DESCRIPTOR);
  this.lookupDescriptorDoc = rule.getProperty(LOOKUP_DESCRIPTOR_DTD);
}

代码示例来源:origin: pmd/pmd

lines.add("**This rule is defined by the following XPath expression:**");
  lines.add("``` xpath");
  lines.addAll(toLines(StringUtils.stripToEmpty(rule.getProperty(XPathRule.XPATH_DESCRIPTOR))));
  lines.add("```");
} else {

代码示例来源:origin: pmd/pmd

public EcmascriptParserOptions(Rule rule) {
  this.recordingComments = rule.getProperty(RECORDING_COMMENTS_DESCRIPTOR);
  this.recordingLocalJsDocComments = rule.getProperty(RECORDING_LOCAL_JSDOC_COMMENTS_DESCRIPTOR);
  this.rhinoLanguageVersion = rule.getProperty(RHINO_LANGUAGE_VERSION);
}

代码示例来源:origin: pmd/pmd

assertEquals(message + ", Rule property descriptor ", propertyDescriptors1, propertyDescriptors2);
for (int j = 0; j < propertyDescriptors1.size(); j++) {
  Object value1 = rule1.getProperty(propertyDescriptors1.get(j));
  Object value2 = rule2.getProperty(propertyDescriptors2.get(j));

代码示例来源:origin: pmd/pmd

private void setSuppression(Rule rule, T node) {
  String regex = rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex
  if (regex != null && description != null) {
    if (Pattern.matches(regex, description)) {
      suppressed = true;
    }
  }
  if (!suppressed) { // XPath
    String xpath = rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR);
    if (xpath != null) {
      suppressed = node.hasDescendantMatchingXPath(xpath);
    }
  }
}

代码示例来源:origin: pmd/pmd

private int getRemediationPoints() {
  int remediationPoints = REMEDIATION_POINTS_DEFAULT;
  if (rule.hasDescriptor(CODECLIMATE_REMEDIATION_MULTIPLIER)) {
    remediationPoints *= rule.getProperty(CODECLIMATE_REMEDIATION_MULTIPLIER);
  }
  return remediationPoints;
}

代码示例来源:origin: pmd/pmd

private String[] getCategories() {
  String[] result;
  if (rule.hasDescriptor(CODECLIMATE_CATEGORIES)) {
    List<String> categories = rule.getProperty(CODECLIMATE_CATEGORIES);
    result = categories.toArray(new String[0]);
  } else {
    result = CODECLIMATE_DEFAULT_CATEGORIES;
  }
  return result;
}

代码示例来源:origin: pmd/pmd

@Override
public String propertyErrorFor(Rule rule) {
  List<V> realValues = rule.getProperty(this);
  return realValues == null ? null : errorFor(realValues);
}

代码示例来源:origin: pmd/pmd

@Override
public String propertyErrorFor(Rule rule) {
  T realValue = rule.getProperty(this);
  return realValue == null ? null : errorFor(realValue);
}

代码示例来源:origin: pmd/pmd

/**
 * Creates a new RuleSet containing a single rule.
 *
 * @param rule
 *            The rule being created
 * @return The newly created RuleSet
 */
public RuleSet createSingleRuleRuleSet(final Rule rule) { // TODO make static?
  final long checksum;
  if (rule instanceof XPathRule) {
    checksum = rule.getProperty(XPathRule.XPATH_DESCRIPTOR).hashCode();
  } else {
    // TODO : Is this good enough? all properties' values + rule name
    checksum = rule.getPropertiesByPropertyDescriptor().values().hashCode() * 31 + rule.getName().hashCode();
  }
  final RuleSetBuilder builder = new RuleSetBuilder(checksum)
      .withName(rule.getName())
      .withDescription("RuleSet for " + rule.getName());
  builder.addRule(rule);
  return builder.build();
}

代码示例来源:origin: pmd/pmd

if (rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR) != null) {
  invalidRegexSuppress++;
  messages += "Rule " + fileName + "/" + rule.getName() + " should not have '"
if (rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR) != null) {
  invalidXPathSuppress++;
  messages += "Rule " + fileName + "/" + rule.getName() + " should not have '"

代码示例来源:origin: pmd/pmd

private CodeClimateIssue.Location getLocation(RuleViolation rv) {
  CodeClimateIssue.Location result;
  String pathWithoutCcRoot = StringUtils.removeStartIgnoreCase(rv.getFilename(), "/code/");
  if (rule.hasDescriptor(CODECLIMATE_REMEDIATION_MULTIPLIER)
    && !rule.getProperty(CODECLIMATE_BLOCK_HIGHLIGHTING)) {
    result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getBeginLine());
  } else {
    result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getEndLine());
  }
  return result;
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

private String[] getCategories() {
  String[] result;
  if (rule.hasDescriptor(CODECLIMATE_CATEGORIES)) {
    List<String> categories = rule.getProperty(CODECLIMATE_CATEGORIES);
    result = categories.toArray(new String[0]);
  } else {
    result = CODECLIMATE_DEFAULT_CATEGORIES;
  }
  return result;
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

@Override
public String propertyErrorFor(Rule rule) {
  T realValue = rule.getProperty(this);
  return realValue == null ? null : errorFor(realValue);
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

private int getRemediationPoints() {
  int remediationPoints = REMEDIATION_POINTS_DEFAULT;
  if (rule.hasDescriptor(CODECLIMATE_REMEDIATION_MULTIPLIER)) {
    remediationPoints *= rule.getProperty(CODECLIMATE_REMEDIATION_MULTIPLIER);
  }
  return remediationPoints;
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

@Override
public String propertyErrorFor(Rule rule) {
  List<V> realValues = rule.getProperty(this);
  return realValues == null ? null : errorFor(realValues);
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

private CodeClimateIssue.Location getLocation(RuleViolation rv) {
  CodeClimateIssue.Location result;
  String pathWithoutCcRoot = StringUtils.removeStartIgnoreCase(rv.getFilename(), "/code/");
  if (rule.hasDescriptor(CODECLIMATE_REMEDIATION_MULTIPLIER)
    && !rule.getProperty(CODECLIMATE_BLOCK_HIGHLIGHTING)) {
    result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getBeginLine());
  } else {
    result = new CodeClimateIssue.Location(pathWithoutCcRoot, rv.getBeginLine(), rv.getEndLine());
  }
  return result;
}

相关文章