From: Evgeny Mandrikov Date: Thu, 22 Mar 2012 18:33:41 +0000 (+0400) Subject: Fix some quality flaws X-Git-Tag: 3.0~142 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=be160292022b9fa5ec33224f32fc12db78aeb79b;p=sonarqube.git Fix some quality flaws --- 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 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 properties = processProps(moduleCursor); Rule rule;