当前位置: 首页>>代码示例>>Java>>正文


Java RulesDefinition.NewRule方法代码示例

本文整理汇总了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"));
}
 
开发者ID:Axway,项目名称:sonar-rules,代码行数:21,代码来源:CaughtExceptionTouchedCheck.java

示例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;
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:19,代码来源:RulesLoader.java

示例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()));
		}
	}
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:20,代码来源:RulesLoader.java

示例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"));
}
 
开发者ID:Axway,项目名称:sonar-rules,代码行数:16,代码来源:UnusedNotAnnotatedPrivateFieldCheck.java

示例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"));
}
 
开发者ID:Axway,项目名称:sonar-rules,代码行数:16,代码来源:UnusedNotAnnotatedPrivateMethodCheck.java

示例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);
}
 
开发者ID:simonbrandhof,项目名称:sonar-slideshow-plugin,代码行数:8,代码来源:Slides.java

示例7: Slide

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
private Slide(RulesDefinition.NewRule rule) {
  this.rule = rule;
}
 
开发者ID:simonbrandhof,项目名称:sonar-slideshow-plugin,代码行数:4,代码来源:Slides.java

示例8: Content

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
private Content(RulesDefinition.NewRule rule) {
  this.rule = rule;
}
 
开发者ID:simonbrandhof,项目名称:sonar-slideshow-plugin,代码行数:4,代码来源:Slides.java


注:本文中的org.sonar.api.server.rule.RulesDefinition.NewRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。