From 45ae7835e43c8ac6f676a5a50eb164d7a8a4e9d5 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 20 Jun 2017 13:52:28 +0200 Subject: [PATCH] Fix Quality flaws --- .../org/sonar/api/batch/debt/DebtRemediationFunction.java | 4 ++-- .../org/sonar/api/batch/sensor/coverage/CoverageType.java | 6 +++--- .../src/main/java/org/sonar/api/rule/Severity.java | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtRemediationFunction.java index 602d8ebeb1a..44917519e72 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtRemediationFunction.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/DebtRemediationFunction.java @@ -85,10 +85,10 @@ public class DebtRemediationFunction { if (type != that.type) { return false; } - if (coefficient != null ? !coefficient.equals(that.coefficient) : that.coefficient != null) { + if ((coefficient != null) ? !coefficient.equals(that.coefficient) : (that.coefficient != null)) { return false; } - return offset != null ? offset.equals(that.offset) : that.offset == null; + return (offset != null) ? offset.equals(that.offset) : (that.offset == null); } @Override diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java index b0f397623fc..c3ef537cac2 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/coverage/CoverageType.java @@ -19,12 +19,12 @@ */ package org.sonar.api.batch.sensor.coverage; -import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; import org.sonar.api.measures.Metric; +import static java.util.Arrays.asList; import static org.sonar.api.measures.CoreMetrics.CONDITIONS_BY_LINE; import static org.sonar.api.measures.CoreMetrics.CONDITIONS_TO_COVER; import static org.sonar.api.measures.CoreMetrics.COVERAGE_LINE_HITS_DATA; @@ -79,8 +79,8 @@ public enum CoverageType { this.uncoveredConditions = uncoveredConditions; this.coveredConditionsByLine = coveredConditionsByLine; this.conditionsByLine = conditionsByLine; - this.all = Collections - .unmodifiableSet(new LinkedHashSet<>(Arrays.asList(linesToCover, uncoveredLines, lineHitsData, conditionsToCover, uncoveredConditions, coveredConditionsByLine, conditionsByLine))); + this.all = Collections.unmodifiableSet(new LinkedHashSet<>( + asList(linesToCover, uncoveredLines, lineHitsData, conditionsToCover, uncoveredConditions, coveredConditionsByLine, conditionsByLine))); } public Set allMetrics() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rule/Severity.java b/sonar-plugin-api/src/main/java/org/sonar/api/rule/Severity.java index 385b3a2b32e..8faf14504fa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rule/Severity.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rule/Severity.java @@ -22,6 +22,7 @@ package org.sonar.api.rule; import java.util.List; import static java.util.Arrays.asList; +import static java.util.Collections.unmodifiableList; /** * @since 3.6 @@ -37,7 +38,7 @@ public final class Severity { /** * All the supported severity values, ordered from {@link #INFO} to {@link #BLOCKER}. */ - public static final List ALL = asList(INFO, MINOR, MAJOR, CRITICAL, BLOCKER); + public static final List ALL = unmodifiableList(asList(INFO, MINOR, MAJOR, CRITICAL, BLOCKER)); private Severity() { // utility -- 2.39.5