diff options
20 files changed, 40 insertions, 45 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java b/server/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java index 5dd3e7092a7..8d935cb5f32 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/ChartFactory.java @@ -20,15 +20,13 @@ package org.sonar.server.charts; import com.google.common.collect.Maps; -import org.sonar.api.server.ServerSide; +import java.util.Map; +import javax.annotation.CheckForNull; import org.sonar.api.charts.Chart; +import org.sonar.api.server.ServerSide; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import javax.annotation.CheckForNull; - -import java.util.Map; - @ServerSide public final class ChartFactory { private static final Logger LOG = Loggers.get(ChartFactory.class); diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java index 31e02d1df36..10e2fc1b944 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionAreaChart.java @@ -19,6 +19,7 @@ */ package org.sonar.server.charts; +import java.text.NumberFormat; import org.apache.commons.lang.StringUtils; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; @@ -29,8 +30,6 @@ import org.jfree.data.category.DefaultCategoryDataset; import org.sonar.api.charts.AbstractChart; import org.sonar.api.charts.ChartParameters; -import java.text.NumberFormat; - public class DistributionAreaChart extends AbstractChart { private static final String PARAM_COLORS = "c"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java index 80cfb64d927..397a25b01e8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/DistributionBarChart.java @@ -19,6 +19,8 @@ */ package org.sonar.server.charts; +import java.awt.Font; +import java.text.DecimalFormat; import org.apache.commons.lang.StringUtils; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; @@ -29,12 +31,8 @@ import org.jfree.data.category.DefaultCategoryDataset; import org.sonar.api.charts.AbstractChart; import org.sonar.api.charts.ChartParameters; -import java.awt.*; -import java.text.DecimalFormat; - public class DistributionBarChart extends AbstractChart { - public static final String PARAM_VALUES = "v"; public static final String PARAM_COLORS = "c"; public static final String PARAM_Y_SUFFIX = "ysuf"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java index ef1c05e9449..064df390a3c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java @@ -19,7 +19,8 @@ */ package org.sonar.server.charts.deprecated; -import java.awt.*; +import java.awt.Color; +import java.awt.Paint; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.Map; diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarRenderer.java b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarRenderer.java index 2ebb50d3479..c5cab5c4305 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarRenderer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarRenderer.java @@ -19,7 +19,8 @@ */ package org.sonar.server.charts.deprecated; -import java.awt.*; +import java.awt.Color; +import java.awt.Paint; import org.jfree.chart.renderer.category.BarRenderer; public class CustomBarRenderer extends BarRenderer { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java index df1b03047a5..0fc25e9e58b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityGateEventsStep.java @@ -97,7 +97,7 @@ public class QualityGateEventsStep implements ComputationStep { // The QualityGate status has changed String label = String.format("%s (was %s)", rawStatus.getStatus().getColorName(), baseStatus.getStatus().getColorName()); createEvent(project, label, rawStatus.getText()); - boolean isNewKo = (rawStatus.getStatus() == Measure.Level.OK); + boolean isNewKo = rawStatus.getStatus() == Measure.Level.OK; notifyUsers(project, label, rawStatus, isNewKo); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java index 479f5b20afa..6a973bcb979 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v36/ViolationConverter.java @@ -194,7 +194,7 @@ class ViolationConverter implements Callable<Object> { } else { // violation + review String reviewStatus = (String) row.get(REVIEW_STATUS); - status = (STATUS_OPEN.equals(reviewStatus) ? STATUS_CONFIRMED : reviewStatus); + status = STATUS_OPEN.equals(reviewStatus) ? STATUS_CONFIRMED : reviewStatus; manualSeverity = Objects.firstNonNull((Boolean) row.get(REVIEW_MANUAL_SEVERITY), false); severity = (String) row.get(REVIEW_SEVERITY); updatedAt = Objects.firstNonNull(row.get(REVIEW_UPDATED_AT), ONE_YEAR_AGO); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java b/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java index cf7bd8bfd7d..c8f42483795 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/Result.java @@ -129,7 +129,7 @@ public class Result<T> { } Message message = (Message) o; - if (l10nKey != null ? !l10nKey.equals(message.l10nKey) : message.l10nKey != null) { + if ((l10nKey != null) ? !l10nKey.equals(message.l10nKey) : (message.l10nKey != null)) { return false; } // Probably incorrect - comparing Object[] arrays with Arrays.equals diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java index 5965b32a07b..8d79cbdd4d3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueAuthorizationIndexer.java @@ -100,10 +100,9 @@ public class IssueAuthorizationIndexer extends BaseIndexer { IssueIndexDefinition.FIELD_AUTHORIZATION_GROUPS, dto.getGroups(), IssueIndexDefinition.FIELD_AUTHORIZATION_USERS, dto.getUsers(), IssueIndexDefinition.FIELD_AUTHORIZATION_UPDATED_AT, new Date(dto.getUpdatedAt())); - ActionRequest<?> request = new UpdateRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_AUTHORIZATION, dto.getProjectUuid()) + return new UpdateRequest(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_AUTHORIZATION, dto.getProjectUuid()) .routing(dto.getProjectUuid()) .doc(doc) .upsert(doc); - return request; } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcher.java b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcher.java index 1ee261ea214..0197166d2f4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcher.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcher.java @@ -22,11 +22,11 @@ package org.sonar.server.issue.notification; import com.google.common.base.Objects; import com.google.common.collect.Multimap; -import org.sonar.api.issue.Issue; -import org.sonar.api.notifications.*; - import java.util.Collection; import java.util.Map; +import org.sonar.api.issue.Issue; +import org.sonar.api.notifications.Notification; +import org.sonar.api.notifications.NotificationChannel; import org.sonar.server.notification.NotificationDispatcher; import org.sonar.server.notification.NotificationDispatcherMetadata; import org.sonar.server.notification.NotificationManager; diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/OpeningHtmlTag.java b/server/sonar-server/src/main/java/org/sonar/server/source/OpeningHtmlTag.java index 980bfbb1f11..a4cd64e70b5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/source/OpeningHtmlTag.java +++ b/server/sonar-server/src/main/java/org/sonar/server/source/OpeningHtmlTag.java @@ -59,7 +59,7 @@ class OpeningHtmlTag { if (startOffset != otherTag.startOffset) { return false; } - if (cssClass != null ? !cssClass.equals(otherTag.cssClass) : otherTag.cssClass != null) { + if ((cssClass != null) ? !cssClass.equals(otherTag.cssClass) : (otherTag.cssClass != null)) { return false; } return true; diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java index 769241f2de2..b7c610c8466 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java @@ -19,6 +19,7 @@ */ package org.sonar.server.startup; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -78,7 +79,8 @@ public final class RegisterNewMeasureFilters { return loadedTemplateDao.countByTypeAndKey(LoadedTemplateDto.FILTER_TYPE, filterName) == 0; } - protected MeasureFilterDto register(String name, Filter filter) { + @VisibleForTesting + MeasureFilterDto register(String name, Filter filter) { MeasureFilterDto dto = null; if (filterDao.findSystemFilterByName(name) == null) { LOG.info("Register measure filter: " + name); @@ -90,7 +92,8 @@ public final class RegisterNewMeasureFilters { return dto; } - protected MeasureFilterDto createDtoFromExtension(String name, Filter filter) { + @VisibleForTesting + MeasureFilterDto createDtoFromExtension(String name, Filter filter) { Date now = new Date(); String data = toData(filter); return new MeasureFilterDto() diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java b/server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java index b718dbe094d..2c7665b7492 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/util/CloseableIterator.java @@ -20,7 +20,6 @@ package org.sonar.server.util; import com.google.common.base.Throwables; -import java.io.Closeable; import java.util.Iterator; import java.util.NoSuchElementException; import javax.annotation.CheckForNull; @@ -82,7 +81,8 @@ public abstract class CloseableIterator<O> implements Iterator<O>, AutoCloseable private O bufferNext() { try { - return nextObject = doNext(); + nextObject = doNext(); + return nextObject; } catch (RuntimeException e) { close(); throw e; diff --git a/server/sonar-server/src/main/java/org/sonar/server/util/cache/MemoryCache.java b/server/sonar-server/src/main/java/org/sonar/server/util/cache/MemoryCache.java index 1d158d5fbec..2048992ee7d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/util/cache/MemoryCache.java +++ b/server/sonar-server/src/main/java/org/sonar/server/util/cache/MemoryCache.java @@ -19,13 +19,12 @@ */ package org.sonar.server.util.cache; -import org.sonar.server.exceptions.NotFoundException; - -import javax.annotation.CheckForNull; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.CheckForNull; +import org.sonar.server.exceptions.NotFoundException; /** * This in-memory cache relies on {@link org.sonar.server.util.cache.CacheLoader} to @@ -44,11 +43,9 @@ public class MemoryCache<K, V> { @CheckForNull public V getNullable(K key) { V value = map.get(key); - if (value == null) { - if (!map.containsKey(key)) { - value = loader.load(key); - map.put(key, value); - } + if (value == null && !map.containsKey(key)) { + value = loader.load(key); + map.put(key, value); } return value; } diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java index 040ea887b8e..b4fd0da96d8 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCacheBuilder.java @@ -37,7 +37,7 @@ public class FileCacheBuilder { } public FileCacheBuilder setUserHome(@Nullable String path) { - this.userHome = (path == null ? null : new File(path)); + this.userHome = (path == null) ? null : new File(path); return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java index a811576ef6b..4e88bc085cc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java @@ -19,15 +19,14 @@ */ package org.sonar.api.profiles; +import java.io.Writer; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.batch.BatchSide; import org.sonar.api.ExtensionPoint; +import org.sonar.api.batch.BatchSide; import org.sonar.api.server.ServerSide; -import java.io.Writer; - /** * @since 2.3 */ @@ -67,7 +66,7 @@ public abstract class ProfileExporter { } protected final ProfileExporter setSupportedLanguages(String... languages) { - supportedLanguages = (languages != null ? languages : new String[0]); + supportedLanguages = (languages != null) ? languages : new String[0]; return this; } @@ -98,7 +97,7 @@ public abstract class ProfileExporter { return false; } ProfileExporter that = (ProfileExporter) o; - return !(key != null ? !key.equals(that.key) : that.key != null); + return !((key != null) ? !key.equals(that.key) : (that.key != null)); } @Override diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java index d0eeb1ac824..bc37cec75b3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java @@ -64,7 +64,7 @@ public abstract class ProfileImporter { } protected final ProfileImporter setSupportedLanguages(String... languages) { - supportedLanguages = (languages != null) ? languages : new String[0]; + supportedLanguages = ((languages != null) ? languages : new String[0]); return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java index 0c5c511c4ed..fa78cd4edfa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java @@ -573,7 +573,7 @@ public interface WebService extends Definable<WebService.Context> { * @since 4.4 */ public NewParam setExampleValue(@Nullable Object s) { - this.exampleValue = (s != null ? s.toString() : null); + this.exampleValue = ((s != null) ? s.toString() : null); return this; } @@ -616,7 +616,7 @@ public interface WebService extends Definable<WebService.Context> { * @since 4.4 */ public NewParam setDefaultValue(@Nullable Object o) { - this.defaultValue = (o != null ? o.toString() : null); + this.defaultValue = ((o != null) ? o.toString() : null); return this; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java index 86b240416fb..a9e8e044df5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java @@ -174,7 +174,7 @@ public final class ZipUtils { private static void doZip(String entryName, File file, ZipOutputStream out) throws IOException { if (file.isDirectory()) { - entryName += '/'; + entryName += "/"; ZipEntry entry = new ZipEntry(entryName); out.putNextEntry(entry); out.closeEntry(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java index 5f40106efc1..a7f878fe061 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java @@ -60,7 +60,7 @@ public final class ViolationQuery { * @return the current violation query */ public ViolationQuery setSwitchedOff(boolean b) { - this.switchMode = (b ? SwitchMode.OFF : SwitchMode.ON); + this.switchMode = b ? SwitchMode.OFF : SwitchMode.ON; return this; } |