aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsCategory.java (renamed from plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/Category.java)2
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConstants.java (renamed from plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/xml/FindBugsXmlTests.java)63
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java (renamed from plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulePriorityMapper.java)17
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandler.java12
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java13
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileExporter.java67
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileImporter.java112
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRuleRepository.java44
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulesRepository.java111
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java20
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfile.java47
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java42
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml1129
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java5
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileExporterTest.java (renamed from plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/xml/FindBugsFilterTest.java)255
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java144
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleFinder.java57
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleRepositoryTest.java45
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest.java186
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java26
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsTests.java65
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java41
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/tools/RulesGenerator.java190
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportPatterns.xml9
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugs-include.xml6
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml6
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml6
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml9
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportCategories.xml (renamed from plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCategories.xml)0
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportCodes.xml (renamed from plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCodes.xml)2
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml9
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/uncorrectFindbugsXml.xml5
32 files changed, 1959 insertions, 786 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/Category.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsCategory.java
index f9d5c641ff0..2150dffc565 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/Category.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsCategory.java
@@ -22,7 +22,7 @@ package org.sonar.plugins.findbugs;
import java.util.HashMap;
import java.util.Map;
-public final class Category {
+public final class FindbugsCategory {
private final static Map<String, String> findbugsToSonar = new HashMap<String, String>();
static {
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/xml/FindBugsXmlTests.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConstants.java
index 907679f880a..a49d06f620a 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/xml/FindBugsXmlTests.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConstants.java
@@ -1,33 +1,30 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.findbugs.xml;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-import org.sonar.plugins.findbugs.FindbugsTests;
-
-public class FindBugsXmlTests extends FindbugsTests {
-
- protected static void assertChild(Match child, String configKey) {
- Bug bug = child.getBug();
- assertNotNull(bug);
- assertThat(bug.getPattern(), is(configKey));
- }
-} \ No newline at end of file
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import org.sonar.api.CoreProperties;
+
+public final class FindbugsConstants {
+
+ public static final String REPOSITORY_KEY = CoreProperties.FINDBUGS_PLUGIN;
+ public static final String REPOSITORY_NAME = "Findbugs";
+ public static final String PLUGIN_NAME = "Findbugs";
+ public static final String PLUGIN_KEY = CoreProperties.FINDBUGS_PLUGIN;
+}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulePriorityMapper.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java
index 47a8fb54120..60237a995ef 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulePriorityMapper.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsLevelUtils.java
@@ -20,9 +20,8 @@
package org.sonar.plugins.findbugs;
import org.sonar.api.rules.RulePriority;
-import org.sonar.api.rules.RulePriorityMapper;
-public class FindbugsRulePriorityMapper implements RulePriorityMapper<String, String> {
+public class FindbugsLevelUtils {
public RulePriority from(String priority) {
if (priority.equals("1")) {
@@ -36,18 +35,4 @@ public class FindbugsRulePriorityMapper implements RulePriorityMapper<String, St
}
throw new IllegalArgumentException("Priority not supported: " + priority);
}
-
- public String to(RulePriority priority) {
- if (priority.equals(RulePriority.BLOCKER) || priority.equals(RulePriority.CRITICAL)) {
- return "1";
- }
- if (priority.equals(RulePriority.MAJOR)) {
- return "2";
- }
- if (priority.equals(RulePriority.INFO) || priority.equals(RulePriority.MINOR)) {
- return "3";
- }
- throw new IllegalArgumentException("Priority not supported: " + priority);
- }
-
}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandler.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandler.java
index 0e6e9164762..e7e45ac3017 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandler.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandler.java
@@ -21,6 +21,7 @@ package org.sonar.plugins.findbugs;
import java.io.File;
import java.io.IOException;
+import java.io.StringWriter;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
@@ -37,11 +38,11 @@ import org.sonar.plugins.findbugs.xml.Match;
public class FindbugsMavenPluginHandler implements MavenPluginHandler {
private RulesProfile profile;
- private FindbugsRulesRepository findbugsRulesRepository;
+ private FindbugsProfileExporter exporter;
- public FindbugsMavenPluginHandler(RulesProfile profile, FindbugsRulesRepository findbugsRulesRepository) {
+ public FindbugsMavenPluginHandler(RulesProfile profile, FindbugsProfileExporter exporter) {
this.profile = profile;
- this.findbugsRulesRepository = findbugsRulesRepository;
+ this.exporter = exporter;
}
public String getGroupId() {
@@ -121,8 +122,9 @@ public class FindbugsMavenPluginHandler implements MavenPluginHandler {
}
private File saveIncludeConfigXml(Project project) throws IOException {
- String configuration = findbugsRulesRepository.exportConfiguration(profile);
- return project.getFileSystem().writeToWorkingDirectory(configuration, "findbugs-include.xml");
+ StringWriter conf = new StringWriter();
+ exporter.exportProfile(profile, conf);
+ return project.getFileSystem().writeToWorkingDirectory(conf.toString(), "findbugs-include.xml");
}
private File saveExcludeConfigXml(Project project) throws IOException {
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
index 86cf5ea1441..c43965d1b3b 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
@@ -19,11 +19,15 @@
*/
package org.sonar.plugins.findbugs;
-import org.sonar.api.*;
-
import java.util.ArrayList;
import java.util.List;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Extension;
+import org.sonar.api.Plugin;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+
@Properties({
@Property(
key = CoreProperties.FINDBUGS_EFFORT_PROPERTY,
@@ -67,7 +71,10 @@ public class FindbugsPlugin implements Plugin {
List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();
list.add(FindbugsSensor.class);
list.add(FindbugsMavenPluginHandler.class);
- list.add(FindbugsRulesRepository.class);
+ list.add(FindbugsRuleRepository.class);
+ list.add(FindbugsProfileExporter.class);
+ list.add(FindbugsProfileImporter.class);
+ list.add(SonarWayWithFindbugsProfile.class);
return list;
}
}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileExporter.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileExporter.java
new file mode 100644
index 00000000000..bb228713115
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileExporter.java
@@ -0,0 +1,67 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import org.sonar.api.profiles.ProfileExporter;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.resources.Java;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.api.utils.SonarException;
+import org.sonar.plugins.findbugs.xml.Bug;
+import org.sonar.plugins.findbugs.xml.FindBugsFilter;
+import org.sonar.plugins.findbugs.xml.Match;
+
+import com.thoughtworks.xstream.XStream;
+
+public class FindbugsProfileExporter extends ProfileExporter {
+
+ public FindbugsProfileExporter() {
+ super(FindbugsConstants.REPOSITORY_KEY, FindbugsConstants.PLUGIN_NAME);
+ setSupportedLanguages(Java.KEY);
+ setMimeType("application/xml");
+ }
+
+ @Override
+ public void exportProfile(RulesProfile profile, Writer writer) {
+ try {
+ FindBugsFilter filter = buildFindbugsFilter(profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY));
+ XStream xstream = FindBugsFilter.createXStream();
+ writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Generated by Sonar -->\n".concat(xstream.toXML(filter)));
+ } catch (IOException e) {
+ throw new SonarException("Fail to export the Findbugs profile : " + profile, e);
+ }
+ }
+
+ protected static FindBugsFilter buildFindbugsFilter(List<ActiveRule> activeRules) {
+ FindBugsFilter root = new FindBugsFilter();
+ for (ActiveRule activeRule : activeRules) {
+ if (FindbugsConstants.REPOSITORY_KEY.equals(activeRule.getRepositoryKey())) {
+ Match child = new Match();
+ child.setBug(new Bug(activeRule.getConfigKey()));
+ root.addMatch(child);
+ }
+ }
+ return root;
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileImporter.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileImporter.java
new file mode 100644
index 00000000000..39b32b6dd49
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsProfileImporter.java
@@ -0,0 +1,112 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import java.io.Reader;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.profiles.ProfileImporter;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.resources.Java;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.rules.RulePriority;
+import org.sonar.api.rules.RuleQuery;
+import org.sonar.api.utils.ValidationMessages;
+import org.sonar.plugins.findbugs.xml.FindBugsFilter;
+
+import com.thoughtworks.xstream.XStream;
+
+public class FindbugsProfileImporter extends ProfileImporter {
+
+ private final RuleFinder ruleFinder;
+ private static Logger LOG = LoggerFactory.getLogger(FindbugsProfileImporter.class);
+
+ public FindbugsProfileImporter(RuleFinder ruleFinder) {
+ super(FindbugsConstants.REPOSITORY_KEY, FindbugsConstants.PLUGIN_NAME);
+ setSupportedLanguages(Java.KEY);
+ this.ruleFinder = ruleFinder;
+ }
+
+ @Override
+ public RulesProfile importProfile(Reader findbugsConf, ValidationMessages messages) {
+ RulesProfile profile = RulesProfile.create();
+ try {
+ XStream xStream = FindBugsFilter.createXStream();
+ FindBugsFilter filter = (FindBugsFilter) xStream.fromXML(findbugsConf);
+
+ activateRulesByCategory(profile, filter, messages);
+ activateRulesByCode(profile, filter, messages);
+ activateRulesByPattern(profile, filter, messages);
+
+ return profile;
+ } catch (Exception e) {
+ String errorMessage = "The Findbugs configuration file is not valid";
+ messages.addErrorText(errorMessage + " : " + e.getMessage());
+ LOG.error(errorMessage, e);
+ return profile;
+ }
+ }
+
+ private void activateRulesByPattern(RulesProfile profile, FindBugsFilter filter, ValidationMessages messages) {
+ for (Map.Entry<String, RulePriority> patternLevel : filter.getPatternLevels(new FindbugsLevelUtils()).entrySet()) {
+ Rule rule = ruleFinder.findByKey(FindbugsConstants.REPOSITORY_KEY, patternLevel.getKey());
+ if (rule != null) {
+ profile.activateRule(rule, patternLevel.getValue());
+ } else {
+ messages.addWarningText("Unable to activate unknown rule : '" + patternLevel.getKey() + "'");
+ }
+ }
+ }
+
+ private void activateRulesByCode(RulesProfile profile, FindBugsFilter filter, ValidationMessages messages) {
+ for (Map.Entry<String, RulePriority> codeLevel : filter.getCodeLevels(new FindbugsLevelUtils()).entrySet()) {
+ boolean someRulesHaveBeenActivated = false;
+ for (Rule rule : ruleFinder.findAll(RuleQuery.create().withRepositoryKey(FindbugsConstants.REPOSITORY_KEY))) {
+ if (rule.getKey().equals(codeLevel.getKey()) || StringUtils.startsWith(rule.getKey(), codeLevel.getKey() + "_")) {
+ someRulesHaveBeenActivated = true;
+ profile.activateRule(rule, codeLevel.getValue());
+ }
+ }
+ if ( !someRulesHaveBeenActivated) {
+ messages.addWarningText("Unable to find any rules associated to code : '" + codeLevel.getKey() + "'");
+ }
+ }
+ }
+
+ private void activateRulesByCategory(RulesProfile profile, FindBugsFilter filter, ValidationMessages messages) {
+ for (Map.Entry<String, RulePriority> categoryLevel : filter.getCategoryLevels(new FindbugsLevelUtils()).entrySet()) {
+ boolean someRulesHaveBeenActivated = false;
+ String sonarCateg = FindbugsCategory.findbugsToSonar(categoryLevel.getKey());
+ for (Rule rule : ruleFinder.findAll(RuleQuery.create().withRepositoryKey(FindbugsConstants.REPOSITORY_KEY))) {
+ if (sonarCateg != null && rule.getName().startsWith(sonarCateg)) {
+ someRulesHaveBeenActivated = true;
+ profile.activateRule(rule, categoryLevel.getValue());
+ }
+ }
+ if ( !someRulesHaveBeenActivated) {
+ messages.addWarningText("Unable to find any rules associated to category : '" + categoryLevel.getKey() + "'");
+ }
+ }
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRuleRepository.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRuleRepository.java
new file mode 100644
index 00000000000..f690c82619b
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRuleRepository.java
@@ -0,0 +1,44 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.sonar.api.platform.ServerFileSystem;
+import org.sonar.api.resources.Java;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleRepository;
+import org.sonar.api.rules.StandardRuleXmlFormat;
+
+public final class FindbugsRuleRepository extends RuleRepository {
+
+ public FindbugsRuleRepository() {
+ super(FindbugsConstants.REPOSITORY_KEY, Java.KEY);
+ setName(FindbugsConstants.REPOSITORY_NAME);
+ }
+
+ @Override
+ public List<Rule> createRules() {
+ List<Rule> rules = new ArrayList<Rule>();
+ rules.addAll(StandardRuleXmlFormat.parseXml(getClass().getResourceAsStream("/org/sonar/plugins/findbugs/rules.xml")));
+ return rules;
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulesRepository.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulesRepository.java
deleted file mode 100644
index 4113c709536..00000000000
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsRulesRepository.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.findbugs;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.resources.Java;
-import org.sonar.api.rules.*;
-import org.sonar.plugins.findbugs.xml.FindBugsFilter;
-
-import java.util.*;
-
-public class FindbugsRulesRepository extends AbstractRulesRepository<Java, FindbugsRulePriorityMapper> implements ConfigurationImportable, ConfigurationExportable {
-
- public FindbugsRulesRepository(Java language) {
- super(language, new FindbugsRulePriorityMapper());
- }
-
- @Override
- public String getRepositoryResourcesBase() {
- return "org/sonar/plugins/findbugs";
- }
-
- @Override
- public List<Rule> parseReferential(String fileContent) {
- return new StandardRulesXmlParser().parse(fileContent);
- }
-
- public List<RulesProfile> getProvidedProfiles() {
- RulesProfile profile = new RulesProfile(RulesProfile.SONAR_WAY_FINDBUGS_NAME, Java.KEY);
- List<Rule> rules = getInitialReferential();
- ArrayList<ActiveRule> activeRules = new ArrayList<ActiveRule>();
- for (Rule rule : rules) {
- activeRules.add(new ActiveRule(profile, rule, null));
- }
- profile.setActiveRules(activeRules);
- return Arrays.asList(profile);
- }
-
- public String exportConfiguration(RulesProfile activeProfile) {
- FindBugsFilter filter = FindBugsFilter.fromActiveRules(activeProfile.getActiveRulesByPlugin(CoreProperties.FINDBUGS_PLUGIN));
- return addHeaderToXml(filter.toXml());
- }
-
- private static String addHeaderToXml(String xmlModules) {
- return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- Generated by Sonar -->\n".concat(xmlModules);
- }
-
- public List<ActiveRule> importConfiguration(String xml, List<Rule> rules) {
- FindBugsFilter filter = FindBugsFilter.fromXml(xml);
-
- Set<ActiveRule> result = new HashSet<ActiveRule>();
-
- for (Map.Entry<String, RulePriority> categoryLevel : filter.getCategoryLevels(getRulePriorityMapper()).entrySet()) {
- completeActiveRulesByCategory(result, rules, categoryLevel.getKey(), categoryLevel.getValue());
- }
-
- for (Map.Entry<String, RulePriority> codeLevel : filter.getCodeLevels(getRulePriorityMapper()).entrySet()) {
- completeActiveRulesByCode(result, rules, codeLevel.getKey(), codeLevel.getValue());
- }
-
- for (Map.Entry<String, RulePriority> patternLevel : filter.getPatternLevels(getRulePriorityMapper()).entrySet()) {
- completeActiveRulesByPattern(result, rules, patternLevel.getKey(), patternLevel.getValue());
- }
-
- return new ArrayList<ActiveRule>(result);
- }
-
- private void completeActiveRulesByCategory(Set<ActiveRule> result, List<Rule> rules, String findbugsCategory, RulePriority priority) {
- for (Rule rule : rules) {
- String sonarCateg = Category.findbugsToSonar(findbugsCategory);
- if (sonarCateg != null && rule.getName().startsWith(sonarCateg)) {
- result.add(new ActiveRule(null, rule, priority));
- }
- }
- }
-
- private void completeActiveRulesByCode(Set<ActiveRule> result, List<Rule> rules, String findbugsCode, RulePriority priority) {
- for (Rule rule : rules) {
- if (rule.getKey().equals(findbugsCode) || StringUtils.startsWith(rule.getKey(), findbugsCode + "_")) {
- result.add(new ActiveRule(null, rule, priority));
- }
- }
- }
-
- private void completeActiveRulesByPattern(Set<ActiveRule> result, List<Rule> rules, String findbugsPattern, RulePriority priority) {
- for (Rule rule : rules) {
- if (rule.getKey().equals(findbugsPattern)) {
- result.add(new ActiveRule(null, rule, priority));
- }
- }
- }
-}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java
index cf31f5a3e55..f1ba161bb8c 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java
@@ -35,19 +35,19 @@ import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.Project;
import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulesManager;
+import org.sonar.api.rules.RuleFinder;
import org.sonar.api.rules.Violation;
public class FindbugsSensor implements Sensor, DependsUponMavenPlugin, GeneratesViolations {
private RulesProfile profile;
- private RulesManager rulesManager;
+ private RuleFinder ruleFinder;
private FindbugsMavenPluginHandler pluginHandler;
private static Logger LOG = LoggerFactory.getLogger(FindbugsSensor.class);
- public FindbugsSensor(RulesProfile profile, RulesManager rulesManager, FindbugsMavenPluginHandler pluginHandler) {
+ public FindbugsSensor(RulesProfile profile, RuleFinder ruleFinder, FindbugsMavenPluginHandler pluginHandler) {
this.profile = profile;
- this.rulesManager = rulesManager;
+ this.ruleFinder = ruleFinder;
this.pluginHandler = pluginHandler;
}
@@ -57,12 +57,10 @@ public class FindbugsSensor implements Sensor, DependsUponMavenPlugin, Generates
FindbugsXmlReportParser reportParser = new FindbugsXmlReportParser(report);
List<FindbugsXmlReportParser.Violation> fbViolations = reportParser.getViolations();
for (FindbugsXmlReportParser.Violation fbViolation : fbViolations) {
- Rule rule = rulesManager.getPluginRule(CoreProperties.FINDBUGS_PLUGIN, fbViolation.getType());
+ Rule rule = ruleFinder.findByKey(FindbugsConstants.REPOSITORY_KEY, fbViolation.getType());
JavaFile resource = new JavaFile(fbViolation.getSonarJavaFileKey());
if (context.getResource(resource) != null) {
- Violation violation = new Violation(rule, resource)
- .setLineId(fbViolation.getStart())
- .setMessage(fbViolation.getLongMessage());
+ Violation violation = new Violation(rule, resource).setLineId(fbViolation.getStart()).setMessage(fbViolation.getLongMessage());
context.saveViolation(violation);
}
}
@@ -76,9 +74,9 @@ public class FindbugsSensor implements Sensor, DependsUponMavenPlugin, Generates
}
public boolean shouldExecuteOnProject(Project project) {
- return project.getFileSystem().hasJavaSourceFiles() &&
- ( !profile.getActiveRulesByPlugin(CoreProperties.FINDBUGS_PLUGIN).isEmpty() || project.getReuseExistingRulesConfig()) &&
- project.getPom() != null && !StringUtils.equalsIgnoreCase(project.getPom().getPackaging(), "ear");
+ return project.getFileSystem().hasJavaSourceFiles()
+ && ( !profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).isEmpty() || project.getReuseExistingRulesConfig())
+ && project.getPom() != null && !StringUtils.equalsIgnoreCase(project.getPom().getPackaging(), "ear");
}
public MavenPluginHandler getMavenPluginHandler(Project project) {
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfile.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfile.java
new file mode 100644
index 00000000000..e7b70e12dc1
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfile.java
@@ -0,0 +1,47 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.sonar.api.profiles.ProfileDefinition;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.resources.Java;
+import org.sonar.api.utils.ValidationMessages;
+
+public class SonarWayWithFindbugsProfile extends ProfileDefinition {
+
+ private FindbugsProfileImporter importer;
+
+ public SonarWayWithFindbugsProfile(FindbugsProfileImporter importer) {
+ this.importer = importer;
+ }
+
+ @Override
+ public RulesProfile createProfile(ValidationMessages messages) {
+ Reader pmdSonarWayProfile = new InputStreamReader(this.getClass().getResourceAsStream(
+ "/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml"));
+ RulesProfile profile = importer.importProfile(pmdSonarWayProfile, messages);
+ profile.setLanguage(Java.KEY);
+ profile.setName(RulesProfile.SONAR_WAY_FINDBUGS_NAME);
+ return profile;
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
index bd2f6284aed..9790f185d22 100644
--- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
+++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/xml/FindBugsFilter.java
@@ -29,6 +29,7 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.RulePriority;
import org.sonar.api.rules.RulePriorityMapper;
+import org.sonar.plugins.findbugs.FindbugsLevelUtils;
import java.io.IOException;
import java.io.InputStream;
@@ -69,7 +70,7 @@ public class FindBugsFilter {
matchs.add(child);
}
- public Map<String, RulePriority> getPatternLevels(RulePriorityMapper priorityMapper) {
+ public Map<String, RulePriority> getPatternLevels(FindbugsLevelUtils priorityMapper) {
BugInfoSplitter splitter = new BugInfoSplitter() {
public String getSeparator() {
return PATTERN_SEPARATOR;
@@ -82,7 +83,7 @@ public class FindBugsFilter {
return processMatches(priorityMapper, splitter);
}
- public Map<String, RulePriority> getCodeLevels(RulePriorityMapper priorityMapper) {
+ public Map<String, RulePriority> getCodeLevels(FindbugsLevelUtils priorityMapper) {
BugInfoSplitter splitter = new BugInfoSplitter() {
public String getSeparator() {
return CODE_SEPARATOR;
@@ -95,7 +96,7 @@ public class FindBugsFilter {
return processMatches(priorityMapper, splitter);
}
- public Map<String, RulePriority> getCategoryLevels(RulePriorityMapper priorityMapper) {
+ public Map<String, RulePriority> getCategoryLevels(FindbugsLevelUtils priorityMapper) {
BugInfoSplitter splitter = new BugInfoSplitter() {
public String getSeparator() {
return CATEGORY_SEPARATOR;
@@ -108,11 +109,11 @@ public class FindBugsFilter {
return processMatches(priorityMapper, splitter);
}
- private RulePriority getRulePriority(Priority priority, RulePriorityMapper priorityMapper) {
+ private RulePriority getRulePriority(Priority priority, FindbugsLevelUtils priorityMapper) {
return priority != null ? priorityMapper.from(priority.getValue()) : null;
}
- private Map<String, RulePriority> processMatches(RulePriorityMapper priorityMapper, BugInfoSplitter splitter) {
+ private Map<String, RulePriority> processMatches(FindbugsLevelUtils priorityMapper, BugInfoSplitter splitter) {
Map<String, RulePriority> result = new HashMap<String, RulePriority>();
for (Match child : getChildren()) {
if (child.getOrs() != null) {
@@ -127,7 +128,7 @@ public class FindBugsFilter {
return result;
}
- private void completeLevels(Map<String, RulePriority> result, List<Bug> bugs, Priority priority, RulePriorityMapper priorityMapper, BugInfoSplitter splitter) {
+ private void completeLevels(Map<String, RulePriority> result, List<Bug> bugs, Priority priority, FindbugsLevelUtils priorityMapper, BugInfoSplitter splitter) {
if (bugs == null) {
return;
}
@@ -174,33 +175,4 @@ public class FindBugsFilter {
xstream.processAnnotations(OrFilter.class);
return xstream;
}
-
- public static FindBugsFilter fromXml(String xml) {
- try {
- XStream xStream = createXStream();
- InputStream inputStream = IOUtils.toInputStream(xml, CharEncoding.UTF_8);
- return (FindBugsFilter) xStream.fromXML(inputStream);
-
- } catch (IOException e) {
- throw new RuntimeException("can't read configuration file", e);
- }
- }
-
- public static FindBugsFilter fromActiveRules(List<ActiveRule> activeRules) {
- FindBugsFilter root = new FindBugsFilter();
- for (ActiveRule activeRule : activeRules) {
- if (CoreProperties.FINDBUGS_PLUGIN.equals(activeRule.getPluginName())) {
- Match child = createChild(activeRule);
- root.addMatch(child);
- }
- }
- return root;
- }
-
- private static Match createChild(ActiveRule activeRule) {
- Match child = new Match();
- child.setBug(new Bug(activeRule.getConfigKey()));
- return child;
- }
-
}
diff --git a/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml b/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml
new file mode 100644
index 00000000000..d3b7e6c9fd6
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml
@@ -0,0 +1,1129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated by Sonar -->
+<FindBugsFilter>
+ <Match>
+ <Bug pattern="SA_LOCAL_SELF_COMPARISON"/>
+ </Match>
+ <Match>
+ <Bug pattern="UG_SYNC_SET_UNSYNC_GET"/>
+ </Match>
+ <Match>
+ <Bug pattern="IC_SUPERCLASS_USES_SUBCLASS_DURING_INITIALIZATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_FIELD_NAMING_CONVENTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_IMPOSSIBLE_DOWNCAST"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_FIELD_SELF_COMPUTATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS"/>
+ </Match>
+ <Match>
+ <Bug pattern="TQ_MAYBE_SOURCE_VALUE_REACHES_NEVER_SINK"/>
+ </Match>
+ <Match>
+ <Bug pattern="NO_NOTIFY_NOT_NOTIFYALL"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_BAD_ARGUMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="UPM_UNCALLED_PRIVATE_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="SF_DEAD_STORE_DUE_TO_SWITCH_FALLTHROUGH"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS"/>
+ </Match>
+ <Match>
+ <Bug pattern="LI_LAZY_INIT_UPDATE_STATIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_NONLONG_SERIALVERSIONID"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_THREAD_PASSED_WHERE_RUNNABLE_EXPECTED"/>
+ </Match>
+ <Match>
+ <Bug pattern="ODR_OPEN_DATABASE_RESOURCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_LCASE_HASHCODE"/>
+ </Match>
+ <Match>
+ <Bug pattern="VO_VOLATILE_REFERENCE_TO_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="XSS_REQUEST_PARAMETER_TO_JSP_WRITER"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_NUMBER_CTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="ITA_INEFFICIENT_TO_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="IJU_TEARDOWN_NO_SUPER"/>
+ </Match>
+ <Match>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_BAD_EQUAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_BOXED_PRIMITIVE_TOSTRING"/>
+ </Match>
+ <Match>
+ <Bug pattern="IJU_SUITE_NOT_STATIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="IM_MULTIPLYING_RESULT_OF_IREM"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_HASHCODE_USE_OBJECT_EQUALS"/>
+ </Match>
+ <Match>
+ <Bug pattern="IL_CONTAINER_ADDED_TO_ITSELF"/>
+ </Match>
+ <Match>
+ <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_BAD_CONVERSION"/>
+ </Match>
+ <Match>
+ <Bug pattern="SR_NOT_CHECKED"/>
+ </Match>
+ <Match>
+ <Bug pattern="DB_DUPLICATE_SWITCH_CLAUSES"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_PARAM_DEREF_NONVIRTUAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_RETURN_VALUE_IGNORED"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_EXCEPTION_NOT_THROWN"/>
+ </Match>
+ <Match>
+ <Bug pattern="DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED"/>
+ </Match>
+ <Match>
+ <Bug pattern="CO_SELF_NO_OBJECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_MUTABLE_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_CONVERT_CASE"/>
+ </Match>
+ <Match>
+ <Bug pattern="INT_VACUOUS_COMPARISON"/>
+ </Match>
+ <Match>
+ <Bug pattern="UW_UNCOND_WAIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_FINAL_PKGPROTECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_BOOLEAN_RETURN_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="DL_SYNCHRONIZATION_ON_UNSHARED_BOXED_PRIMITIVE"/>
+ </Match>
+ <Match>
+ <Bug pattern="TQ_MAYBE_SOURCE_VALUE_REACHES_ALWAYS_SINK"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_GC"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_RANDOM_USED_ONLY_ONCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="BX_BOXING_IMMEDIATELY_UNBOXED_TO_PERFORM_COERCION"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_SIGNED_CHECK_HIGH_BIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="DL_SYNCHRONIZATION_ON_BOXED_PRIMITIVE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DE_MIGHT_DROP"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_DONT_JUST_NULL_CHECK_READLINE"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_CHECK_FOR_POSITIVE_INDEXOF"/>
+ </Match>
+ <Match>
+ <Bug pattern="URF_UNREAD_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_USELESS_SUBSTRING"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_MONITOR_WAIT_ON_CONDITION"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_INSTANCEOF"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_PKGPROTECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_OVERRIDING_EQUALS_NOT_SYMMETRIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_UNRELATED_INTERFACES"/>
+ </Match>
+ <Match>
+ <Bug pattern="SWL_SLEEP_WITH_LOCK_HELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_FP_NUMBER_CTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_PUBLIC_SHOULD_BE_PROTECTED"/>
+ </Match>
+ <Match>
+ <Bug pattern="STI_INTERRUPTED_ON_CURRENTTHREAD"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DE_MIGHT_IGNORE"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_SIGNED_CHECK"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_BAD_MONTH"/>
+ </Match>
+ <Match>
+ <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_MISSING_SUPER_CALL"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_OTHER_NO_OBJECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="IJU_SETUP_NO_SUPER"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="SQL_BAD_PREPARED_STATEMENT_ACCESS"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_UNUSUAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_EMPTY"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_CLOSING_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="UWF_NULL_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_TRANSIENT_FIELD_OF_NONSERIALIZABLE_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="NN_NAKED_NOTIFY"/>
+ </Match>
+ <Match>
+ <Bug pattern="OS_OPEN_STREAM"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_USE_OF_UNHASHABLE_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_ABSTRACT_SELF"/>
+ </Match>
+ <Match>
+ <Bug pattern="J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION"/>
+ </Match>
+ <Match>
+ <Bug pattern="TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK"/>
+ </Match>
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES"/>
+ </Match>
+ <Match>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
+ </Match>
+ <Match>
+ <Bug pattern="JCIP_FIELD_ISNT_FINAL_IN_IMMUTABLE_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_SELF_USE_OBJECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_CLASS_NOT_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_METHOD_MUST_BE_PRIVATE"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_IMPOSSIBLE_INSTANCEOF"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_ARRAY_AND_NONARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_EXPLICIT_INVOCATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="SS_SHOULD_BE_STATIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_IOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_NONFINAL_SERIALVERSIONID"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_SHOULD_BE_FINAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_DONT_DEFINE_EQUALS_FOR_ENUM"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_EXTRA_ARGUMENTS_PASSED"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_ALWAYS_FALSE"/>
+ </Match>
+ <Match>
+ <Bug pattern="EI_EXPOSE_REP2"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_REM_OF_RANDOM_INT"/>
+ </Match>
+ <Match>
+ <Bug pattern="INT_VACUOUS_BIT_OPERATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="SF_SWITCH_NO_DEFAULT"/>
+ </Match>
+ <Match>
+ <Bug pattern="IL_INFINITE_LOOP"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_PARAM_DEREF"/>
+ </Match>
+ <Match>
+ <Bug pattern="AM_CREATES_EMPTY_JAR_FILE_ENTRY"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_COMPARING_CLASS_NAMES"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_ALWAYS_NULL_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="DB_DUPLICATE_BRANCHES"/>
+ </Match>
+ <Match>
+ <Bug pattern="IMSE_DONT_CATCH_IMSE"/>
+ </Match>
+ <Match>
+ <Bug pattern="XSS_REQUEST_PARAMETER_TO_SERVLET_WRITER"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_STRING_CTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_NO_SERIALVERSIONID"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_BAD_FIELD_STORE"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME"/>
+ </Match>
+ <Match>
+ <Bug pattern="RU_INVOKE_RUN"/>
+ </Match>
+ <Match>
+ <Bug pattern="SQL_BAD_RESULTSET_ACCESS"/>
+ </Match>
+ <Match>
+ <Bug pattern="IJU_ASSERT_METHOD_INVOKED_FROM_RUN_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="BX_BOXING_IMMEDIATELY_UNBOXED"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_BAD_CONVERSION_FROM_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_HASHCODE_NO_EQUALS"/>
+ </Match>
+ <Match>
+ <Bug pattern="SI_INSTANCE_BEFORE_FINALS_ASSIGNED"/>
+ </Match>
+ <Match>
+ <Bug pattern="UI_INHERITANCE_UNSAFE_GETRESOURCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_SYNC_AND_NULL_CHECK_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="RpC_REPEATED_CONDITIONAL_TEST"/>
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE_IN_RETURN"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_UNRELATED_CLASS_AND_INTERFACE"/>
+ </Match>
+ <Match>
+ <Bug pattern="RE_CANT_USE_FILE_SEPARATOR_AS_REGULAR_EXPRESSION"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_INHERITS_EQUALS_USE_HASHCODE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_DEREFERENCE_OF_READLINE_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="WA_NOT_IN_LOOP"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_IMPOSSIBLE_CAST"/>
+ </Match>
+ <Match>
+ <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_ON_SOME_PATH_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="IC_INIT_CIRCULARITY"/>
+ </Match>
+ <Match>
+ <Bug pattern="UM_UNNECESSARY_MATH"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_CLASS_NAMING_CONVENTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="STCAL_STATIC_CALENDAR_INSTANCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_ALWAYS_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_GUARANTEED_DEREF_ON_EXCEPTION_PATH"/>
+ </Match>
+ <Match>
+ <Bug pattern="UUF_UNUSED_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/>
+ </Match>
+ <Match>
+ <Bug pattern="INT_BAD_COMPARISON_WITH_SIGNED_BYTE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_CLONE_COULD_RETURN_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_EQUALS_NO_HASHCODE"/>
+ </Match>
+ <Match>
+ <Bug pattern="IS_FIELD_NOT_GUARDED"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_LCASE_TOSTRING"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_WRONG_PACKAGE"/>
+ </Match>
+ <Match>
+ <Bug pattern="UCF_USELESS_CONTROL_FLOW"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_USELESS_THREAD"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_USING_REMOVEALL_TO_CLEAR_COLLECTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_BAD_SHIFT_AMOUNT"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_NULLIFY_SUPER"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_MUTABLE_HASHTABLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_READ_RESOLVE_MUST_RETURN_OBJECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="SIO_SUPERFLUOUS_INSTANCEOF"/>
+ </Match>
+ <Match>
+ <Bug pattern="BOA_BADLY_OVERRIDDEN_ADAPTER"/>
+ </Match>
+ <Match>
+ <Bug pattern="IM_AVERAGE_COMPUTATION_COULD_OVERFLOW"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_NEW_FOR_GETCLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_CONFUSING"/>
+ </Match>
+ <Match>
+ <Bug pattern="WMI_WRONG_MAP_ITERATOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_UNWRITTEN_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_BAD_FIELD_INNER_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/>
+ </Match>
+ <Match>
+ <Bug pattern="UCF_USELESS_CONTROL_FLOW_NEXT_LINE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_GUARANTEED_DEREF"/>
+ </Match>
+ <Match>
+ <Bug pattern="EI_EXPOSE_STATIC_REP2"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_FUTURE_KEYWORD_USED_AS_MEMBER_IDENTIFIER"/>
+ </Match>
+ <Match>
+ <Bug pattern="WA_AWAIT_NOT_IN_LOOP"/>
+ </Match>
+ <Match>
+ <Bug pattern="RC_REF_COMPARISON"/>
+ </Match>
+ <Match>
+ <Bug pattern="SC_START_IN_CTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="MF_CLASS_MASKS_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
+ </Match>
+ <Match>
+ <Bug pattern="PS_PUBLIC_SEMAPHORES"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_INVOKING_HASHCODE_ON_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="SKIPPED_CLASS_TOO_BIG"/>
+ </Match>
+ <Match>
+ <Bug pattern="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="HSC_HUGE_SHARED_STRING_CONSTANT"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_LOCAL_SELF_COMPUTATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_ILLEGAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_NO_SUITABLE_CONSTRUCTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="MWN_MISMATCHED_NOTIFY"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS"/>
+ </Match>
+ <Match>
+ <Bug pattern="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_READ_RESOLVE_IS_STATIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_LOCAL_DOUBLE_ASSIGNMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="DP_DO_INSIDE_DO_PRIVILEGED"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_RETURN_VALUE_IGNORED2"/>
+ </Match>
+ <Match>
+ <Bug pattern="RI_REDUNDANT_INTERFACES"/>
+ </Match>
+ <Match>
+ <Bug pattern="MTIA_SUSPECT_SERVLET_INSTANCE_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_FINALIZER_ONLY_NULLS_FIELDS"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_VERY_CONFUSING"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_NO_PREVIOUS_ARGUMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="IO_APPENDING_TO_OBJECT_OUTPUT_STREAM"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_RUN_FINALIZERS_ON_EXIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="STCAL_STATIC_SIMPLE_DATE_FORMAT_INSTANCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_FINALIZER_NULLS_FIELDS"/>
+ </Match>
+ <Match>
+ <Bug pattern="FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_UNSUPPORTED_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="TLW_TWO_LOCK_WAIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_CONSTANT_DB_PASSWORD"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_01_TO_INT"/>
+ </Match>
+ <Match>
+ <Bug pattern="IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_COLLECTION_OF_URLS"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_AND_ZZ"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_STRING_VOID_CTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="UL_UNRELEASED_LOCK"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_METHOD_NAMING_CONVENTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="HRS_REQUEST_PARAMETER_TO_HTTP_HEADER"/>
+ </Match>
+ <Match>
+ <Bug pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="SIC_THREADLOCAL_DEADLY_EMBRACE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DL_SYNCHRONIZATION_ON_SHARED_CONSTANT"/>
+ </Match>
+ <Match>
+ <Bug pattern="MF_METHOD_MASKS_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_WRONG_PACKAGE_INTENTIONAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="INT_BAD_REM_BY_1"/>
+ </Match>
+ <Match>
+ <Bug pattern="ES_COMPARING_STRINGS_WITH_EQ"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_FIELD_SELF_COMPARISON"/>
+ </Match>
+ <Match>
+ <Bug pattern="QF_QUESTIONABLE_FOR_LOOP"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_BAD_CONVERSION_TO_BOOLEAN"/>
+ </Match>
+ <Match>
+ <Bug pattern="XFB_XML_FACTORY_BYPASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_INNER_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="CI_CONFUSED_INHERITANCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="UWF_UNWRITTEN_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="WS_WRITEOBJECT_SYNC"/>
+ </Match>
+ <Match>
+ <Bug pattern="CN_IDIOM_NO_SUPER_CALL"/>
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_STORE_OF_CLASS_LITERAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS"/>
+ </Match>
+ <Match>
+ <Bug pattern="FI_USELESS"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_METHOD_CONSTRUCTOR_CONFUSION"/>
+ </Match>
+ <Match>
+ <Bug pattern="ML_SYNC_ON_FIELD_TO_GUARD_CHANGING_THAT_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="MWN_MISMATCHED_WAIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="ML_SYNC_ON_UPDATED_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="FL_MATH_USING_FLOAT_PRECISION"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_NEXTINT_VIA_NEXTDOUBLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_EXPECTED_MESSAGE_FORMAT_SUPPLIED"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_NONSERIALIZABLE_OBJECT_WRITTEN"/>
+ </Match>
+ <Match>
+ <Bug pattern="MTIA_SUSPECT_STRUTS_INSTANCE_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_OTHER_USE_OBJECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE_OF_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_BLOCKING_METHODS_ON_URL"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_CANNOT_BE_FINAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_STORE_INTO_NONNULL_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="IM_BAD_CHECK_FOR_ODD"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_VERY_CONFUSING_INTENTIONAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="SP_SPIN_ON_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="IS2_INCONSISTENT_SYNC"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL"/>
+ </Match>
+ <Match>
+ <Bug pattern="ODR_OPEN_DATABASE_RESOURCE_EXCEPTION_PATH"/>
+ </Match>
+ <Match>
+ <Bug pattern="CN_IDIOM"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_SCHEDULED_THREAD_POOL_EXECUTOR_WITH_ZERO_CORE_THREADS"/>
+ </Match>
+ <Match>
+ <Bug pattern="XSS_REQUEST_PARAMETER_TO_SEND_ERROR"/>
+ </Match>
+ <Match>
+ <Bug pattern="GC_UNCHECKED_TYPE_IN_GENERIC_CALL"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_PRIVATE_READ_RESOLVE_NOT_INHERITED"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_INVOKING_TOSTRING_ON_ARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="DL_SYNCHRONIZATION_ON_BOOLEAN"/>
+ </Match>
+ <Match>
+ <Bug pattern="SW_SWING_METHODS_INVOKED_IN_SWING_THREAD"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_ARGUMENT_MIGHT_BE_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="CO_ABSTRACT_SELF"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_EXIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED"/>
+ </Match>
+ <Match>
+ <Bug pattern="DC_DOUBLECHECK"/>
+ </Match>
+ <Match>
+ <Bug pattern="UL_UNRELEASED_LOCK_EXCEPTION_PATH"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_BAD_ARRAY_COMPARE"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_BAD_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_LOCAL_SELF_ASSIGNMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="REC_CATCH_EXCEPTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="TQ_NEVER_VALUE_USED_WHERE_ALWAYS_REQUIRED"/>
+ </Match>
+ <Match>
+ <Bug pattern="UR_UNINIT_READ"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_VACUOUS_SELF_COLLECTION_CALL"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_FUTILE_ATTEMPT_TO_CHANGE_MAXPOOL_SIZE_OF_SCHEDULED_THREAD_POOL_EXECUTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_AND"/>
+ </Match>
+ <Match>
+ <Bug pattern="RR_NOT_CHECKED"/>
+ </Match>
+ <Match>
+ <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_SELF_NO_OBJECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_TOSTRING_COULD_RETURN_NULL"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_COLLECTIONS_SHOULD_NOT_CONTAIN_THEMSELVES"/>
+ </Match>
+ <Match>
+ <Bug pattern="GC_UNRELATED_TYPES"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_SIGNATURE_DECLARES_HASHING_OF_UNHASHABLE_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_NULL_ARG"/>
+ </Match>
+ <Match>
+ <Bug pattern="IL_INFINITE_RECURSIVE_LOOP"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NONNULL_RETURN_VIOLATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_STRING_TOSTRING"/>
+ </Match>
+ <Match>
+ <Bug pattern="AM_CREATES_EMPTY_ZIP_FILE_ENTRY"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_PRIMITIVE_ARRAY_PASSED_TO_OBJECT_VARARG"/>
+ </Match>
+ <Match>
+ <Bug pattern="NS_NON_SHORT_CIRCUIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_BOOLEAN_CTOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_BAD_CAST_TO_CONCRETE_COLLECTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_NEEDS_THIS"/>
+ </Match>
+ <Match>
+ <Bug pattern="LI_LAZY_INIT_STATIC"/>
+ </Match>
+ <Match>
+ <Bug pattern="HE_EQUALS_USE_HASHCODE"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_ABSOLUTE_VALUE_OF_RANDOM_INT"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_VACUOUS_CALL_TO_EASYMOCK_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_INTEGER_MULTIPLY_CAST_TO_LONG"/>
+ </Match>
+ <Match>
+ <Bug pattern="NM_SAME_SIMPLE_NAME_AS_INTERFACE"/>
+ </Match>
+ <Match>
+ <Bug pattern="STI_INTERRUPTED_ON_UNKNOWNTHREAD"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_FIELD_SELF_ASSIGNMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_EMPTY_DB_PASSWORD"/>
+ </Match>
+ <Match>
+ <Bug pattern="IJU_BAD_SUITE_METHOD"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_MISSING_ARGUMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_ADD_OF_SIGNED_BYTE"/>
+ </Match>
+ <Match>
+ <Bug pattern="SBSC_USE_STRINGBUFFER_CONCATENATION"/>
+ </Match>
+ <Match>
+ <Bug pattern="WL_USING_GETCLASS_RATHER_THAN_CLASS_LITERAL"/>
+ </Match>
+ <Match>
+ <Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE"/>
+ </Match>
+ <Match>
+ <Bug pattern="TQ_ALWAYS_VALUE_USED_WHERE_NEVER_REQUIRED"/>
+ </Match>
+ <Match>
+ <Bug pattern="RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_ALWAYS_TRUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="STCAL_INVOKE_ON_STATIC_CALENDAR_INSTANCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="ISC_INSTANTIATE_STATIC_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_BAD_CAST_TO_ABSTRACT_COLLECTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="IT_NO_SUCH_ELEMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="EI_EXPOSE_REP"/>
+ </Match>
+ <Match>
+ <Bug pattern="INT_BAD_COMPARISON_WITH_NONNEGATIVE_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="MSF_MUTABLE_SERVLET_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="BIT_IOR_OF_SIGNED_BYTE"/>
+ </Match>
+ <Match>
+ <Bug pattern="JLM_JSR166_LOCK_MONITORENTER"/>
+ </Match>
+ <Match>
+ <Bug pattern="IS_INCONSISTENT_SYNC"/>
+ </Match>
+ <Match>
+ <Bug pattern="LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_REM_OF_HASHCODE"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND"/>
+ </Match>
+ <Match>
+ <Bug pattern="SE_NONSTATIC_SERIALVERSIONID"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_VACUOUS_INSTANCEOF"/>
+ </Match>
+ <Match>
+ <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_ABSOLUTE_VALUE_OF_HASHCODE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_CALLING_NEXT_FROM_HASNEXT"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_NULL_ON_SOME_PATH"/>
+ </Match>
+ <Match>
+ <Bug pattern="RS_READOBJECT_SYNC"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_INCOMPATIBLE_ARRAY_COMPARE"/>
+ </Match>
+ <Match>
+ <Bug pattern="NS_DANGEROUS_NON_SHORT_CIRCUIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY"/>
+ </Match>
+ <Match>
+ <Bug pattern="BC_UNCONFIRMED_CAST"/>
+ </Match>
+ <Match>
+ <Bug pattern="EQ_GETCLASS_AND_CLASS_CONSTANT"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_FIELD_DOUBLE_ASSIGNMENT"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_ARG_MISMATCH"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_OOI_PKGPROTECT"/>
+ </Match>
+ <Match>
+ <Bug pattern="EC_UNRELATED_TYPES"/>
+ </Match>
+ <Match>
+ <Bug pattern="MS_EXPOSE_REP"/>
+ </Match>
+ <Match>
+ <Bug pattern="BX_UNBOXED_AND_COERCED_FOR_TERNARY_OPERATOR"/>
+ </Match>
+ <Match>
+ <Bug pattern="SF_SWITCH_FALLTHROUGH"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_IMMEDIATE_DEREFERENCE_OF_READLINE"/>
+ </Match>
+ <Match>
+ <Bug pattern="ESync_EMPTY_SYNC"/>
+ </Match>
+ <Match>
+ <Bug pattern="HRS_REQUEST_PARAMETER_TO_COOKIE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_LONG_BITS_TO_DOUBLE_INVOKED_ON_INT"/>
+ </Match>
+ <Match>
+ <Bug pattern="UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS"/>
+ </Match>
+ <Match>
+ <Bug pattern="IJU_NO_TESTS"/>
+ </Match>
+ <Match>
+ <Bug pattern="RE_POSSIBLE_UNINTENDED_PATTERN"/>
+ </Match>
+ <Match>
+ <Bug pattern="DLS_OVERWRITTEN_INCREMENT"/>
+ </Match>
+</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java
index 9b443c0c2ec..30bbd30d199 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsMavenPluginHandlerTest.java
@@ -52,7 +52,6 @@ public class FindbugsMavenPluginHandlerTest {
private Project project;
private ProjectFileSystem fs;
private File fakeSonarConfig;
- private FindbugsRulesRepository repo;
private MavenPlugin plugin;
private FindbugsMavenPluginHandler handler;
@@ -61,7 +60,6 @@ public class FindbugsMavenPluginHandlerTest {
project = mock(Project.class);
fs = mock(ProjectFileSystem.class);
fakeSonarConfig = mock(File.class);
- repo = mock(FindbugsRulesRepository.class);
plugin = mock(MavenPlugin.class);
handler = createMavenPluginHandler();
}
@@ -173,8 +171,7 @@ public class FindbugsMavenPluginHandlerTest {
}
private FindbugsMavenPluginHandler createMavenPluginHandler() {
- when(repo.exportConfiguration((RulesProfile) anyObject())).thenReturn("<test/>");
- return new FindbugsMavenPluginHandler(new RulesProfile(), repo);
+ return new FindbugsMavenPluginHandler(RulesProfile.create(), new FindbugsProfileExporter());
}
private void mockProject(String effort) throws URISyntaxException, IOException {
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/xml/FindBugsFilterTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileExporterTest.java
index 384dc56882f..52b7c246781 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/xml/FindBugsFilterTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileExporterTest.java
@@ -1,124 +1,131 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.findbugs.xml;
-
-import org.apache.commons.io.IOUtils;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.rules.ActiveRule;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulePriority;
-import org.sonar.plugins.findbugs.FindbugsRulePriorityMapper;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class FindBugsFilterTest extends FindBugsXmlTests {
-
- @Test
- public void shouldBuilXmlFromModuleTree() throws IOException, SAXException {
- FindBugsFilter root = buildModuleTreeFixture();
-
- String xml = root.toXml();
-
- assertXmlAreSimilar(xml, "test_module_tree.xml");
- }
-
- @Test
- public void shouldBuilModuleTreeFromXml() throws IOException {
- InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/test_module_tree.xml");
-
- FindBugsFilter module = FindBugsFilter.fromXml(IOUtils.toString(input));
-
- List<Match> matches = module.getMatchs();
- assertThat(matches.size(), is(2));
- assertChild(matches.get(0), "DLS_DEAD_LOCAL_STORE");
- assertChild(matches.get(1), "URF_UNREAD_FIELD");
- }
-
- private static FindBugsFilter buildModuleTreeFixture() {
- FindBugsFilter findBugsFilter = new FindBugsFilter();
- findBugsFilter.addMatch(new Match(new Bug("DLS_DEAD_LOCAL_STORE")));
- findBugsFilter.addMatch(new Match(new Bug("URF_UNREAD_FIELD")));
- return findBugsFilter;
- }
-
- private static final String DLS_DEAD_LOCAL_STORE = "DLS_DEAD_LOCAL_STORE";
- private static final String SS_SHOULD_BE_STATIC = "SS_SHOULD_BE_STATIC";
-
- @Test
- public void shouldBuildModuleWithProperties() {
- ActiveRule activeRule = anActiveRule(DLS_DEAD_LOCAL_STORE);
- FindBugsFilter filter = FindBugsFilter.fromActiveRules(Arrays.asList(activeRule));
-
- assertThat(filter.getMatchs().size(), is(1));
- assertChild(filter.getMatchs().get(0), DLS_DEAD_LOCAL_STORE);
- }
-
- @Test
- public void shouldBuildOnlyOneModuleWhenNoActiveRules() {
- FindBugsFilter filter = FindBugsFilter.fromActiveRules(Collections.<ActiveRule>emptyList());
- assertThat(filter.getMatchs().size(), is(0));
- }
-
- @Test
- public void shouldBuildTwoModulesEvenIfSameTwoRulesActivated() {
- ActiveRule activeRule1 = anActiveRule(DLS_DEAD_LOCAL_STORE);
- ActiveRule activeRule2 = anActiveRule(SS_SHOULD_BE_STATIC);
- FindBugsFilter filter = FindBugsFilter.fromActiveRules(Arrays.asList(activeRule1, activeRule2));
-
- List<Match> matches = filter.getMatchs();
- assertThat(matches.size(), is(2));
-
- assertChild(matches.get(0), DLS_DEAD_LOCAL_STORE);
- assertChild(matches.get(1), SS_SHOULD_BE_STATIC);
- }
-
- @Test
- public void shouldBuildOnlyOneModuleWhenNoFindbugsActiveRules() {
- ActiveRule activeRule1 = anActiveRuleFromAnotherPlugin();
- ActiveRule activeRule2 = anActiveRuleFromAnotherPlugin();
-
- FindBugsFilter filter = FindBugsFilter.fromActiveRules(Arrays.asList(activeRule1, activeRule2));
- assertThat(filter.getMatchs().size(), is(0));
- }
-
- private static ActiveRule anActiveRule(String configKey) {
- Rule rule = new Rule();
- rule.setConfigKey(configKey);
- rule.setPluginName(CoreProperties.FINDBUGS_PLUGIN);
- ActiveRule activeRule = new ActiveRule(null, rule, RulePriority.CRITICAL);
- return activeRule;
- }
-
- private static ActiveRule anActiveRuleFromAnotherPlugin() {
- Rule rule1 = new Rule();
- rule1.setPluginName("not-a-findbugs-plugin");
- ActiveRule activeRule1 = new ActiveRule(null, rule1, RulePriority.CRITICAL);
- return activeRule1;
- }
-
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Test;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RulePriority;
+import org.sonar.plugins.findbugs.xml.Bug;
+import org.sonar.plugins.findbugs.xml.FindBugsFilter;
+import org.sonar.plugins.findbugs.xml.Match;
+import org.xml.sax.SAXException;
+
+public class FindbugsProfileExporterTest extends FindbugsTests {
+
+ private FindbugsProfileExporter exporter = new FindbugsProfileExporter();
+
+ @Test
+ public void shouldAddHeaderToExportedXml() throws IOException, SAXException {
+ RulesProfile profile = RulesProfile.create();
+
+ StringWriter xml = new StringWriter();
+ exporter.exportProfile(profile, xml);
+ assertXmlAreSimilar(xml.toString(), "test_header.xml");
+ }
+
+ @Test
+ public void shouldExportConfiguration() throws IOException, SAXException {
+ List<Rule> rules = buildRulesFixture();
+ List<ActiveRule> activeRulesExpected = buildActiveRulesFixture(rules);
+ RulesProfile profile = RulesProfile.create();
+ profile.setActiveRules(activeRulesExpected);
+
+ StringWriter xml = new StringWriter();
+ exporter.exportProfile(profile, xml);
+ assertXmlAreSimilar(xml.toString(), "test_xml_complete.xml");
+ }
+
+ @Test
+ public void shouldBuildOnlyOneModuleWhenNoActiveRules() {
+ FindBugsFilter filter = FindbugsProfileExporter.buildFindbugsFilter(Collections.<ActiveRule> emptyList());
+ assertThat(filter.getMatchs().size(), is(0));
+ }
+
+ @Test
+ public void shouldBuildTwoModulesEvenIfSameTwoRulesActivated() {
+ ActiveRule activeRule1 = anActiveRule(DLS_DEAD_LOCAL_STORE);
+ ActiveRule activeRule2 = anActiveRule(SS_SHOULD_BE_STATIC);
+ FindBugsFilter filter = FindbugsProfileExporter.buildFindbugsFilter(Arrays.asList(activeRule1, activeRule2));
+
+ List<Match> matches = filter.getMatchs();
+ assertThat(matches.size(), is(2));
+
+ assertThat(matches.get(0).getBug().getPattern(), is("DLS_DEAD_LOCAL_STORE"));
+ assertThat(matches.get(1).getBug().getPattern(), is("SS_SHOULD_BE_STATIC"));
+ }
+
+ @Test
+ public void shouldBuildOnlyOneModuleWhenNoFindbugsActiveRules() {
+ ActiveRule activeRule1 = anActiveRuleFromAnotherPlugin();
+ ActiveRule activeRule2 = anActiveRuleFromAnotherPlugin();
+
+ FindBugsFilter filter = FindbugsProfileExporter.buildFindbugsFilter(Arrays.asList(activeRule1, activeRule2));
+ assertThat(filter.getMatchs().size(), is(0));
+ }
+
+ @Test
+ public void shouldBuildModuleWithProperties() {
+ ActiveRule activeRule = anActiveRule(DLS_DEAD_LOCAL_STORE);
+ FindBugsFilter filter = FindbugsProfileExporter.buildFindbugsFilter(Arrays.asList(activeRule));
+
+ assertThat(filter.getMatchs().size(), is(1));
+ assertThat(filter.getMatchs().get(0).getBug().getPattern(), is("DLS_DEAD_LOCAL_STORE"));
+ }
+
+ @Test
+ public void shouldBuilXmlFromModuleTree() throws IOException, SAXException {
+ FindBugsFilter findBugsFilter = new FindBugsFilter();
+ findBugsFilter.addMatch(new Match(new Bug("DLS_DEAD_LOCAL_STORE")));
+ findBugsFilter.addMatch(new Match(new Bug("URF_UNREAD_FIELD")));
+
+ String xml = findBugsFilter.toXml();
+
+ assertXmlAreSimilar(xml, "test_module_tree.xml");
+ }
+
+ private static final String DLS_DEAD_LOCAL_STORE = "DLS_DEAD_LOCAL_STORE";
+ private static final String SS_SHOULD_BE_STATIC = "SS_SHOULD_BE_STATIC";
+
+ private static ActiveRule anActiveRule(String configKey) {
+ Rule rule = Rule.create();
+ rule.setConfigKey(configKey);
+ rule.setRepositoryKey(FindbugsConstants.REPOSITORY_KEY);
+ ActiveRule activeRule = RulesProfile.create().activateRule(rule, RulePriority.CRITICAL);
+ return activeRule;
+ }
+
+ private static ActiveRule anActiveRuleFromAnotherPlugin() {
+ Rule rule = Rule.create();
+ rule.setPluginName("not-a-findbugs-plugin");
+ ActiveRule activeRule = RulesProfile.create().activateRule(rule, RulePriority.CRITICAL);
+ return activeRule;
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java
new file mode 100644
index 00000000000..b829ce9abf1
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsProfileImporterTest.java
@@ -0,0 +1,144 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.api.utils.ValidationMessages;
+import org.sonar.plugins.findbugs.xml.FindBugsFilter;
+import org.sonar.plugins.findbugs.xml.Match;
+import org.sonar.test.TestUtils;
+
+import com.thoughtworks.xstream.XStream;
+
+public class FindbugsProfileImporterTest {
+
+ private FindbugsProfileImporter importer = new FindbugsProfileImporter(new FindbugsRuleFinder());
+
+ @Test
+ public void shouldImportPatterns() throws IOException {
+ String findbugsConf = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/shouldImportPatterns.xml");
+ RulesProfile profile = importer.importProfile(new StringReader(findbugsConf), ValidationMessages.create());
+
+ assertThat(profile.getActiveRules().size(), is(2));
+ assertThat(profile.getActiveRule(FindbugsConstants.REPOSITORY_KEY, "NP_CLOSING_NULL"), is(notNullValue()));
+ assertThat(profile.getActiveRule(FindbugsConstants.REPOSITORY_KEY, "RC_REF_COMPARISON_BAD_PRACTICE"), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldImportCodes() throws IOException {
+ InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/shouldImportCodes.xml");
+ RulesProfile profile = importer.importProfile(new InputStreamReader(input), ValidationMessages.create());
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(18));
+ assertThat(profile.getActiveRule(FindbugsConstants.REPOSITORY_KEY, "EC_INCOMPATIBLE_ARRAY_COMPARE"), is(notNullValue()));
+ assertThat(profile.getActiveRule(FindbugsConstants.REPOSITORY_KEY, "BC_IMPOSSIBLE_DOWNCAST_OF_TOARRAY"), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldImportCategories() throws IOException {
+ InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/shouldImportCategories.xml");
+ RulesProfile profile = importer.importProfile(new InputStreamReader(input), ValidationMessages.create());
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(183));
+ assertThat(profile.getActiveRule(FindbugsConstants.REPOSITORY_KEY, "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE"), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldImportConfigurationBugInclude() throws IOException {
+ InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/findbugs-include.xml");
+ RulesProfile profile = importer.importProfile(new InputStreamReader(input), ValidationMessages.create());
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(11));
+ assertThat(profile.getActiveRule(FindbugsConstants.REPOSITORY_KEY, "RC_REF_COMPARISON_BAD_PRACTICE"), is(notNullValue()));
+ }
+
+ @Test
+ public void shouldBuilModuleTreeFromXml() throws IOException {
+ InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/test_module_tree.xml");
+
+ XStream xStream = FindBugsFilter.createXStream();
+ FindBugsFilter filter = (FindBugsFilter) xStream.fromXML(IOUtils.toString(input));
+
+ List<Match> matches = filter.getMatchs();
+ assertThat(matches.size(), is(2));
+ assertThat(matches.get(0).getBug().getPattern(), is("DLS_DEAD_LOCAL_STORE"));
+ assertThat(matches.get(1).getBug().getPattern(), is("URF_UNREAD_FIELD"));
+ }
+
+ @Test
+ public void testImportingUncorrectXmlFile() throws IOException {
+ String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/uncorrectFindbugsXml.xml");
+ ValidationMessages messages = ValidationMessages.create();
+ RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages);
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(0));
+ assertThat(messages.getErrors().size(), is(1));
+ }
+
+ @Test
+ public void testImportingXmlFileWithUnknownRule() throws IOException {
+ String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml");
+ ValidationMessages messages = ValidationMessages.create();
+ RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages);
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(1));
+ assertThat(messages.getWarnings().size(), is(1));
+ }
+
+ @Test
+ public void testImportingXmlFileWithUnknownCategory() throws IOException {
+ String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml");
+ ValidationMessages messages = ValidationMessages.create();
+ RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages);
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(142));
+ assertThat(messages.getWarnings().size(), is(1));
+ }
+
+ @Test
+ public void testImportingXmlFileWithUnknownCode() throws IOException {
+ String uncorrectFindbugsXml = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml");
+ ValidationMessages messages = ValidationMessages.create();
+ RulesProfile profile = importer.importProfile(new StringReader(uncorrectFindbugsXml), messages);
+ List<ActiveRule> results = profile.getActiveRules();
+
+ assertThat(results.size(), is(9));
+ assertThat(messages.getWarnings().size(), is(1));
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleFinder.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleFinder.java
new file mode 100644
index 00000000000..44c279b4f6e
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleFinder.java
@@ -0,0 +1,57 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.rules.RuleQuery;
+
+public class FindbugsRuleFinder implements RuleFinder {
+
+ private final List<Rule> findbugsRules;
+
+ public FindbugsRuleFinder() {
+ FindbugsRuleRepository repo = new FindbugsRuleRepository();
+ findbugsRules = repo.createRules();
+ for(Rule rule : findbugsRules){
+ rule.setRepositoryKey(FindbugsConstants.REPOSITORY_KEY);
+ }
+ }
+
+ public Rule findByKey(String repositoryKey, String key) {
+ for (Rule rule : findbugsRules) {
+ if (rule.getKey().equals(key)) {
+ return rule;
+ }
+ }
+ return null;
+ }
+
+ public Rule find(RuleQuery query) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<Rule> findAll(RuleQuery query) {
+ return findbugsRules;
+ }
+} \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleRepositoryTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleRepositoryTest.java
new file mode 100644
index 00000000000..d8c9ff8a32c
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRuleRepositoryTest.java
@@ -0,0 +1,45 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.sonar.api.rules.Rule;
+
+public class FindbugsRuleRepositoryTest {
+
+ @Test
+ public void testLoadRepositoryFromXml() {
+ FindbugsRuleRepository repository = new FindbugsRuleRepository();
+ List<Rule> rules = repository.createRules();
+ assertThat(rules.size(), greaterThan(300));
+ for (Rule rule : rules) {
+ assertNotNull(rule.getKey());
+ assertNotNull(rule.getDescription());
+ assertNotNull(rule.getConfigKey());
+ assertNotNull(rule.getName());
+ }
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest.java
deleted file mode 100644
index 2033a209f43..00000000000
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.findbugs;
-
-import org.apache.commons.io.IOUtils;
-import org.hamcrest.BaseMatcher;
-import static org.hamcrest.CoreMatchers.is;
-import org.hamcrest.Description;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.resources.Java;
-import org.sonar.api.rules.ActiveRule;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulePriority;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class FindbugsRulesRepositoryTest extends FindbugsTests {
-
- private FindbugsRulesRepository repository;
-
- @Before
- public void setup() {
- repository = new FindbugsRulesRepository(new Java());
- }
-
- @Test
- public void rulesAreDefinedWithTheDefaultSonarXmlFormat() {
- List<Rule> rules = repository.getInitialReferential();
- assertTrue(rules.size() > 0);
- for (Rule rule : rules) {
- assertNotNull(rule.getKey());
- assertNotNull(rule.getDescription());
- assertNotNull(rule.getConfigKey());
- assertNotNull(rule.getName());
- }
- }
-
- @Test
- @Ignore
- public void shouldProvideProfiles() {
- List<RulesProfile> profiles = repository.getProvidedProfiles();
- assertThat(profiles.size(), is(1));
-
- RulesProfile profile1 = profiles.get(0);
- assertThat(profile1.getName(), is(RulesProfile.SONAR_WAY_FINDBUGS_NAME));
- assertEquals(profile1.getActiveRules().size(), 344);
- }
-
- @Test
- public void shouldAddHeaderToExportedXml() throws IOException, SAXException {
- RulesProfile rulesProfile = mock(RulesProfile.class);
- when(rulesProfile.getActiveRulesByPlugin(CoreProperties.FINDBUGS_PLUGIN)).thenReturn(Collections.<ActiveRule>emptyList());
-
- assertXmlAreSimilar(repository.exportConfiguration(rulesProfile), "test_header.xml");
- }
-
- @Test
- public void shouldExportConfiguration() throws IOException, SAXException {
- List<Rule> rules = buildRulesFixture();
- List<ActiveRule> activeRulesExpected = buildActiveRulesFixture(rules);
- RulesProfile activeProfile = new RulesProfile();
- activeProfile.setActiveRules(activeRulesExpected);
-
- assertXmlAreSimilar(repository.exportConfiguration(activeProfile), "test_xml_complete.xml");
- }
-
- @Test
- public void shouldImportPatterns() throws IOException {
- InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportPatterns.xml");
- List<ActiveRule> results = repository.importConfiguration(IOUtils.toString(input), buildRulesFixtureImport());
-
- assertThat(results.size(), is(2));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_1", RulePriority.MAJOR));
- assertThat(results, new ContainsActiveRule("FB2_IMPORT_TEST_4", RulePriority.MAJOR));
- }
-
- @Test
- public void shouldImportCodes() throws IOException {
- InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCodes.xml");
- List<ActiveRule> results = repository.importConfiguration(IOUtils.toString(input), buildRulesFixtureImport());
-
- assertThat(results.size(), is(4));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_1", RulePriority.MAJOR));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_2", RulePriority.MAJOR));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_3", RulePriority.MAJOR));
- assertThat(results, new ContainsActiveRule("FB3_IMPORT_TEST_5", RulePriority.MAJOR));
- }
-
- @Test
- public void shouldImportCategories() throws IOException {
- InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCategories.xml");
- List<ActiveRule> results = repository.importConfiguration(IOUtils.toString(input), buildRulesFixtureImport());
-
- assertThat(results.size(), is(4));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_1", RulePriority.INFO));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_2", RulePriority.INFO));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_3", RulePriority.INFO));
- assertThat(results, new ContainsActiveRule("FB2_IMPORT_TEST_4", RulePriority.INFO));
- }
-
- @Test
- public void shouldImportConfigurationBugInclude() throws IOException {
- InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/findbugs-include.xml");
- List<ActiveRule> results = repository.importConfiguration(IOUtils.toString(input), buildRulesFixtureImport());
-
- assertThat(results.size(), is(4));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_1", null));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_2", null));
- assertThat(results, new ContainsActiveRule("FB1_IMPORT_TEST_3", null));
- assertThat(results, new ContainsActiveRule("FB2_IMPORT_TEST_4", null));
- }
-
- private static List<Rule> buildRulesFixtureImport() {
- Rule rule1 = new Rule("Correctness - Import test 1 group 1", "FB1_IMPORT_TEST_1",
- "FB1_IMPORT_TEST_1", null, CoreProperties.FINDBUGS_PLUGIN, null);
-
- Rule rule2 = new Rule("Multithreaded correctness - Import test 2 group 1", "FB1_IMPORT_TEST_2",
- "FB1_IMPORT_TEST_2", null, CoreProperties.FINDBUGS_PLUGIN, null);
-
- Rule rule3 = new Rule("Multithreaded correctness - Import test 3 group 1", "FB1_IMPORT_TEST_3",
- "FB1_IMPORT_TEST_3", null, CoreProperties.FINDBUGS_PLUGIN, null);
-
- Rule rule4 = new Rule("Multithreaded correctness - Import test 4 group 2", "FB2_IMPORT_TEST_4",
- "FB2_IMPORT_TEST_4", null, CoreProperties.FINDBUGS_PLUGIN, null);
-
- Rule rule5 = new Rule("Style - Import test 5 group 3", "FB3_IMPORT_TEST_5",
- "FB3_IMPORT_TEST_5", null, CoreProperties.FINDBUGS_PLUGIN, null);
-
- return Arrays.asList(rule1, rule2, rule3, rule4, rule5);
- }
-}
-
-class ContainsActiveRule extends BaseMatcher<List<ActiveRule>> {
- private String key;
- private RulePriority priority;
-
- ContainsActiveRule(String key, RulePriority priority) {
- this.key = key;
- this.priority = priority;
- }
-
- public boolean matches(Object o) {
- List<ActiveRule> rules = (List<ActiveRule>) o;
- for (ActiveRule rule : rules) {
- if (rule.getRule().getKey().equals(key)) {
- if (priority == null) {
- return true;
- }
- return rule.getPriority().equals(priority);
- }
- }
- return false;
- }
-
- public void describeTo(Description description) {
- }
-}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java
index feed2b855a9..0e74508fee9 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsSensorTest.java
@@ -38,6 +38,7 @@ import org.apache.maven.project.MavenProject;
import org.junit.Test;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.SensorContext;
+import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.DefaultProjectFileSystem;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.Project;
@@ -49,22 +50,21 @@ public class FindbugsSensorTest extends FindbugsTests {
@Test
public void shouldExecuteWhenSomeRulesAreActive() throws Exception {
- FindbugsSensor sensor = new FindbugsSensor(createRulesProfileWithActiveRules(), createRulesManager(), null);
+ FindbugsSensor sensor = new FindbugsSensor(createRulesProfileWithActiveRules(), new FindbugsRuleFinder(), null);
Project project = createProject();
assertTrue(sensor.shouldExecuteOnProject(project));
}
@Test
public void shouldNotExecuteWhenNoRulesAreActive() throws Exception {
- FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithoutActiveRules(), createRulesManager(), null);
+ FindbugsSensor analyser = new FindbugsSensor(RulesProfile.create(), new FindbugsRuleFinder(), null);
Project pom = createProject();
assertFalse(analyser.shouldExecuteOnProject(pom));
}
@Test
public void testGetMavenPluginHandlerWhenFindbugsReportPathExists() throws Exception {
- FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithoutActiveRules(), createRulesManager(),
- mock(FindbugsMavenPluginHandler.class));
+ FindbugsSensor analyser = new FindbugsSensor(RulesProfile.create(), new FindbugsRuleFinder(), mock(FindbugsMavenPluginHandler.class));
Project pom = createProject();
Configuration conf = mock(Configuration.class);
when(conf.getString(CoreProperties.FINDBUGS_REPORT_PATH)).thenReturn("pathToFindbugsReport");
@@ -74,8 +74,7 @@ public class FindbugsSensorTest extends FindbugsTests {
@Test
public void testGetFindbugsReport() {
- FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithActiveRules(), createRulesManager(),
- null);
+ FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithActiveRules(), new FindbugsRuleFinder(), null);
Project pom = createProject();
Configuration conf = mock(Configuration.class);
when(pom.getConfiguration()).thenReturn(conf);
@@ -89,7 +88,7 @@ public class FindbugsSensorTest extends FindbugsTests {
public void shouldNotExecuteOnEar() {
Project project = createProject();
when(project.getPom().getPackaging()).thenReturn("ear");
- FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithActiveRules(), createRulesManager(), null);
+ FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithActiveRules(), new FindbugsRuleFinder(), null);
assertFalse(analyser.shouldExecuteOnProject(project));
}
@@ -104,21 +103,18 @@ public class FindbugsSensorTest extends FindbugsTests {
when(project.getConfiguration()).thenReturn(conf);
when(context.getResource(any(Resource.class))).thenReturn(new JavaFile("org.sonar.MyClass"));
- FindbugsSensor analyser = new FindbugsSensor(createRulesProfileWithoutActiveRules(), createRulesManager(),
- null);
+ FindbugsSensor analyser = new FindbugsSensor(RulesProfile.create(), new FindbugsRuleFinder(), null);
analyser.analyse(project, context);
verify(context, times(3)).saveViolation(any(Violation.class));
- Violation wanted = new Violation(null, new JavaFile("org.sonar.commons.ZipUtils"))
- .setMessage("Empty zip file entry created in org.sonar.commons.ZipUtils._zip(String, File, ZipOutputStream)")
- .setLineId(107);
+ Violation wanted = new Violation(null, new JavaFile("org.sonar.commons.ZipUtils")).setMessage(
+ "Empty zip file entry created in org.sonar.commons.ZipUtils._zip(String, File, ZipOutputStream)").setLineId(107);
verify(context).saveViolation(argThat(new IsViolation(wanted)));
- wanted = new Violation(null, new JavaFile("org.sonar.commons.resources.MeasuresDao"))
- .setMessage("The class org.sonar.commons.resources.MeasuresDao$1 could be refactored into a named _static_ inner class")
- .setLineId(56);
+ wanted = new Violation(null, new JavaFile("org.sonar.commons.resources.MeasuresDao")).setMessage(
+ "The class org.sonar.commons.resources.MeasuresDao$1 could be refactored into a named _static_ inner class").setLineId(56);
verify(context).saveViolation(argThat(new IsViolation(wanted)));
}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsTests.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsTests.java
index 88afed2cdcd..e051e7c52a7 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsTests.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsTests.java
@@ -19,45 +19,44 @@
*/
package org.sonar.plugins.findbugs;
-import org.apache.commons.io.IOUtils;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.sonar.api.CoreProperties;
import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.resources.Java;
import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
+import org.sonar.api.rules.RuleQuery;
import org.sonar.api.rules.RulesManager;
import org.sonar.test.TestUtils;
import org.xml.sax.SAXException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public abstract class FindbugsTests {
protected void assertXmlAreSimilar(String actualContent, String expectedFileName) throws IOException, SAXException {
- InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/findbugs/" + expectedFileName);
- String expectedContent = IOUtils.toString(input);
+ String expectedContent = TestUtils.getResourceContent("/org/sonar/plugins/findbugs/" + expectedFileName);
TestUtils.assertSimilarXml(expectedContent, actualContent);
}
protected List<Rule> buildRulesFixture() {
List<Rule> rules = new ArrayList<Rule>();
- Rule rule1 = new Rule("DLS: Dead store to local variable", "DLS_DEAD_LOCAL_STORE",
- "DLS_DEAD_LOCAL_STORE", null, CoreProperties.FINDBUGS_PLUGIN, null);
+ Rule rule1 = new Rule("DLS: Dead store to local variable", "DLS_DEAD_LOCAL_STORE", "DLS_DEAD_LOCAL_STORE", null,
+ CoreProperties.FINDBUGS_PLUGIN, null);
- Rule rule2 = new Rule("UrF: Unread field", "URF_UNREAD_FIELD",
- "URF_UNREAD_FIELD", null, CoreProperties.FINDBUGS_PLUGIN, null);
+ Rule rule2 = new Rule("UrF: Unread field", "URF_UNREAD_FIELD", "URF_UNREAD_FIELD", null, CoreProperties.FINDBUGS_PLUGIN, null);
rules.add(rule1);
rules.add(rule2);
@@ -74,11 +73,11 @@ public abstract class FindbugsTests {
return activeRules;
}
-
protected RulesManager createRulesManager() {
RulesManager rulesManager = mock(RulesManager.class);
when(rulesManager.getPluginRule(eq(CoreProperties.FINDBUGS_PLUGIN), anyString())).thenAnswer(new Answer<Rule>() {
+
public Rule answer(InvocationOnMock invocationOnMock) throws Throwable {
Object[] args = invocationOnMock.getArguments();
Rule rule = new Rule();
@@ -91,25 +90,13 @@ public abstract class FindbugsTests {
}
protected RulesProfile createRulesProfileWithActiveRules() {
- RulesProfile rulesProfile = mock(RulesProfile.class);
- when(rulesProfile.getActiveRule(eq(CoreProperties.FINDBUGS_PLUGIN), anyString())).thenAnswer(new Answer<ActiveRule>() {
- public ActiveRule answer(InvocationOnMock invocationOnMock) throws Throwable {
- Object[] args = invocationOnMock.getArguments();
- ActiveRule activeRule = mock(ActiveRule.class);
- when(activeRule.getPluginName()).thenReturn((String) args[0]);
- when(activeRule.getRuleKey()).thenReturn((String) args[1]);
- when(activeRule.getPriority()).thenReturn(RulePriority.CRITICAL);
- return activeRule;
- }
- });
- when(rulesProfile.getActiveRulesByPlugin(CoreProperties.FINDBUGS_PLUGIN)).thenReturn(Arrays.asList(new ActiveRule()));
- return rulesProfile;
- }
-
- protected RulesProfile createRulesProfileWithoutActiveRules() {
- RulesProfile rulesProfile = new RulesProfile();
- List<ActiveRule> list = new ArrayList<ActiveRule>();
- rulesProfile.setActiveRules(list);
- return rulesProfile;
+ RulesProfile profile = RulesProfile.create();
+ profile.setName(RulesProfile.SONAR_WAY_FINDBUGS_NAME);
+ profile.setLanguage(Java.KEY);
+ for (Rule rule : new FindbugsRuleRepository().createRules()) {
+ rule.setRepositoryKey(FindbugsConstants.REPOSITORY_KEY);
+ profile.activateRule(rule, null);
+ }
+ return profile;
}
}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java
new file mode 100644
index 00000000000..0d1e3b73112
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java
@@ -0,0 +1,41 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.plugins.findbugs;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.sonar.api.profiles.RulesProfile;
+import org.sonar.api.utils.ValidationMessages;
+
+public class SonarWayWithFindbugsProfileTest {
+
+ @Test
+ public void create() {
+ FindbugsProfileImporter importer = new FindbugsProfileImporter(new FindbugsRuleFinder());
+ SonarWayWithFindbugsProfile sonarWayWithFindbugs = new SonarWayWithFindbugsProfile(importer);
+ ValidationMessages validation = ValidationMessages.create();
+ RulesProfile profile = sonarWayWithFindbugs.createProfile(validation);
+ assertThat(profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).size(), greaterThan(300));
+ assertThat(validation.hasErrors(), is(false));
+ }
+}
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/tools/RulesGenerator.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/tools/RulesGenerator.java
deleted file mode 100644
index d3701ed66cc..00000000000
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/tools/RulesGenerator.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.findbugs.tools;
-
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.staxmate.in.SMHierarchicCursor;
-import org.codehaus.staxmate.in.SMInputCursor;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulesCategory;
-import org.sonar.api.rules.StandardRulesXmlParser;
-import org.sonar.api.utils.StaxParser;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class RulesGenerator {
-
- private static final String FOR_VERSION = "1.3.8";
-
-
- private final static Map<String, String> BUG_CATEGS = new HashMap<String, String>();
-
- static {
- BUG_CATEGS.put("STYLE", "Usability");
- BUG_CATEGS.put("NOISE", "Reliability");
- BUG_CATEGS.put("CORRECTNESS", "Reliability");
- BUG_CATEGS.put("SECURITY", "Reliability");
- BUG_CATEGS.put("BAD_PRACTICE", "Maintainability");
- BUG_CATEGS.put("MT_CORRECTNESS", "Reliability");
- BUG_CATEGS.put("PERFORMANCE", "Efficiency");
- BUG_CATEGS.put("I18N", "Portability");
- BUG_CATEGS.put("MALICIOUS_CODE", "Reliability");
- }
-
- public static void main(String[] args) throws Exception {
- List<FindBugsBug> bugs = getBugsToImport();
- String generatedXML = parseMessages(bugs);
- File out = new File(".", "rules.xml");
- IOUtil.copy(generatedXML.getBytes(), new FileOutputStream(out));
- System.out.println("Written to " + out.getPath());
- }
-
- private static List<FindBugsBug> getBugsToImport() throws MalformedURLException, IOException, XMLStreamException {
- URL messages = new URL("http://findbugs.googlecode.com/svn/branches/" + FOR_VERSION + "/findbugs/etc/findbugs.xml");
- InputStream in = messages.openStream();
- final List<FindBugsBug> bugs = new ArrayList<FindBugsBug>();
- StaxParser p = new StaxParser(new StaxParser.XmlStreamHandler() {
-
- public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
- rootCursor.advance();
- SMInputCursor bugPatterns = rootCursor.descendantElementCursor("BugPattern");
- collectBugDefs(bugs, bugPatterns);
- }
-
- private void collectBugDefs(final List<FindBugsBug> bugs, SMInputCursor bugPatterns) throws XMLStreamException {
- while (bugPatterns.getNext() != null) {
- if (bugPatterns.asEvent().isEndElement()) continue;
-
- String experimental = bugPatterns.getAttrValue("experimental");
- boolean isExperimental = (StringUtils.isNotEmpty(experimental) && Boolean.valueOf(experimental)) || bugPatterns.getAttrValue("category").equals("EXPERIMENTAL");
- String deprecated = bugPatterns.getAttrValue("deprecated");
- boolean isDeprecated = StringUtils.isNotEmpty(deprecated) && Boolean.valueOf(deprecated);
- if (!isExperimental && !isDeprecated) {
- bugs.add(new FindBugsBug(bugPatterns.getAttrValue("category"), bugPatterns.getAttrValue("type")));
- }
- }
- }
- });
- p.parse(in);
- in.close();
- return bugs;
- }
-
- private static String parseMessages(final List<FindBugsBug> bugs) throws MalformedURLException, IOException, XMLStreamException {
- URL messages = new URL("http://findbugs.googlecode.com/svn/branches/" + FOR_VERSION + "/findbugs/etc/messages.xml");
-
- InputStream in = messages.openStream();
- final List<Rule> rules = new ArrayList<Rule>();
- StaxParser p = new StaxParser(new StaxParser.XmlStreamHandler() {
-
- public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
- rootCursor.advance();
- Map<String, String> bugCategoriesDecr = new HashMap<String, String>();
- SMInputCursor childrens = rootCursor.childElementCursor();
- while (childrens.getNext() != null) {
- if (childrens.asEvent().isEndElement()) continue;
- if (childrens.getLocalName().equals("BugCategory")) {
- String bugCateg = childrens.getAttrValue("category");
- bugCategoriesDecr.put(bugCateg, childrens.childElementCursor("Description").advance().collectDescendantText());
- } else if (childrens.getLocalName().equals("BugPattern")) {
- String bugType = childrens.getAttrValue("type");
- FindBugsBug bug = getFindBugsBugByType(bugType, bugs);
- if (bug == null) continue;
-
- rules.add(getRuleForBug(bugType, bug, bugCategoriesDecr, childrens));
- }
- }
- }
- });
-
- p.parse(in);
- in.close();
- StandardRulesXmlParser parser = new StandardRulesXmlParser();
- return parser.toXml(rules);
- }
-
- private static Rule getRuleForBug(String bugType, FindBugsBug bug,
- Map<String, String> bugCategoriesDecr, SMInputCursor childrens) throws XMLStreamException {
- Rule rule = new Rule();
- rule.setKey(bugType);
- rule.setConfigKey(bugType);
-
- String rulesCateg = BUG_CATEGS.get(bug.getCategory());
- if (StringUtils.isEmpty(rulesCateg)) {
- throw new RuntimeException("Rules cat not found " + bug.getCategory());
- }
- rule.setRulesCategory(new RulesCategory(rulesCateg));
-
- SMInputCursor descendents = childrens.childElementCursor();
- while (descendents.getNext() != null) {
- if (descendents.asEvent().isStartElement()) {
- if (descendents.getLocalName().equals("ShortDescription")) {
- String categName = bugCategoriesDecr.get(bug.getCategory());
- if (StringUtils.isEmpty(categName)) throw new RuntimeException("Cat not found " + bug.getCategory());
- rule.setName(categName + " - " + descendents.collectDescendantText());
- } else if (descendents.getLocalName().equals("Details")) {
- rule.setDescription(descendents.collectDescendantText());
- }
- }
- }
- return rule;
- }
-
- private static FindBugsBug getFindBugsBugByType(String type, List<FindBugsBug> bugs) {
- for (FindBugsBug findBugsBug : bugs) {
- if (findBugsBug.getType().equals(type)) {
- return findBugsBug;
- }
- }
- return null;
- }
-
- private static class FindBugsBug {
- private String category;
- private String type;
-
- public FindBugsBug(String category, String type) {
- super();
- this.category = category;
- this.type = type;
- }
-
- public String getCategory() {
- return category;
- }
-
- public String getType() {
- return type;
- }
-
- }
-
-}
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportPatterns.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportPatterns.xml
deleted file mode 100644
index 072a4b077ce..00000000000
--- a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportPatterns.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<FindBugsFilter>
- <Match>
- <Or>
- <Bug pattern="FB1_IMPORT_TEST_1"/>
- <Bug pattern="FB2_IMPORT_TEST_4"/>
- </Or>
- <Priority value="2"/>
- </Match>
-</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugs-include.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugs-include.xml
index 32e2e8f516c..9fc59110054 100644
--- a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugs-include.xml
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugs-include.xml
@@ -5,7 +5,7 @@
<Match>
<Class name="com.foobar.ClassWithSomeBugsMatched" />
- <Bug code="FB1" />
+ <Bug code="NP_CLOSING_NULL" />
<Priority value="2" />
</Match>
@@ -13,7 +13,7 @@
<Class name="com.foobar.MyClass" />
<Method name="someMethod" />
<Local name="maxArgs" />
- <Bug pattern="FB1_IMPORT_TEST_3" />
+ <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE" />
<Priority value="1" />
</Match>
@@ -30,7 +30,7 @@
<Method name="frob" params="int,java.lang.String" returns="void" />
<Method name="blat" params="" returns="boolean" />
</Or>
- <Bug category="MT_CORRECTNESS" />
+ <Bug category="SECURITY" />
<Priority value="3" />
</Match>
</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml
new file mode 100644
index 00000000000..33115c28621
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCategory.xml
@@ -0,0 +1,6 @@
+<FindBugsFilter>
+ <Match>
+ <Bug category="CORRECTNESS,MT_CORRECTN9876976" />
+ <Priority value="3"/>
+ </Match>
+</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml
new file mode 100644
index 00000000000..874d9c570aa
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownCode.xml
@@ -0,0 +1,6 @@
+<FindBugsFilter>
+ <Match>
+ <Bug code="BC,EC87LK"/>
+ <Priority value="2"/>
+ </Match>
+</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml
new file mode 100644
index 00000000000..4e542bbcba7
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/findbugsXmlWithUnknownRule.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FindBugsFilter>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE" />
+ </Match>
+ <Match>
+ <Bug pattern="UNKNOWN" />
+ </Match>
+</FindBugsFilter>
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCategories.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportCategories.xml
index 5f4ae48efa2..5f4ae48efa2 100644
--- a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCategories.xml
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportCategories.xml
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCodes.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportCodes.xml
index 0da831362e5..f079f7dabbd 100644
--- a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/FindbugsRulesRepositoryTest/shouldImportCodes.xml
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportCodes.xml
@@ -1,6 +1,6 @@
<FindBugsFilter>
<Match>
- <Bug code="FB1,FB3"/>
+ <Bug code="BC,EC"/>
<Priority value="2"/>
</Match>
</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml
new file mode 100644
index 00000000000..b454f431b93
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/shouldImportPatterns.xml
@@ -0,0 +1,9 @@
+<FindBugsFilter>
+ <Match>
+ <Or>
+ <Bug pattern="NP_CLOSING_NULL"/>
+ <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE"/>
+ </Or>
+ <Priority value="2"/>
+ </Match>
+</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/uncorrectFindbugsXml.xml b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/uncorrectFindbugsXml.xml
new file mode 100644
index 00000000000..23b9b37a5d2
--- /dev/null
+++ b/plugins/sonar-findbugs-plugin/src/test/resources/org/sonar/plugins/findbugs/uncorrectFindbugsXml.xml
@@ -0,0 +1,5 @@
+<BugCollection timestamp='1282919233000' analysisTimestamp='1282919402891' sequence='0' release='' version='1.3.9'>
+ <Project projectName=''>
+ <Jar>/Users/freddy/Documents/sonar_projects/sonar/sonar-commons/target/classes</Jar>
+ <AuxClasspathEntry>/Users/freddy/.m2/repository/org/apache/maven/reporting/maven-reporting-impl/2.0/maven-reporting-impl-2.0.jar</AuxClasspathEntry>
+ \ No newline at end of file