本文整理了Java中org.sonar.api.rules.Rule.setConfigKey
方法的一些代码示例,展示了Rule.setConfigKey
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.setConfigKey
方法的具体详情如下:
包路径:org.sonar.api.rules.Rule
类名称:Rule
方法名:setConfigKey
[英]Sets the configuration key
[中]设置配置密钥
代码示例来源:origin: SonarSource/sonarqube
public Rule setUniqueKey(String repositoryKey, String key) {
return setRepositoryKey(repositoryKey).setKey(key).setConfigKey(key);
}
代码示例来源:origin: SonarSource/sonarqube
rule.setConfigKey(StringUtils.trim(cursor.collectDescendantText(false)));
代码示例来源:origin: SonarSource/sonarqube
@Test
public void searchRulesByConfigKey() {
RulesProfile profile = RulesProfile.create();
profile.activateRule(Rule.create("repo", "key1", "name1"), null);
profile.activateRule(Rule.create("repo", "key2", "name2").setConfigKey("config2"), null);
assertThat(profile.getActiveRuleByConfigKey("repo", "unknown")).isNull();
assertThat(profile.getActiveRuleByConfigKey("repo", "config2").getRuleKey()).isEqualTo("key2");
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public List<Rule> createRules() {
Rule rule = Rule.create("checkstyle", "ConstantName", "Constant Name");
rule.setDescription("Checks that constant names conform to the specified format");
rule.setConfigKey("Checker/TreeWalker/ConstantName");
rule.setSeverity(RulePriority.BLOCKER);
rule.setStatus(Rule.STATUS_BETA);
rule.setTags(new String[] {"style", "clumsy"});
rule.createParameter("format").setDescription("Regular expression").setDefaultValue("A-Z").setType("REGULAR_EXPRESSION");
return Arrays.asList(rule);
}
}
代码示例来源:origin: SonarSource/sonarqube
.setLanguage(rule.getLanguage())
.setKey(rule.getRuleKey())
.setConfigKey(rule.getConfigKey())
.setIsTemplate(rule.isTemplate())
.setCreatedAt(new Date(rule.getCreatedAt()))
代码示例来源:origin: SonarSource/sonarqube
.setLanguage(ruleDefinition.getLanguage())
.setKey(ruleDefinition.getRuleKey())
.setConfigKey(ruleDefinition.getConfigKey())
.setIsTemplate(ruleDefinition.isTemplate())
.setCreatedAt(new Date(ruleDefinition.getCreatedAt()))
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
public Rule setUniqueKey(String repositoryKey, String key) {
return setRepositoryKey(repositoryKey).setKey(key).setConfigKey(key);
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
public Rule setUniqueKey(String repositoryKey, String key) {
return setRepositoryKey(repositoryKey).setKey(key).setConfigKey(key);
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch
@CheckForNull
private static Rule toRule(@Nullable org.sonar.api.batch.rule.Rule ar) {
return ar == null ? null : Rule.create(ar.key().repository(), ar.key().rule()).setName(ar.name()).setConfigKey(ar.internalKey());
}
代码示例来源:origin: org.codehaus.sonar/sonar-deprecated
rule.setConfigKey(StringUtils.trim(cursor.collectDescendantText(false)));
代码示例来源:origin: org.codehaus.sonar/sonar-batch
private RulesProfile select(QProfile qProfile, ActiveRules activeRules) {
RulesProfile deprecatedProfile = new RulesProfile();
// TODO deprecatedProfile.setVersion(qProfile.version());
deprecatedProfile.setName(qProfile.getName());
deprecatedProfile.setLanguage(qProfile.getLanguage());
for (org.sonar.api.batch.rule.ActiveRule activeRule : ((DefaultActiveRules) activeRules).findByLanguage(qProfile.getLanguage())) {
Rule rule = Rule.create(activeRule.ruleKey().repository(), activeRule.ruleKey().rule());
rule.setConfigKey(activeRule.internalKey());
ActiveRule deprecatedActiveRule = deprecatedProfile.activateRule(rule,
RulePriority.valueOf(activeRule.severity()));
for (Map.Entry<String, String> param : activeRule.params().entrySet()) {
rule.createParameter(param.getKey());
deprecatedActiveRule.setParameter(param.getKey(), param.getValue());
}
}
return deprecatedProfile;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch
private static RulesProfile select(QProfile qProfile, ActiveRules activeRules) {
RulesProfile deprecatedProfile = new RulesProfile();
// TODO deprecatedProfile.setVersion(qProfile.version());
deprecatedProfile.setName(qProfile.getName());
deprecatedProfile.setLanguage(qProfile.getLanguage());
for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules.findByLanguage(qProfile.getLanguage())) {
Rule rule = Rule.create(activeRule.ruleKey().repository(), activeRule.ruleKey().rule());
rule.setConfigKey(activeRule.internalKey());
// SONAR-6706
if (activeRule.templateRuleKey() != null) {
rule.setTemplate(Rule.create(activeRule.ruleKey().repository(), activeRule.templateRuleKey()));
}
ActiveRule deprecatedActiveRule = deprecatedProfile.activateRule(rule,
RulePriority.valueOf(activeRule.severity()));
for (Map.Entry<String, String> param : activeRule.params().entrySet()) {
rule.createParameter(param.getKey());
deprecatedActiveRule.setParameter(param.getKey(), param.getValue());
}
}
return deprecatedProfile;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
.setLanguage(rule.getLanguage())
.setKey(rule.getRuleKey())
.setConfigKey(rule.getConfigKey())
.setIsTemplate(rule.isTemplate())
.setCreatedAt(new Date(rule.getCreatedAt()))
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
.setLanguage(ruleDefinition.getLanguage())
.setKey(ruleDefinition.getRuleKey())
.setConfigKey(ruleDefinition.getConfigKey())
.setIsTemplate(ruleDefinition.isTemplate())
.setCreatedAt(new Date(ruleDefinition.getCreatedAt()))
代码示例来源:origin: fabriciocolombo/sonar-delphi
private static Rule createRepositoryRule(DelphiRule fRule) {
RulePriority priority = severityFromLevel(fRule.getPriority());
Rule rule = Rule.create(DelphiPmdConstants.REPOSITORY_KEY, fRule.getName(), fRule.getMessage()).setSeverity(
priority);
rule.setDescription(fRule.getDescription());
rule.setTags(fRule.getTags());
rule.setConfigKey(fRule.getClazz());
List<RuleParam> ruleParams = new ArrayList<RuleParam>();
if (fRule.getProperties() != null) {
for (Property property : fRule.getProperties()) {
RuleParam param = rule.createParameter()
.setKey(property.getName())
.setDescription(property.getName())
.setType("s");
if (NumberUtils.isNumber(property.getValue())) {
param.setType("i");
}
param.setDefaultValue(property.getValue());
ruleParams.add(param);
}
}
rule.setParams(ruleParams);
return rule;
}
代码示例来源:origin: SonarSource/sonarlint-core
private static Rule toRuleNotNull(RulesDefinition.Rule ruleDef) {
Rule rule = Rule.create(ruleDef.repository().key(), ruleDef.key())
.setName(ruleDef.name())
.setSeverity(RulePriority.valueOf(ruleDef.severity()))
.setLanguage(ruleDef.repository().language())
.setIsTemplate(ruleDef.template())
.setConfigKey(ruleDef.internalKey());
for (Param param : ruleDef.params()) {
rule.createParameter(param.key()).setDefaultValue(param.defaultValue()).setDescription(param.description());
}
return rule;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
rule.setConfigKey(StringUtils.trim(cursor.collectDescendantText(false)));
内容来源于网络,如有侵权,请联系作者删除!