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;
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);
}
public List<File> getSourceFiles() {
- return fileSystem.getSourceFiles(Java.INSTANCE);
+ return InputFileUtils.toFiles(fileSystem.mainFiles(Java.KEY));
}
public File getTargetXMLReport() {
*/
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;
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";
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);
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;