diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-07-31 10:30:54 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-08-01 10:43:03 +0200 |
commit | c2b40be7f722bfd9c96c0639f4650bca60c859f8 (patch) | |
tree | d34336b5a13fd1084769638a12fa6220065b0cd7 | |
parent | 102fcaa285b796f70f1c422267360118dec3dd05 (diff) | |
download | sonarqube-c2b40be7f722bfd9c96c0639f4650bca60c859f8.tar.gz sonarqube-c2b40be7f722bfd9c96c0639f4650bca60c859f8.zip |
Fix minor quality flaws
13 files changed, 27 insertions, 48 deletions
diff --git a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java index 1b7f96a5eaf..f1e532514ea 100644 --- a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java +++ b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java @@ -105,11 +105,9 @@ public class DefaultMavenPluginExecutor implements MavenPluginExecutor { } if (executeMethod.getParameterTypes().length == 1) { concreteExecuteMaven3(pom, goal); - } - else if (executeMethod.getParameterTypes().length == 3) { + } else if (executeMethod.getParameterTypes().length == 3) { concreteExecuteMaven2(executeMethod, pom, goal); - } - else { + } else { throw new SonarException("Unexpected parameter count on Maven LifecycleExecutor#execute method. Please check your Maven version."); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java index fc258b1da3c..755d2a46b97 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java @@ -78,8 +78,7 @@ public class BatchPluginRepository implements PluginRepository { PluginMetadata metadata = extractor.install(pluginFiles.get(0), remote.isCore(), extensionFiles, targetDir); if (StringUtils.isBlank(metadata.getBasePlugin()) || filter.accepts(metadata.getBasePlugin())) { metadataByKey.put(metadata.getKey(), metadata); - } - else { + } else { LOG.debug("Excluded plugin: " + metadata.getKey()); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java index 0f87fd7990b..97ffaf0d62f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java @@ -58,8 +58,7 @@ public final class LoggingConfiguration { setShowSql(false); if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) { setFormat(FORMAT_MAVEN); - } - else { + } else { setFormat(FORMAT_DEFAULT); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java index 81810cd00c3..566cc98a3c8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java @@ -92,9 +92,7 @@ public abstract class AbstractTimeProfiling { if (i++ >= maxSize || item.totalTime() == 0) { return result; } - else { - result.add(item); - } + result.add(item); } return result; } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java index 6c99ca65fd4..6b9f37291c0 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java @@ -41,8 +41,7 @@ public class HtmlCodeBuilder implements Appendable { colorizedCode.append(">"); } else if (c == '&') { colorizedCode.append("&"); - } - else { + } else { colorizedCode.append(c); } return this; diff --git a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterCondition.java b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterCondition.java index bbf2c7ed869..809827da517 100644 --- a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterCondition.java +++ b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterCondition.java @@ -115,8 +115,7 @@ public class MeasureFilterCondition { sql.append(" ").append(operator.getSql()).append(" "); if (textValue == null) { sql.append(value); - } - else { + } else { sql.append(textValue); } sql.append(" AND "); diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java index 218f0b48fd7..b0954a836f8 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeProfiler.java @@ -90,9 +90,8 @@ public class PurgeProfiler { for (Entry<String, Long> item : sortedFullList) { if (i++ >= maxSize || item.getValue() == 0) { return result; - } else { - result.add(item); } + result.add(item); } return result; } diff --git a/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java b/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java index 2d3feee9042..578879645ab 100644 --- a/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java +++ b/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java @@ -73,8 +73,7 @@ public class MinimumFeedbackEdgeSetSolver { Set<FeedbackEdge> pendingFeedbackEdges = new HashSet<FeedbackEdge>(); if (cyclesNumber < maxNumberCyclesForSearchingMinimumFeedback) { searchFeedbackEdges(0, 0, pendingFeedbackEdges); - } - else { + } else { lightResearchForFeedbackEdges(); } } @@ -112,15 +111,13 @@ public class MinimumFeedbackEdgeSetSolver { if (doesFeedbackEdgesContainAnEdgeOfTheCycle(pendingFeedbackEdges, feedbackCycle)) { searchFeedbackEdges(level + 1, pendingWeight, pendingFeedbackEdges); - } - else { + } else { boolean hasAnEdgeWithOccurrenceOfOneBeenUsed = false; for (FeedbackEdge feedbackEdge : feedbackCycle) { if (feedbackEdge.getOccurences() == 1) { if (hasAnEdgeWithOccurrenceOfOneBeenUsed) { continue; - } - else { + } else { hasAnEdgeWithOccurrenceOfOneBeenUsed = true; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java index b20c575916d..289c7f9ee46 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/SumChildDistributionFormula.java @@ -52,16 +52,14 @@ public class SumChildDistributionFormula implements Formula { if (measures == null || measures.isEmpty()) { return null; } - else { - RangeDistributionBuilder distribution = new RangeDistributionBuilder(context.getTargetMetric()); - for (Measure measure : measures) { - distribution.add(measure); - } - Measure measure = distribution.build(); - if (!Scopes.isHigherThanOrEquals(context.getResource().getScope(), minimumScopeToPersist)) { - measure.setPersistenceMode(PersistenceMode.MEMORY); - } - return measure; + RangeDistributionBuilder distribution = new RangeDistributionBuilder(context.getTargetMetric()); + for (Measure measure : measures) { + distribution.add(measure); } + Measure measure = distribution.build(); + if (!Scopes.isHigherThanOrEquals(context.getResource().getScope(), minimumScopeToPersist)) { + measure.setPersistenceMode(PersistenceMode.MEMORY); + } + return measure; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java index deaf6d1fed0..00fa4c82678 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java @@ -265,9 +265,8 @@ public class HttpDownloader extends UriReader.SchemeProcessor implements BatchCo String errorResponseContent = IOUtils.toString(errorResponse); throw new HttpException(uri, responseCode, errorResponseContent); } - else { - throw new HttpException(uri, responseCode); - } + throw new HttpException(uri, responseCode); + } finally { IOUtils.closeQuietly(errorResponse); } diff --git a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java index 32d7a60ed66..e85e0fdd66b 100644 --- a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java +++ b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BaseChartWeb.java @@ -100,8 +100,7 @@ public abstract class BaseChartWeb extends BaseChart { } else { configureDefaultColors(renderer); } - } - catch (Exception e) { + } catch (Exception e) { configureDefaultColors(renderer); } } @@ -117,8 +116,7 @@ public abstract class BaseChartWeb extends BaseChart { if (isParamValueValid(paramValue)) { try { result = Double.parseDouble(paramValue); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // ignore } } @@ -144,8 +142,7 @@ public abstract class BaseChartWeb extends BaseChart { setWidth(iWidth); setHeight(iHeight); } - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // Do nothing, default dimensions are already setted } } diff --git a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java index a9b4ae95345..7f0fcbafba0 100644 --- a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java +++ b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java @@ -85,8 +85,7 @@ public class PieChart extends BaseChartWeb implements DeprecatedChart { } else { configureDefaultColors(); } - } - catch (Exception e) { + } catch (Exception e) { configureDefaultColors(); } } @@ -117,8 +116,7 @@ public class PieChart extends BaseChartWeb implements DeprecatedChart { double measure = 0; try { measure = Double.parseDouble(st.nextToken()); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // ignore } dataset.setValue(Integer.toString(i), measure); diff --git a/sonar-server/src/main/java/org/sonar/server/user/UserSession.java b/sonar-server/src/main/java/org/sonar/server/user/UserSession.java index 6f153d7c302..3ca82006a7d 100644 --- a/sonar-server/src/main/java/org/sonar/server/user/UserSession.java +++ b/sonar-server/src/main/java/org/sonar/server/user/UserSession.java @@ -117,8 +117,7 @@ public class UserSession { Permission perm = Permission.allGlobal().get(permissionKey); if (perm == null) { LOG.warn("Ignoring unknown permission {} for user {}", permissionKey, login); - } - else { + } else { permissions.add(perm); } } |