diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-27 21:26:17 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-27 21:26:17 +0200 |
commit | 2b560c35ab24a4f7db27d7e180a64e830b9a56a1 (patch) | |
tree | 59318ddf4d2e78688a7fa2ced83b37f921f6eac8 /plugins | |
parent | 9559e69e14d6123c3e03335e7d9b416cbac5e576 (diff) | |
download | sonarqube-2b560c35ab24a4f7db27d7e180a64e830b9a56a1.tar.gz sonarqube-2b560c35ab24a4f7db27d7e180a64e830b9a56a1.zip |
fix coding violations
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdAnalyser.java | 19 | ||||
-rw-r--r-- | plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java | 29 |
2 files changed, 11 insertions, 37 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdAnalyser.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdAnalyser.java index a185eed64af..4214a736039 100644 --- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdAnalyser.java +++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdAnalyser.java @@ -19,17 +19,7 @@ */ package org.sonar.plugins.cpd; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - import net.sourceforge.pmd.cpd.TokenEntry; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.CpdMapping; @@ -40,6 +30,9 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.duplications.cpd.Match; +import java.io.File; +import java.util.*; + public class CpdAnalyser { private static final Logger LOG = LoggerFactory.getLogger(CpdAnalyser.class); @@ -84,7 +77,7 @@ public class CpdAnalyser { continue; } - firstFileData.cumulate(secondFile, secondLine, firstLine, match.getLineCount(), match); + firstFileData.cumulate(secondFile, secondLine, firstLine, match.getLineCount()); } } } @@ -116,8 +109,7 @@ public class CpdAnalyser { this.resource = resource; } - protected void cumulate(Resource targetResource, int targetDuplicationStartLine, int duplicationStartLine, int duplicatedLines, - Match match) { + protected void cumulate(Resource targetResource, int targetDuplicationStartLine, int duplicationStartLine, int duplicatedLines) { StringBuilder xml = new StringBuilder(); xml.append("<duplication lines=\"").append(duplicatedLines).append("\" start=\"").append(duplicationStartLine) .append("\" target-start=\"").append(targetDuplicationStartLine).append("\" target-resource=\"") @@ -125,7 +117,6 @@ public class CpdAnalyser { duplicationXMLEntries.add(xml); - int duplicatedLinesBefore = this.duplicatedLines.size(); for (int duplicatedLine = duplicationStartLine; duplicatedLine < duplicationStartLine + duplicatedLines; duplicatedLine++) { this.duplicatedLines.add(duplicatedLine); } diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java index 1103d9fccb4..e1552a340f7 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdExecutor.java @@ -19,27 +19,10 @@ */ package org.sonar.plugins.pmd; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.List; - -import net.sourceforge.pmd.PMD; -import net.sourceforge.pmd.PMDException; -import net.sourceforge.pmd.Report; -import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.RuleSetFactory; -import net.sourceforge.pmd.RuleSets; -import net.sourceforge.pmd.SourceType; +import net.sourceforge.pmd.*; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.XMLRenderer; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -50,6 +33,9 @@ import org.sonar.api.resources.Project; import org.sonar.api.utils.TimeProfiler; import org.sonar.java.api.JavaUtils; +import java.io.*; +import java.util.List; + public class PmdExecutor implements BatchExtension { private static final Logger LOG = LoggerFactory.getLogger(PmdExecutor.class); @@ -147,13 +133,10 @@ public class PmdExecutor implements BatchExtension { xmlRenderer.start(); xmlRenderer.renderFileReport(report); xmlRenderer.end(); - String buffer = stringwriter.toString(); File xmlReport = new File(project.getFileSystem().getSonarWorkingDirectory(), "pmd-result.xml"); LOG.info("PMD output report: " + xmlReport.getAbsolutePath()); - Writer writer = new FileWriter(xmlReport); - writer.write(buffer, 0, buffer.length()); - writer.close(); + FileUtils.write(xmlReport, stringwriter.toString()); return xmlReport; } |