use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.
the class DebtRulesXMLImporterTest method read_integer.
@Test
public void read_integer() throws Exception {
String xml = getFileContent("read_integer.xml");
List<RuleDebt> results = underTest.importXML(xml, validationMessages);
assertThat(results).hasSize(1);
RuleDebt ruleDebt = results.get(0);
assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name());
assertThat(ruleDebt.coefficient()).isEqualTo("3h");
assertThat(ruleDebt.offset()).isNull();
}
use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.
the class DebtRulesXMLImporterTest method replace_mn_by_min.
@Test
public void replace_mn_by_min() throws Exception {
String xml = getFileContent("replace_mn_by_min.xml");
List<RuleDebt> results = underTest.importXML(xml, validationMessages);
assertThat(results).hasSize(1);
RuleDebt ruleDebt = results.get(0);
assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name());
assertThat(ruleDebt.coefficient()).isEqualTo("3min");
assertThat(ruleDebt.offset()).isNull();
}
use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.
the class DeprecatedRulesDefinitionLoader method complete.
void complete(RulesDefinition.Context context) {
// Load rule debt definitions from xml files provided by plugin
List<RuleDebt> ruleDebts = loadRuleDebtList();
for (RuleRepository repository : repositories) {
// RuleRepository API does not handle difference between new and extended repositories,
RulesDefinition.NewRepository newRepository;
if (context.repository(repository.getKey()) == null) {
newRepository = context.createRepository(repository.getKey(), repository.getLanguage());
newRepository.setName(repository.getName());
} else {
newRepository = context.extendRepository(repository.getKey(), repository.getLanguage());
}
for (org.sonar.api.rules.Rule rule : repository.createRules()) {
RulesDefinition.NewRule newRule = newRepository.createRule(rule.getKey());
newRule.setName(ruleName(repository.getKey(), rule));
newRule.setHtmlDescription(ruleDescription(repository.getKey(), rule));
newRule.setInternalKey(rule.getConfigKey());
newRule.setTemplate(rule.isTemplate());
newRule.setSeverity(rule.getSeverity().toString());
newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
for (RuleParam param : rule.getParams()) {
RulesDefinition.NewParam newParam = newRule.createParam(param.getKey());
newParam.setDefaultValue(param.getDefaultValue());
newParam.setDescription(paramDescription(repository.getKey(), rule.getKey(), param));
newParam.setType(RuleParamType.parse(param.getType()));
}
updateRuleDebtDefinitions(newRule, repository.getKey(), rule.getKey(), ruleDebts);
}
newRepository.done();
}
}
use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.
the class DebtRulesXMLImporterTest method import_badly_formatted_xml.
@Test
public void import_badly_formatted_xml() throws Exception {
String xml = getFileContent("import_badly_formatted_xml.xml");
List<RuleDebt> results = underTest.importXML(xml, validationMessages);
assertThat(results).hasSize(1);
RuleDebt ruleDebt = results.get(0);
assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name());
assertThat(ruleDebt.coefficient()).isEqualTo("3h");
assertThat(ruleDebt.offset()).isNull();
}
use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.
the class DebtRulesXMLImporterTest method import_constant_issue.
@Test
public void import_constant_issue() throws Exception {
String xml = getFileContent("import_constant_issue.xml");
List<RuleDebt> results = underTest.importXML(xml, validationMessages);
assertThat(results).hasSize(1);
RuleDebt ruleDebt = results.get(0);
assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name());
assertThat(ruleDebt.coefficient()).isNull();
assertThat(ruleDebt.offset()).isEqualTo("3d");
}
Aggregations