本文整理汇总了Java中org.sonar.api.server.rule.RulesDefinition.NewRule方法的典型用法代码示例。如果您正苦于以下问题:Java RulesDefinition.NewRule方法的具体用法?Java RulesDefinition.NewRule怎么用?Java RulesDefinition.NewRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.server.rule.RulesDefinition
的用法示例。
在下文中一共展示了RulesDefinition.NewRule方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
/**
* Initialization.
*
* @param repo the repository in which the rules is registered
*/
public static void init(RulesDefinition.NewRepository repo) {
final RulesDefinition.NewRule rule = repo.createRule(RULE_KEY)
.setName("The exception should be used in the catch block")
.setHtmlDescription("The exception is not used, this is rather bad. You should use the exception " +
"object in your log, or rethrow it.")
.addTags("error-handling")
.setSeverity(Severity.MAJOR)
.setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.LOGIC_RELIABILITY);
rule.createParam("exceptions").setType(RuleParamType.STRING)
.setDescription("List of exceptions which should not be checked")
.setDefaultValue("" + CaughtExceptionTouchedCheck.EXCLUDED_EXCEPTION_TYPE);
rule.setDebtRemediationFunction(rule.debtRemediationFunctions().constantPerIssue("10min"));
}
示例2: loadRule
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
private RulesDefinition.NewRule loadRule(RulesDefinition.NewExtendedRepository repo, Class<? extends JavaCheck> clazz, Rule ruleAnnotation) {
String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName());
String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null);
String description = StringUtils.defaultIfEmpty(getDescriptionFromResources(ruleKey), "No description yet.");
RulesDefinition.NewRule rule = repo.createRule(ruleKey);
rule.setName(ruleName).setMarkdownDescription(description);
rule.setSeverity(ruleAnnotation.priority().name());
rule.setStatus(RuleStatus.valueOf(ruleAnnotation.status()));
rule.setTags(ruleAnnotation.tags());
List<Field> fields = FieldUtils2.getFields(clazz, true);
for (Field field : fields) {
loadParameters(rule, field);
}
return rule;
}
示例3: loadParameters
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
private void loadParameters(RulesDefinition.NewRule rule, Field field) {
org.sonar.check.RuleProperty propertyAnnotation = field.getAnnotation(org.sonar.check.RuleProperty.class);
if (propertyAnnotation != null) {
String fieldKey = StringUtils.defaultIfEmpty(propertyAnnotation.key(), field.getName());
RulesDefinition.NewParam param = rule.createParam(fieldKey)
.setDescription(propertyAnnotation.description())
.setDefaultValue(propertyAnnotation.defaultValue());
if (!StringUtils.isBlank(propertyAnnotation.type())) {
try {
param.setType(RuleParamType.parse(propertyAnnotation.type().trim()));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid property type [" + propertyAnnotation.type() + "]", e);
}
} else {
param.setType(guessType(field.getType()));
}
}
}
示例4: init
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
/**
* Initialization.
*
* @param repo the repository in which the rules is registered
*/
public static void init(RulesDefinition.NewRepository repo) {
RulesDefinition.NewRule rule = repo.createRule(UnusedNotAnnotatedPrivateFieldCheck.RULE_KEY)
.setName("Unused private field should be removed")
.setHtmlDescription("The field does not seem to be used, so you can remove it.")
.addTags("unused")
.setSeverity(Severity.MAJOR)
.setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.UNDERSTANDABILITY);
rule.setDebtRemediationFunction(rule.debtRemediationFunctions().constantPerIssue("5min"));
}
示例5: init
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
/**
* Initialization.
*
* @param repo the repository in which the rules is registered
*/
public static void init(RulesDefinition.NewRepository repo) {
RulesDefinition.NewRule rule = repo.createRule(UnusedNotAnnotatedPrivateMethodCheck.RULE_KEY)
.setName("Unused private method should be removed")
.setHtmlDescription("The method does not seem to be called, so you can remove it.")
.addTags("unused")
.setSeverity(Severity.MAJOR)
.setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.UNDERSTANDABILITY);
rule.setDebtRemediationFunction(rule.debtRemediationFunctions().constantPerIssue("5min"));
}
示例6: create
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
public Slide create(String ruleName) {
String fullName = String.format("%02d. %s", index, ruleName);
RulesDefinition.NewRule rule = repo.createRule(Slug.slugify(fullName));
rule.setName(fullName);
index++;
return new Slide(rule);
}
示例7: Slide
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
private Slide(RulesDefinition.NewRule rule) {
this.rule = rule;
}
示例8: Content
import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
private Content(RulesDefinition.NewRule rule) {
this.rule = rule;
}