From 3c8379f8dac6872ce030dd3b3c824e4e69b76fc2 Mon Sep 17 00:00:00 2001 From: Klaudio Sinani Date: Mon, 14 Nov 2022 15:29:00 +0100 Subject: [PATCH] [NO-JIRA] Fix reported code smells --- .../org/sonar/xoo/coverage/package-info.java | 23 +++++++++++++++++++ .../formula/coverage/CoverageUtils.java | 1 - .../measure/BestValueOptimization.java | 1 - .../projectanalysis/step/LoadPeriodsStep.java | 3 --- .../migration/version/v98/package-info.java | 23 +++++++++++++++++++ .../live/LiveMeasureTreeUpdaterImpl.java | 2 -- .../org/sonar/core/platform/ServerId.java | 4 ++-- 7 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/package-info.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v98/package-info.java diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/package-info.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/package-info.java new file mode 100644 index 00000000000..211676e4e8f --- /dev/null +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/coverage/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.xoo.coverage; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/formula/coverage/CoverageUtils.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/formula/coverage/CoverageUtils.java index 876ce18cc4c..e54b518dff3 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/formula/coverage/CoverageUtils.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/formula/coverage/CoverageUtils.java @@ -19,7 +19,6 @@ */ package org.sonar.ce.task.projectanalysis.formula.coverage; -import java.util.Optional; import org.sonar.ce.task.projectanalysis.formula.CounterInitializationContext; import org.sonar.ce.task.projectanalysis.measure.Measure; diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimization.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimization.java index e30cf81f572..66b03e9b7ff 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimization.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/BestValueOptimization.java @@ -25,7 +25,6 @@ import org.sonar.ce.task.projectanalysis.component.Component; import org.sonar.ce.task.projectanalysis.metric.Metric; import static java.util.Objects.requireNonNull; -import static org.apache.commons.lang.math.NumberUtils.compare; import static org.sonar.ce.task.projectanalysis.measure.Measure.ValueType.NO_VALUE; public class BestValueOptimization implements Predicate { diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java index 19853944a19..87366dd2b74 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java @@ -19,10 +19,7 @@ */ package org.sonar.ce.task.projectanalysis.step; -import java.util.Arrays; -import java.util.Collection; import java.util.Optional; -import java.util.function.Supplier; import org.sonar.api.utils.System2; import org.sonar.ce.task.log.CeTaskMessages; import org.sonar.ce.task.log.CeTaskMessages.Message; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v98/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v98/package-info.java new file mode 100644 index 00000000000..d1fe6a9e477 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v98/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.platform.db.migration.version.v98; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java index 45c46995da4..ab65dd55386 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/live/LiveMeasureTreeUpdaterImpl.java @@ -22,7 +22,6 @@ package org.sonar.server.measure.live; import java.util.List; import java.util.Objects; import java.util.Optional; -import java.util.function.Function; import java.util.stream.Collectors; import org.sonar.api.config.Configuration; import org.sonar.api.measures.Metric; @@ -36,7 +35,6 @@ import org.sonar.db.measure.LiveMeasureDto; import org.sonar.server.measure.DebtRatingGrid; import org.sonar.server.measure.Rating; -import static com.google.common.base.Preconditions.checkState; import static org.sonar.api.measures.CoreMetrics.NEW_SECURITY_HOTSPOTS_KEY; import static org.sonar.api.measures.CoreMetrics.NEW_SECURITY_HOTSPOTS_REVIEWED_KEY; import static org.sonar.api.measures.CoreMetrics.NEW_SECURITY_HOTSPOTS_REVIEWED_STATUS_KEY; diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ServerId.java b/sonar-core/src/main/java/org/sonar/core/platform/ServerId.java index 30861f3d600..e1edc5f9fdb 100644 --- a/sonar-core/src/main/java/org/sonar/core/platform/ServerId.java +++ b/sonar-core/src/main/java/org/sonar/core/platform/ServerId.java @@ -109,8 +109,8 @@ public final class ServerId { public static ServerId of(@Nullable String databaseId, String datasetId) { if (databaseId != null) { - int databaseIdLength = databaseId.length(); - checkArgument(databaseIdLength == DATABASE_ID_LENGTH, "Illegal databaseId length (%s)", databaseIdLength); + int databaseIdLength = databaseId.length(); + checkArgument(databaseIdLength == DATABASE_ID_LENGTH, "Illegal databaseId length (%s)", databaseIdLength); } int datasetIdLength = datasetId.length(); checkArgument(datasetIdLength == DEPRECATED_SERVER_ID_LENGTH -- 2.39.5