import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.measure.Metric;
-import org.sonar.api.batch.rule.ActiveRule;
import org.sonar.api.batch.rule.ActiveRules;
+import org.sonar.api.batch.rule.internal.DefaultActiveRule;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.IssueBuilder;
resourceKey = def.getKey();
}
RuleKey ruleKey = issue.ruleKey();
- ActiveRule activeRule = activeRules.find(ruleKey);
+ DefaultActiveRule activeRule = (DefaultActiveRule) activeRules.find(ruleKey);
if (activeRule == null) {
// rule does not exist or is not enabled -> ignore the issue
return false;
return false;
}
- private void updateIssue(DefaultIssue issue, ActiveRule activeRule) {
+ private void updateIssue(DefaultIssue issue, DefaultActiveRule activeRule) {
if (Strings.isNullOrEmpty(issue.message())) {
issue.setMessage(activeRule.name());
}
import java.util.Map;
@Immutable
-class DefaultActiveRule implements ActiveRule {
+public class DefaultActiveRule implements ActiveRule {
private final RuleKey ruleKey;
private final String name;
private final String severity, internalKey, language;
return ruleKey;
}
- @Override
public String name() {
return name;
}
ActiveRule squid1 = activeRules.find(RuleKey.of("squid", "S0001"));
assertThat(squid1.ruleKey().repository()).isEqualTo("squid");
assertThat(squid1.ruleKey().rule()).isEqualTo("S0001");
- assertThat(squid1.name()).isEqualTo("My Rule");
+ assertThat(((DefaultActiveRule) squid1).name()).isEqualTo("My Rule");
assertThat(squid1.severity()).isEqualTo(Severity.CRITICAL);
assertThat(squid1.internalKey()).isEqualTo("__S0001__");
assertThat(squid1.params()).hasSize(1);