From e0a8d965788b063262f866062c7bc80d5e582654 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 27 Jun 2016 09:51:40 +0200 Subject: [PATCH] Fix some Quality flaws --- .../main/java/org/sonar/ce/app/CeServer.java | 2 +- .../org/sonar/process/monitor/Timeouts.java | 2 +- .../email/EmailNotificationChannel.java | 2 +- .../org/sonar/server/search/QueryContext.java | 2 +- .../org/sonar/core/util/ProgressLogger.java | 2 +- .../sonar/db/dashboard/WidgetPropertyDao.java | 10 +++--- .../main/java/org/sonar/db/rule/RuleDto.java | 4 +-- .../org/sonar/db/user/GroupMembershipDao.java | 32 +++++++++---------- .../java/org/sonar/home/cache/FileCache.java | 2 +- .../api/utils/internal/WorkDuration.java | 2 +- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java b/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java index 34887667ca5..532d5b592a8 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/app/CeServer.java @@ -109,7 +109,7 @@ public class CeServer implements Monitored { while (!stopAwait) { try { // wait for a quite long time but we will be interrupted if flag changes anyway - Thread.sleep(10000); + Thread.sleep(10_000); } catch (InterruptedException e) { // continue and check the flag } diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Timeouts.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Timeouts.java index 51c1e5ef777..3db3a326453 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Timeouts.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Timeouts.java @@ -31,7 +31,7 @@ class Timeouts { } public Timeouts() { - this(60000L); + this(60_000L); } /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java b/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java index f89f5f5ff6a..d3f40feea2d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java @@ -53,7 +53,7 @@ public class EmailNotificationChannel extends NotificationChannel { * @see org.apache.commons.mail.Email#setSocketConnectionTimeout(int) * @see org.apache.commons.mail.Email#setSocketTimeout(int) */ - private static final int SOCKET_TIMEOUT = 30000; + private static final int SOCKET_TIMEOUT = 30_000; /** * Email Header Field: "List-ID". diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/QueryContext.java b/server/sonar-server/src/main/java/org/sonar/server/search/QueryContext.java index 6dada64ab4b..233a8cd72e4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/QueryContext.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/QueryContext.java @@ -127,7 +127,7 @@ public class QueryContext { * Limit on the number of results to return. Defaults to {@link #DEFAULT_LIMIT}. */ public int getLimit() { - return showFullResult ? 999999 : limit; + return showFullResult ? 999_999 : limit; } /** diff --git a/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java b/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java index b6ac17345e2..e69b02e0981 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java +++ b/sonar-core/src/main/java/org/sonar/core/util/ProgressLogger.java @@ -30,7 +30,7 @@ import org.sonar.api.utils.log.Loggers; */ public class ProgressLogger { - public static final long DEFAULT_PERIOD_MS = 60000L; + public static final long DEFAULT_PERIOD_MS = 60_000L; private final Timer timer; private final LoggerTimerTask task; diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java index 067838dcf26..7f1a66c54e3 100644 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java +++ b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java @@ -75,11 +75,11 @@ public class WidgetPropertyDao implements Dao { public void deleteByWidgetIds(DbSession session, List widgetIdsWithPropertiesToDelete) { executeLargeInputs( - widgetIdsWithPropertiesToDelete, - input -> { - mapper(session).deleteByWidgetIds(input); - return Collections.emptyList(); - }); + widgetIdsWithPropertiesToDelete, + input -> { + mapper(session).deleteByWidgetIds(input); + return Collections.emptyList(); + }); } private static WidgetPropertyMapper mapper(DbSession session) { diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java index 55afe2e559e..5f78606ee51 100644 --- a/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java +++ b/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java @@ -312,11 +312,11 @@ public class RuleDto { } public Set getTags() { - return tags == null ? new HashSet() : new TreeSet<>(Arrays.asList(StringUtils.split(tags, ','))); + return tags == null ? new HashSet<>() : new TreeSet<>(Arrays.asList(StringUtils.split(tags, ','))); } public Set getSystemTags() { - return systemTags == null ? new HashSet() : new TreeSet<>(Arrays.asList(StringUtils.split(systemTags, ','))); + return systemTags == null ? new HashSet<>() : new TreeSet<>(Arrays.asList(StringUtils.split(systemTags, ','))); } private String getTagsField() { diff --git a/sonar-db/src/main/java/org/sonar/db/user/GroupMembershipDao.java b/sonar-db/src/main/java/org/sonar/db/user/GroupMembershipDao.java index cb0ad6dc6b8..eacda25b99b 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/GroupMembershipDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/GroupMembershipDao.java @@ -76,14 +76,14 @@ public class GroupMembershipDao implements Dao { public Map countUsersByGroups(DbSession session, Collection groupIds) { Map result = Maps.newHashMap(); executeLargeInputs( - groupIds, - input -> { - List userCounts = mapper(session).countUsersByGroup(input); - for (GroupUserCount count : userCounts) { - result.put(count.groupName(), count.userCount()); - } - return userCounts; - }); + groupIds, + input -> { + List userCounts = mapper(session).countUsersByGroup(input); + for (GroupUserCount count : userCounts) { + result.put(count.groupName(), count.userCount()); + } + return userCounts; + }); return result; } @@ -91,14 +91,14 @@ public class GroupMembershipDao implements Dao { public Multimap selectGroupsByLogins(DbSession session, Collection logins) { Multimap result = ArrayListMultimap.create(); executeLargeInputs( - logins, - input -> { - List groupMemberships = mapper(session).selectGroupsByLogins(input); - for (LoginGroup membership : groupMemberships) { - result.put(membership.login(), membership.groupName()); - } - return groupMemberships; - }); + logins, + input -> { + List groupMemberships = mapper(session).selectGroupsByLogins(input); + for (LoginGroup membership : groupMemberships) { + result.put(membership.login(), membership.groupName()); + } + return groupMemberships; + }); return result; } diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java index a723cf164de..5f341985bf7 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java @@ -32,7 +32,7 @@ import javax.annotation.CheckForNull; public class FileCache { /** Maximum loop count when creating temp directories. */ - private static final int TEMP_DIR_ATTEMPTS = 10000; + private static final int TEMP_DIR_ATTEMPTS = 10_000; private final File dir; private final File tmpDir; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java index f3c2bf812cd..f58a3918c5d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/WorkDuration.java @@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringStyle; */ public class WorkDuration implements Serializable { - static final int DAY_POSITION_IN_LONG = 10000; + static final int DAY_POSITION_IN_LONG = 10_000; static final int HOUR_POSITION_IN_LONG = 100; static final int MINUTE_POSITION_IN_LONG = 1; -- 2.39.5