diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-03-22 22:33:41 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-03-22 22:43:20 +0400 |
commit | be160292022b9fa5ec33224f32fc12db78aeb79b (patch) | |
tree | af91660030a17041fab493c3f06e24f23f532a4d /plugins/sonar-checkstyle-plugin | |
parent | d6c9a3e77a55542e09e68c6bc60096aa4385fb12 (diff) | |
download | sonarqube-be160292022b9fa5ec33224f32fc12db78aeb79b.tar.gz sonarqube-be160292022b9fa5ec33224f32fc12db78aeb79b.zip |
Fix some quality flaws
Diffstat (limited to 'plugins/sonar-checkstyle-plugin')
2 files changed, 20 insertions, 18 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java index fb5790879ee..49e48a220a5 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java @@ -32,6 +32,7 @@ import org.sonar.api.CoreProperties; import org.sonar.api.Property; import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; +import org.sonar.api.resources.InputFileUtils; import org.sonar.api.resources.Java; import org.sonar.api.resources.ProjectFileSystem; import org.sonar.api.utils.SonarException; @@ -43,10 +44,13 @@ import java.util.Locale; import java.util.Properties; @org.sonar.api.Properties({ - @Property(key = CheckstyleConfiguration.PROPERTY_GENERATE_XML, - defaultValue = "false", - name = "Generate XML Report", - project = false, global = false)}) + @Property( + key = CheckstyleConfiguration.PROPERTY_GENERATE_XML, + defaultValue = "false", + name = "Generate XML Report", + project = false, global = false + ) +}) public class CheckstyleConfiguration implements BatchExtension { private static final Logger LOG = LoggerFactory.getLogger(CheckstyleConfiguration.class); @@ -82,7 +86,7 @@ public class CheckstyleConfiguration implements BatchExtension { } public List<File> getSourceFiles() { - return fileSystem.getSourceFiles(Java.INSTANCE); + return InputFileUtils.toFiles(fileSystem.mainFiles(Java.KEY)); } public File getTargetXMLReport() { diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java index 7156cb5957b..1d4a5b7887b 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java @@ -19,12 +19,6 @@ */ package org.sonar.plugins.checkstyle; -import java.io.Reader; -import java.util.Map; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; - import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.codehaus.stax2.XMLInputFactory2; @@ -40,6 +34,12 @@ import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RuleQuery; import org.sonar.api.utils.ValidationMessages; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; + +import java.io.Reader; +import java.util.Map; + public class CheckstyleProfileImporter extends ProfileImporter { private static final String CHECKER_MODULE = "Checker"; @@ -87,8 +87,7 @@ public class CheckstyleProfileImporter extends ProfileImporter { return new SMInputFactory(xmlFactory); } - private void processModule(RulesProfile profile, String path, SMInputCursor moduleCursor, ValidationMessages messages) - throws XMLStreamException { + private void processModule(RulesProfile profile, String path, SMInputCursor moduleCursor, ValidationMessages messages) throws XMLStreamException { String moduleName = moduleCursor.getAttrValue("name"); if (isFilter(moduleName)) { messages.addWarningText("Checkstyle filters are not imported: " + moduleName); @@ -104,13 +103,12 @@ public class CheckstyleProfileImporter extends ProfileImporter { static boolean isFilter(String configKey) { return StringUtils.equals(configKey, "SuppressionCommentFilter") || - StringUtils.equals(configKey, "SeverityMatchFilter") || - StringUtils.equals(configKey, "SuppressionFilter") || - StringUtils.equals(configKey, "SuppressWithNearbyCommentFilter"); + StringUtils.equals(configKey, "SeverityMatchFilter") || + StringUtils.equals(configKey, "SuppressionFilter") || + StringUtils.equals(configKey, "SuppressWithNearbyCommentFilter"); } - private void processRule(RulesProfile profile, String path, String moduleName, SMInputCursor moduleCursor, ValidationMessages messages) - throws XMLStreamException { + private void processRule(RulesProfile profile, String path, String moduleName, SMInputCursor moduleCursor, ValidationMessages messages) throws XMLStreamException { Map<String, String> properties = processProps(moduleCursor); Rule rule; |