aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-10-02 14:29:11 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-10-02 15:03:20 +0200
commitfc7b6dc2a4558c0825a83987f6672cd19a428002 (patch)
treed228da60ac1c66f04b6d9702a34c1d1619ac5598 /plugins
parentc44c42eb76ef58aa06fe276b060b3af06cbcf64f (diff)
downloadsonarqube-fc7b6dc2a4558c0825a83987f6672cd19a428002.tar.gz
sonarqube-fc7b6dc2a4558c0825a83987f6672cd19a428002.zip
Add an IT for custom rules
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java13
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java4
2 files changed, 10 insertions, 7 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
index ef8d3df6af6..adc9dc9d0c9 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
@@ -19,11 +19,12 @@
*/
package org.sonar.xoo.rule;
-import org.sonar.xoo.Xoo2;
-
import org.sonar.api.server.rule.RuleParamType;
import org.sonar.api.server.rule.RulesDefinition;
+import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader;
import org.sonar.xoo.Xoo;
+import org.sonar.xoo.Xoo2;
+import org.sonar.xoo.checks.Check;
/**
* Define all the coding rules that are supported on the repositories named "xoo" and "xoo2"
@@ -50,13 +51,15 @@ public class XooRulesDefinition implements RulesDefinition {
oneIssuePerLine.setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.MEMORY_EFFICIENCY)
.setDebtRemediationFunction(hasTag.debtRemediationFunctions().linear("1min"))
.setEffortToFixDescription("It takes about 1 minute to an experienced software craftsman to remove a line of code");
-
+
repo.done();
}
- private static void defineRulesXoo(Context context) {
+ private void defineRulesXoo(Context context) {
NewRepository repo = context.createRepository(XOO_REPOSITORY, Xoo.KEY).setName("Xoo");
-
+
+ new RulesDefinitionAnnotationLoader().load(repo, Check.ALL);
+
NewRule hasTag = repo.createRule(HasTagSensor.RULE_KEY).setName("Has Tag")
.setHtmlDescription("Search for a given tag in Xoo files");
hasTag.setDebtSubCharacteristic(RulesDefinition.SubCharacteristics.READABILITY)
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
index 923f4d94f5f..ee2d1504b3e 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/XooRulesDefinitionTest.java
@@ -20,10 +20,10 @@
package org.sonar.xoo.rule;
import org.junit.Before;
-
import org.junit.Test;
import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.rule.RulesDefinition;
+
import static org.assertj.core.api.Assertions.assertThat;
public class XooRulesDefinitionTest {
@@ -42,7 +42,7 @@ public class XooRulesDefinitionTest {
assertThat(repo).isNotNull();
assertThat(repo.name()).isEqualTo("Xoo");
assertThat(repo.language()).isEqualTo("xoo");
- assertThat(repo.rules()).hasSize(11);
+ assertThat(repo.rules()).hasSize(12);
RulesDefinition.Rule rule = repo.rule(OneIssuePerLineSensor.RULE_KEY);
assertThat(rule.name()).isNotEmpty();