diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-03-16 17:15:30 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-03-16 17:25:16 +0100 |
commit | 1b09113d16a93c516b03c896202c71205d46134a (patch) | |
tree | 7695ebbcbc01a5ed1ff9e4cd32bfe0523837242e /sonar-batch | |
parent | 887cda2d00ba7b62ee311bc78a4ea611696e9761 (diff) | |
download | sonarqube-1b09113d16a93c516b03c896202c71205d46134a.tar.gz sonarqube-1b09113d16a93c516b03c896202c71205d46134a.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-batch')
6 files changed, 32 insertions, 35 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java index e2f074bc085..cfebad6cbb5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java @@ -202,7 +202,7 @@ public class BatchExtensionDictionnary { return results; } - private void evaluateClass(Class extensionClass, Class annotationClass, List<Object> results) { + private static void evaluateClass(Class extensionClass, Class annotationClass, List<Object> results) { Annotation annotation = extensionClass.getAnnotation(annotationClass); if (annotation != null) { if (annotation.annotationType().isAssignableFrom(DependsUpon.class)) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java index 330750e5411..5b13f1d4ee1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhaseProfiling.java @@ -87,7 +87,7 @@ public class PhaseProfiling extends AbstractTimeProfiling { * @param o * @return */ - private String toStringOrSimpleName(Object o) { + private static String toStringOrSimpleName(Object o) { String toString = o.toString(); if (toString == null || toString.startsWith(o.getClass().getName())) { return o.getClass().getSimpleName(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/ConsoleReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/ConsoleReport.java index eb8e31f18bc..7e37b789c71 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/ConsoleReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/ConsoleReport.java @@ -19,8 +19,6 @@ */ package org.sonar.batch.scan.report; -import org.sonar.batch.issue.tracking.TrackedIssue; - import com.google.common.annotations.VisibleForTesting; import org.apache.commons.lang.StringUtils; import org.sonar.api.Properties; @@ -31,11 +29,12 @@ import org.sonar.api.rule.Severity; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.batch.issue.IssueCache; +import org.sonar.batch.issue.tracking.TrackedIssue; import org.sonar.batch.scan.filesystem.InputPathCache; @Properties({ - @Property(key = ConsoleReport.CONSOLE_REPORT_ENABLED_KEY, name = "Enable console report", description = "Set this to true to generate a report in console output", - type = PropertyType.BOOLEAN, defaultValue = "false")}) + @Property(key = ConsoleReport.CONSOLE_REPORT_ENABLED_KEY, defaultValue = "false", name = "Enable console report", + description = "Set this to true to generate a report in console output", type = PropertyType.BOOLEAN)}) public class ConsoleReport implements Reporter { @VisibleForTesting @@ -122,7 +121,7 @@ public class ConsoleReport implements Reporter { LOG.info(sb.toString()); } - private void printNewIssues(Report r, StringBuilder sb) { + private static void printNewIssues(Report r, StringBuilder sb) { int newIssues = r.totalNewIssues; if (newIssues > 0) { sb.append(StringUtils.leftPad("+" + newIssues, LEFT_PAD)).append(" issue" + (newIssues > 1 ? "s" : "")).append("\n\n"); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/HtmlReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/HtmlReport.java index 369ba2b5e91..8111abd467e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/HtmlReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/HtmlReport.java @@ -21,16 +21,6 @@ package org.sonar.batch.scan.report; import com.google.common.collect.Maps; import freemarker.template.Template; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.api.Properties; -import org.sonar.api.Property; -import org.sonar.api.PropertyType; -import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.config.Settings; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -40,19 +30,26 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.net.URISyntaxException; import java.util.Map; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.PropertyType; +import org.sonar.api.batch.fs.FileSystem; +import org.sonar.api.config.Settings; @Properties({ - @Property(key = HtmlReport.HTML_REPORT_ENABLED_KEY, name = "Enable HTML report", description = "Set this to true to generate an HTML report", - type = PropertyType.BOOLEAN, defaultValue = "false"), - @Property(key = HtmlReport.HTML_REPORT_LOCATION_KEY, name = "HTML Report location", - description = "Location of the generated report. Can be absolute or relative to working directory", - type = PropertyType.STRING, defaultValue = HtmlReport.HTML_REPORT_LOCATION_DEFAULT, global = false, project = false), - @Property(key = HtmlReport.HTML_REPORT_NAME_KEY, name = "HTML Report name", - description = "Name of the generated report. Will be suffixed by .html or -light.html", - type = PropertyType.STRING, defaultValue = HtmlReport.HTML_REPORT_NAME_DEFAULT, global = false, project = false), - @Property(key = HtmlReport.HTML_REPORT_LIGHTMODE_ONLY, name = "Html report in light mode only", project = true, - description = "Set this to true to only generate the new issues report (light report)", - type = PropertyType.BOOLEAN, defaultValue = "false")}) + @Property(key = HtmlReport.HTML_REPORT_ENABLED_KEY, defaultValue = "false", name = "Enable HTML report", description = "Set this to true to generate an HTML report", + type = PropertyType.BOOLEAN), + @Property(key = HtmlReport.HTML_REPORT_LOCATION_KEY, defaultValue = HtmlReport.HTML_REPORT_LOCATION_DEFAULT, name = "HTML Report location", + description = "Location of the generated report. Can be absolute or relative to working directory", project = false, global = false, type = PropertyType.STRING), + @Property(key = HtmlReport.HTML_REPORT_NAME_KEY, defaultValue = HtmlReport.HTML_REPORT_NAME_DEFAULT, name = "HTML Report name", + description = "Name of the generated report. Will be suffixed by .html or -light.html", project = false, global = false, type = PropertyType.STRING), + @Property(key = HtmlReport.HTML_REPORT_LIGHTMODE_ONLY, defaultValue = "false", name = "Html report in light mode only", + description = "Set this to true to only generate the new issues report (light report)", project = true, type = PropertyType.BOOLEAN)}) public class HtmlReport implements Reporter { private static final Logger LOG = LoggerFactory.getLogger(HtmlReport.class); @@ -111,7 +108,7 @@ public class HtmlReport implements Reporter { if (!reportFileDir.isAbsolute()) { reportFileDir = new File(fs.workDir(), reportFileDirStr); } - if (reportFileDirStr.endsWith(".html")) { + if (StringUtils.endsWith(reportFileDirStr, ".html")) { LOG.warn(HTML_REPORT_LOCATION_KEY + " should indicate a directory. Using parent folder."); reportFileDir = reportFileDir.getParentFile(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java index 20be830f8aa..f6a88bf4465 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java @@ -22,6 +22,7 @@ package org.sonar.batch.scm; import com.google.common.base.Joiner; import java.util.LinkedHashMap; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.picocontainer.Startable; import org.sonar.api.CoreProperties; import org.sonar.api.Properties; @@ -40,13 +41,13 @@ import org.sonar.batch.scan.ImmutableProjectReactor; @Property( key = ScmConfiguration.FORCE_RELOAD_KEY, defaultValue = "false", - type = PropertyType.BOOLEAN, name = "Force reloading of SCM information for all files", description = "By default only files modified since previous analysis are inspected. Set this parameter to true to force the reloading.", - module = false, + category = CoreProperties.CATEGORY_SCM, project = false, + module = false, global = false, - category = CoreProperties.CATEGORY_SCM) + type = PropertyType.BOOLEAN) }) @InstantiationStrategy(InstantiationStrategy.PER_BATCH) @BatchSide @@ -103,7 +104,7 @@ public final class ScmConfiguration implements Startable { if (providerPerKey.containsKey(forcedProviderKey)) { this.provider = providerPerKey.get(forcedProviderKey); } else { - String supportedProviders = providerPerKey.isEmpty() ? "No SCM provider installed" : "Supported SCM providers are " + Joiner.on(",").join(providerPerKey.keySet()); + String supportedProviders = providerPerKey.isEmpty() ? "No SCM provider installed" : ("Supported SCM providers are " + Joiner.on(",").join(providerPerKey.keySet())); throw new IllegalArgumentException("SCM provider was set to \"" + forcedProviderKey + "\" but no SCM provider found for this key. " + supportedProviders); } } @@ -111,7 +112,7 @@ public final class ScmConfiguration implements Startable { private void considerOldScmUrl() { if (settings.hasKey(CoreProperties.LINKS_SOURCES_DEV)) { String url = settings.getString(CoreProperties.LINKS_SOURCES_DEV); - if (url.startsWith("scm:")) { + if (StringUtils.startsWith(url, "scm:")) { String[] split = url.split(":"); if (split.length > 1) { setProviderIfSupported(split[1]); diff --git a/sonar-batch/src/main/java/org/sonar/batch/util/ProgressReport.java b/sonar-batch/src/main/java/org/sonar/batch/util/ProgressReport.java index f6fb4cf1752..f2ea0406a01 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/util/ProgressReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/util/ProgressReport.java @@ -69,7 +69,7 @@ public class ProgressReport implements Runnable { } } - private void log(String message) { + private static void log(String message) { synchronized (LOG) { LOG.info(message); LOG.notifyAll(); |