--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>it-plugins</artifactId>
+ <version>5.3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>issue-filter-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>IT :: Issue Filter</name>
+ <description>IT :: Issue Filter</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>IssueFilterPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+import org.sonar.api.config.Settings;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueFilter;
+
+/**
+ * This filter removes the issues that are on line < 5
+ * <p/>
+ * Issue filters have been introduced in 3.6.
+ */
+public class IssueFilterBeforeLine5 implements IssueFilter {
+
+ private final Settings settings;
+
+ public IssueFilterBeforeLine5(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean accept(Issue issue) {
+ if (issue.componentKey() == null) {
+ throw new IllegalStateException("Issue component is not set");
+ }
+ if (issue.ruleKey() == null) {
+ throw new IllegalStateException("Issue rule is not set");
+ }
+
+ return !settings.getBoolean("enableIssueFilters") || issue.line() == null || issue.line() >= 5;
+ }
+}
--- /dev/null
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.SonarPlugin;
+
+@Properties(@Property(
+ key = "enableIssueFilters",
+ name = "Enable Issue Filters",
+ defaultValue = "false",
+ type = PropertyType.BOOLEAN))
+public class IssueFilterPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(IssueFilterBeforeLine5.class, ModuleIssueFilter.class);
+ }
+}
--- /dev/null
+import org.sonar.api.config.Settings;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueFilter;
+import org.sonar.api.rule.RuleKey;
+
+/**
+ * This filter removes the issues that are raised by Xoo plugin on modules.
+ * <p/>
+ * Issue filters have been introduced in 3.6.
+ */
+public class ModuleIssueFilter implements IssueFilter {
+
+ private static final RuleKey ONE_ISSUE_PER_MODULE_RULEKEY = RuleKey.of("xoo", "OneIssuePerModule");
+
+ private final Settings settings;
+
+ public ModuleIssueFilter(Settings settings) {
+ this.settings = settings;
+ }
+
+ @Override
+ public boolean accept(Issue issue) {
+ if (issue.componentKey() == null) {
+ throw new IllegalStateException("Issue component is not set");
+ }
+ if (issue.ruleKey() == null) {
+ throw new IllegalStateException("Issue rule is not set");
+ }
+
+ return !settings.getBoolean("enableIssueFilters") || !ONE_ISSUE_PER_MODULE_RULEKEY.equals(issue.ruleKey());
+ }
+}
<module>settings-plugin</module>
<module>sonar-fake-plugin</module>
<module>sonar-subcategories-plugin</module>
+ <module>issue-filter-plugin</module>
</modules>
</project>