diff options
author | Julien Camus <julien.camus@sonarsource.com> | 2024-12-17 18:22:05 +0100 |
---|---|---|
committer | Steve Marion <steve.marion@sonarsource.com> | 2024-12-18 11:13:24 +0100 |
commit | 9f14907cc3b7fde2ee00129dbc71e23a2f46bf7d (patch) | |
tree | 13eb3433a949a522fc5a0110af8a6e0b28e026f2 | |
parent | 00b0b87104d93055e49860b9cc6ddcedeba362fd (diff) | |
download | sonarqube-9f14907cc3b7fde2ee00129dbc71e23a2f46bf7d.tar.gz sonarqube-9f14907cc3b7fde2ee00129dbc71e23a2f46bf7d.zip |
SONAR-24003 Delete unnecessary imports
30 files changed, 35 insertions, 79 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/telemetry/SensorMetrics.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/telemetry/SensorMetrics.java index 8adf1748bf3..1729ba5de42 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/telemetry/SensorMetrics.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/telemetry/SensorMetrics.java @@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.scanner.ScannerSide; -import org.sonar.api.utils.Version; @ScannerSide public class SensorMetrics { diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/GenericPaginatedHttpClientImplTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/GenericPaginatedHttpClientImplTest.java index 0e4da3d8084..f62e3e3f1dd 100644 --- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/GenericPaginatedHttpClientImplTest.java +++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/GenericPaginatedHttpClientImplTest.java @@ -22,7 +22,6 @@ package org.sonar.alm.client; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.io.IOException; -import java.lang.reflect.Type; import java.util.List; import java.util.Optional; import org.junit.Rule; @@ -34,8 +33,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.slf4j.event.Level; -import org.sonar.auth.github.security.AccessToken; import org.sonar.api.testfixtures.log.LogTester; +import org.sonar.auth.github.security.AccessToken; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @@ -151,7 +150,7 @@ public class GenericPaginatedHttpClientImplTest { assertThatIllegalStateException() .isThrownBy(() -> underTest.get(APP_URL, accessToken, ENDPOINT, result -> gson.fromJson(result, STRING_LIST_TYPE))) .withMessage("SonarQube was not able to retrieve resources from external system. Error while executing a paginated call to https://github.com/, endpoint:/next-endpoint. " - + "Error while executing a call to https://github.com/. Return code 400. Error message: failed."); + + "Error while executing a call to https://github.com/. Return code 400. Error message: failed."); } private static GetResponse mockFailedResponse(String content) { @@ -186,11 +185,11 @@ public class GenericPaginatedHttpClientImplTest { .isThrownBy(() -> underTest.get(APP_URL, accessToken, "query", mock())) .isInstanceOf(IllegalStateException.class) .withMessage("SonarQube was not able to retrieve resources from external system. Error while executing a paginated call to https://github.com/, " - + "endpoint:query?per_page=100. error"); + + "endpoint:query?per_page=100. error"); assertThat(logTester.logs()).hasSize(1); assertThat(logTester.logs(Level.WARN)) .containsExactly("SonarQube was not able to retrieve resources from external system. " - + "Error while executing a paginated call to https://github.com/, endpoint:query?per_page=100."); + + "Error while executing a paginated call to https://github.com/, endpoint:query?per_page=100."); } } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderRule.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderRule.java index 32c944bc35e..8aaf0da7a1d 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderRule.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderRule.java @@ -23,7 +23,6 @@ import java.util.Optional; import javax.annotation.Nullable; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.rules.ExternalResource; import org.sonar.server.qualitygate.EvaluatedQualityGate; import static com.google.common.base.Preconditions.checkState; diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitorTest.java index 25779ab5480..dc607530cdb 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitorTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/MaintainabilityMeasuresVisitorTest.java @@ -61,10 +61,6 @@ import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builde import static org.sonar.ce.task.projectanalysis.measure.Measure.newMeasureBuilder; import static org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry.entryOf; import static org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry.toEntries; -import static org.sonar.server.measure.Rating.A; -import static org.sonar.server.measure.Rating.C; -import static org.sonar.server.measure.Rating.D; -import static org.sonar.server.measure.Rating.E; import static org.sonar.core.metric.SoftwareQualitiesMetrics.EFFORT_TO_REACH_SOFTWARE_QUALITY_MAINTAINABILITY_RATING_A; import static org.sonar.core.metric.SoftwareQualitiesMetrics.EFFORT_TO_REACH_SOFTWARE_QUALITY_MAINTAINABILITY_RATING_A_KEY; import static org.sonar.core.metric.SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_DEBT_RATIO; @@ -73,6 +69,9 @@ import static org.sonar.core.metric.SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MA import static org.sonar.core.metric.SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_RATING_KEY; import static org.sonar.core.metric.SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_REMEDIATION_EFFORT; import static org.sonar.core.metric.SoftwareQualitiesMetrics.SOFTWARE_QUALITY_MAINTAINABILITY_REMEDIATION_EFFORT_KEY; +import static org.sonar.server.measure.Rating.A; +import static org.sonar.server.measure.Rating.C; +import static org.sonar.server.measure.Rating.E; class MaintainabilityMeasuresVisitorTest { diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsComplexityMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsComplexityMeasuresStepTest.java index 283890f7d2c..646f3d6094d 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsComplexityMeasuresStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsComplexityMeasuresStepTest.java @@ -21,7 +21,6 @@ package org.sonar.ce.task.projectanalysis.step; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.sonar.ce.task.projectanalysis.batch.BatchReportReaderRule; import org.sonar.ce.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.ce.task.projectanalysis.measure.MeasureRepositoryRule; import org.sonar.ce.task.projectanalysis.metric.MetricRepositoryRule; diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationRule.java b/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationRule.java index 05927a64adf..1e042e0ed3d 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationRule.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeConfigurationRule.java @@ -19,8 +19,6 @@ */ package org.sonar.ce.configuration; -import org.junit.rules.ExternalResource; - import static com.google.common.base.Preconditions.checkArgument; /** diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/IndexedActiveRuleDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/IndexedActiveRuleDto.java index 58a07f70a44..2c58670a435 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/IndexedActiveRuleDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/IndexedActiveRuleDto.java @@ -21,7 +21,6 @@ package org.sonar.db.qualityprofile; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; import java.util.Map; import javax.annotation.CheckForNull; import org.sonar.api.issue.impact.Severity; @@ -29,7 +28,8 @@ import org.sonar.api.issue.impact.SoftwareQuality; public class IndexedActiveRuleDto { private static final Gson GSON = new Gson(); - private static final TypeToken<Map<SoftwareQuality, Severity>> TYPE = new TypeToken<>(){}; + private static final TypeToken<Map<SoftwareQuality, Severity>> TYPE = new TypeToken<>() { + }; private String uuid; private String ruleUuid; diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectLinkDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectLinkDbTester.java index 8e8203c70d2..24efb64cac4 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectLinkDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ProjectLinkDbTester.java @@ -22,7 +22,6 @@ package org.sonar.db.component; import java.util.Arrays; import java.util.function.Consumer; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.project.ProjectDto; @@ -37,7 +36,7 @@ public class ProjectLinkDbTester { this.db = db; this.dbClient = db.getDbClient(); } - + @SafeVarargs public final ProjectLinkDto insertProvidedLink(ProjectDto project, Consumer<ProjectLinkDto>... dtoPopulators) { return insertLink(project, newProvidedLinkDto(), dtoPopulators); diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/event/EventDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/event/EventDbTester.java index d87187e4f9f..2467b3fe78c 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/event/EventDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/event/EventDbTester.java @@ -23,7 +23,6 @@ import java.util.Optional; import javax.annotation.Nullable; import org.sonar.core.util.UuidFactoryFast; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; @@ -66,7 +65,7 @@ public class EventDbTester { .setComponentName(component.name()) .setComponentBranchKey(Optional.ofNullable(branch).map(BranchDto::getKey).orElse(null)); EventPurgeData eventPurgeData = new EventPurgeData(analysis.getRootComponentUuid(), analysis.getUuid()); - + dbClient.eventComponentChangeDao().insert(db.getSession(), eventComponentChange, eventPurgeData); db.commit(); diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/favorite/FavoriteDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/favorite/FavoriteDbTester.java index 26f53bf9e09..1574a8251de 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/favorite/FavoriteDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/favorite/FavoriteDbTester.java @@ -21,7 +21,6 @@ package org.sonar.db.favorite; import java.util.List; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.entity.EntityDto; import org.sonar.db.property.PropertyDto; @@ -40,9 +39,9 @@ public class FavoriteDbTester { public void add(EntityDto entity, String userUuid, String userLogin) { dbClient.propertiesDao().saveProperty(db.getSession(), new PropertyDto() - .setKey(PROP_FAVORITE_KEY) - .setUserUuid(userUuid) - .setEntityUuid(entity.getUuid()), + .setKey(PROP_FAVORITE_KEY) + .setUserUuid(userUuid) + .setEntityUuid(entity.getUuid()), userLogin, entity.getKey(), entity.getName(), entity.getQualifier()); db.commit(); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java index 99334c52628..214e1789b4a 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/permission/template/PermissionTemplateDbTester.java @@ -22,7 +22,6 @@ package org.sonar.db.permission.template; import java.util.function.Consumer; import javax.annotation.Nullable; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.user.GroupDto; import org.sonar.db.user.UserDto; @@ -97,9 +96,9 @@ public class PermissionTemplateDbTester { public void addProjectCreatorToTemplate(String templateUuid, String permission, String templateName) { dbClient.permissionTemplateCharacteristicDao().insert(db.getSession(), newPermissionTemplateCharacteristicDto() - .setWithProjectCreator(true) - .setTemplateUuid(templateUuid) - .setPermission(permission), + .setWithProjectCreator(true) + .setTemplateUuid(templateUuid) + .setPermission(permission), templateName); db.commit(); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/plugin/PluginDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/plugin/PluginDbTester.java index 8e13b0d233b..fc24a81181b 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/plugin/PluginDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/plugin/PluginDbTester.java @@ -22,7 +22,6 @@ package org.sonar.db.plugin; import java.util.Arrays; import java.util.function.Consumer; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; public class PluginDbTester { diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/InternalComponentPropertyDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/InternalComponentPropertyDbTester.java index f5bb41bc3db..7b5230c8039 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/InternalComponentPropertyDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/InternalComponentPropertyDbTester.java @@ -21,7 +21,6 @@ package org.sonar.db.property; import java.util.Optional; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; public class InternalComponentPropertyDbTester { diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/PropertyDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/PropertyDbTester.java index 38f5755c6e5..6d928820d27 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/PropertyDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/property/PropertyDbTester.java @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Optional; import javax.annotation.Nullable; import org.sonar.db.DbClient; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.entity.EntityDto; @@ -67,9 +66,9 @@ public class PropertyDbTester { public void insertProperty(String propKey, String propValue, @Nullable String componentUuid) { insertProperties(singletonList(new PropertyDto() - .setKey(propKey) - .setValue(propValue) - .setEntityUuid(componentUuid)), + .setKey(propKey) + .setValue(propValue) + .setEntityUuid(componentUuid)), null, null, null, null); } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java index 9462d6b7f49..1e1fea53fdb 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/engine/MigrationEngineImplTest.java @@ -19,7 +19,6 @@ */ package org.sonar.server.platform.db.migration.engine; -import java.sql.SQLException; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -32,8 +31,8 @@ import org.sonar.server.platform.db.migration.step.MigrationSteps; import org.sonar.server.platform.db.migration.step.NoOpMigrationStatusListener; import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep; import org.sonar.server.telemetry.TelemetryDbMigrationStepDurationProvider; -import org.sonar.server.telemetry.TelemetryDbMigrationSuccessProvider; import org.sonar.server.telemetry.TelemetryDbMigrationStepsProvider; +import org.sonar.server.telemetry.TelemetryDbMigrationSuccessProvider; import org.sonar.server.telemetry.TelemetryDbMigrationTotalTimeProvider; import static java.util.Collections.singletonList; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DeduplicateTableBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DeduplicateTableBuilderTest.java index 3be27f199b1..4197ce72bcc 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DeduplicateTableBuilderTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DeduplicateTableBuilderTest.java @@ -20,14 +20,13 @@ package org.sonar.server.platform.db.migration.sql; import java.util.List; -import junit.framework.TestCase; import org.assertj.core.api.Assertions; import org.junit.Test; public class DeduplicateTableBuilderTest { @Test - public void build_shouldReturnExpectedSql(){ + public void build_shouldReturnExpectedSql() { List<String> queries = new DeduplicateTableBuilder("example_table") .addReferenceColumn("reference_column1") .addReferenceColumn("reference_column2") @@ -39,7 +38,7 @@ public class DeduplicateTableBuilderTest { } @Test - public void build_shouldThrowException_whenIdentityColumnUndefined(){ + public void build_shouldThrowException_whenIdentityColumnUndefined() { DeduplicateTableBuilder builder = new DeduplicateTableBuilder("example_table") .addReferenceColumn("reference_column1") .addReferenceColumn("reference_column2"); @@ -49,7 +48,7 @@ public class DeduplicateTableBuilderTest { } @Test - public void build_shouldThrowException_whenReferenceColumnUndefined(){ + public void build_shouldThrowException_whenReferenceColumnUndefined() { DeduplicateTableBuilder builder = new DeduplicateTableBuilder("example_table") .setIdentityColumn("identity_column"); diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java index 7743fd820f1..d658ec2dce1 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java @@ -20,7 +20,6 @@ package org.sonar.server.user; import org.junit.Test; -import org.sonar.api.CoreProperties; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.security.Authenticator; import org.sonar.api.security.SecurityRealm; diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java index f7d25a3ff1e..a0823a23fff 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/component/ComponentUpdaterIT.java @@ -26,13 +26,9 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; -import org.sonar.db.component.ComponentQualifiers; -import org.sonar.db.component.ComponentScopes; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.util.SequenceUuidFactory; @@ -42,8 +38,8 @@ import org.sonar.db.audit.AuditPersister; import org.sonar.db.component.BranchDto; import org.sonar.db.component.BranchType; import org.sonar.db.component.ComponentDto; -import org.sonar.db.property.PropertyDto; -import org.sonar.server.component.ComponentTypesRule; +import org.sonar.db.component.ComponentQualifiers; +import org.sonar.db.component.ComponentScopes; import org.sonar.db.project.CreationMethod; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDto; @@ -53,6 +49,7 @@ import org.sonar.server.common.permission.PermissionUpdater; import org.sonar.server.common.permission.UserPermissionChange; import org.sonar.server.common.permission.UserPermissionChanger; import org.sonar.server.component.ComponentCreationData; +import org.sonar.server.component.ComponentTypesRule; import org.sonar.server.es.EsTester; import org.sonar.server.es.Indexers; import org.sonar.server.es.IndexersImpl; @@ -78,10 +75,10 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; import static org.sonar.db.component.ComponentQualifiers.APP; import static org.sonar.db.component.ComponentQualifiers.PROJECT; import static org.sonar.db.component.ComponentQualifiers.VIEW; -import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME; import static org.sonar.server.common.component.ComponentUpdater.ENABLED_FOR_ALL_PROJECTS; import static org.sonar.server.common.component.ComponentUpdater.SUGGESTION_FEATURE_ENABLED_PROPERTY; diff --git a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/rule/RuleCreatorIT.java b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/rule/RuleCreatorIT.java index 3634ee7c22c..c06e4bb444c 100644 --- a/server/sonar-webserver-common/src/it/java/org/sonar/server/common/rule/RuleCreatorIT.java +++ b/server/sonar-webserver-common/src/it/java/org/sonar/server/common/rule/RuleCreatorIT.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.assertj.core.api.Fail; import org.junit.Rule; import org.junit.Test; -import org.mockito.Mockito; import org.sonar.api.config.Configuration; import org.sonar.api.impl.utils.TestSystem2; import org.sonar.api.rule.RuleKey; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/AdvancedRuleDescriptionSectionsGeneratorTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/AdvancedRuleDescriptionSectionsGeneratorTest.java index 7948270684e..dae7ec067ae 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/AdvancedRuleDescriptionSectionsGeneratorTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/AdvancedRuleDescriptionSectionsGeneratorTest.java @@ -35,7 +35,6 @@ import org.sonar.core.util.UuidFactory; import org.sonar.db.rule.RuleDescriptionSectionContextDto; import org.sonar.db.rule.RuleDescriptionSectionDto; -import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; import static org.sonar.api.server.rule.RuleDescriptionSection.RuleDescriptionSectionKeys.HOW_TO_FIX_SECTION_KEY; @@ -84,7 +83,6 @@ public class AdvancedRuleDescriptionSectionsGeneratorTest { .context(RuleDescriptionSectionContextDto.of(CONTEXT_2.getKey(), CONTEXT_2.getDisplayName())) .build(); - @Mock private UuidFactory uuidFactory; diff --git a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/model/RestPageTest.java b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/model/RestPageTest.java index 2f8911fbf80..9da2eecad5c 100644 --- a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/model/RestPageTest.java +++ b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/model/RestPageTest.java @@ -22,8 +22,6 @@ package org.sonar.server.v2.api.model; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class RestPageTest { diff --git a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/common/model/UpdateFieldTest.java b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/common/model/UpdateFieldTest.java index 700bd3de631..aece08eda90 100644 --- a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/common/model/UpdateFieldTest.java +++ b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/common/model/UpdateFieldTest.java @@ -22,8 +22,6 @@ package org.sonar.server.v2.common.model; import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class UpdateFieldTest { diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/DeleteActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/DeleteActionIT.java index 7b0812c761e..cc60da65d1b 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/DeleteActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/branch/ws/DeleteActionIT.java @@ -28,7 +28,6 @@ import org.sonar.api.web.UserRole; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; -import org.sonar.db.component.ProjectData; import org.sonar.db.project.ProjectDto; import org.sonar.server.component.ComponentCleanerService; import org.sonar.server.component.ComponentFinder; @@ -111,8 +110,8 @@ public class DeleteActionIT { .setParam("project", project.getKey()) .setParam("branch", "branch1") .execute()) - .isInstanceOf(NotFoundException.class) - .hasMessageContaining("Branch 'branch1' not found"); + .isInstanceOf(NotFoundException.class) + .hasMessageContaining("Branch 'branch1' not found"); } @Test @@ -123,8 +122,8 @@ public class DeleteActionIT { .setParam("project", "foo") .setParam("branch", "branch1") .execute()) - .isInstanceOf(NotFoundException.class) - .hasMessageContaining("Project 'foo' not found"); + .isInstanceOf(NotFoundException.class) + .hasMessageContaining("Project 'foo' not found"); } @Test diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/DismissAnalysisWarningAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/DismissAnalysisWarningAction.java index ef6433422b4..f7f09ae6e8f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/DismissAnalysisWarningAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/DismissAnalysisWarningAction.java @@ -30,14 +30,11 @@ import org.sonar.db.DbSession; import org.sonar.db.ce.CeTaskMessageDto; import org.sonar.db.project.ProjectDto; import org.sonar.db.user.UserDismissedMessageDto; -import org.sonar.db.user.UserDto; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.user.UserSession; import static java.lang.String.format; -import static java.util.Objects.requireNonNull; -import static org.sonar.server.exceptions.NotFoundException.checkFound; public class DismissAnalysisWarningAction implements CeWsAction { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java index 26c73f4a36e..9bcd3472cd4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java @@ -21,7 +21,6 @@ package org.sonar.server.hotspot.ws; import java.util.HashSet; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.Function; @@ -300,7 +299,7 @@ public class ShowAction implements HotspotsWsAction { ProjectAndBranch projectAndBranch = hotspotWsSupport.loadAndCheckBranch(dbSession, hotspot, UserRole.USER); BranchDto branch = projectAndBranch.getBranch(); ComponentDto component = dbClient.componentDao().selectByUuid(dbSession, componentUuid) - .orElseThrow(() -> new NotFoundException(format("Component with uuid '%s' does not exist", componentUuid))); + .orElseThrow(() -> new NotFoundException(format("Component with uuid '%s' does not exist", componentUuid))); return new Components(projectAndBranch.getProject(), component, branch); } diff --git a/sonar-core/src/it/java/org/sonar/core/util/DefaultHttpDownloaderIT.java b/sonar-core/src/it/java/org/sonar/core/util/DefaultHttpDownloaderIT.java index 7aededcf286..cbab2fd1955 100644 --- a/sonar-core/src/it/java/org/sonar/core/util/DefaultHttpDownloaderIT.java +++ b/sonar-core/src/it/java/org/sonar/core/util/DefaultHttpDownloaderIT.java @@ -30,13 +30,10 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.Properties; -import java.util.zip.GZIPOutputStream; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; -import org.junit.Ignore; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.io.TempDir; diff --git a/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java b/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java index 26295713c48..b1efbfade58 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/DebtProperties.java @@ -21,9 +21,7 @@ package org.sonar.core.config; import java.util.List; import org.sonar.api.CoreProperties; -import org.sonar.api.PropertyType; import org.sonar.api.config.PropertyDefinition; -import org.sonar.api.config.PropertyFieldDefinition; class DebtProperties { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueFilterChain.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueFilterChain.java index f60a5ed7e1a..ae424d3b49c 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueFilterChain.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueFilterChain.java @@ -19,7 +19,6 @@ */ package org.sonar.scanner.issue; -import java.util.Collections; import java.util.List; import javax.annotation.concurrent.ThreadSafe; import org.sonar.api.scan.issue.filter.FilterableIssue; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java index c95966d6d18..ca666a6d866 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandIT.java @@ -35,7 +35,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.io.CleanupMode; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -68,7 +67,7 @@ class CompositeBlameCommandIT { // In JUnit4, if the cleanup cannot be performed, the test would not fail. This has changed with JUnit5 // As we cannot find the cause of failure during cleanup, we disable it for now - @TempDir (cleanup = NEVER) + @TempDir(cleanup = NEVER) private File temp; @BeforeAll @@ -105,8 +104,7 @@ class CompositeBlameCommandIT { "one-file-many-merges-and-renames", "two-merge-commits", "dummy-git", - "dummy-git-few-comitters" - ); + "dummy-git-few-comitters"); List<BlameAlgorithmEnum> blameStrategies = Arrays.stream(BlameAlgorithmEnum.values()).toList(); return testCases.stream() @@ -114,7 +112,6 @@ class CompositeBlameCommandIT { .toList().stream(); } - private void assertBlameMatchesExpectedBlame(Map<InputFile, List<BlameLine>> blame, File gitFolder) throws Exception { Map<Path, List<BlameLine>> expectedBlame = readExpectedBlame(gitFolder.getName()); diff --git a/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java b/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java index 0dc09835a06..b82fa71afb1 100644 --- a/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java +++ b/sonar-scanner-engine/src/testFixtures/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -50,7 +49,6 @@ import org.sonar.api.SonarEdition; import org.sonar.api.SonarProduct; import org.sonar.api.SonarQubeSide; import org.sonar.api.SonarRuntime; -import org.sonar.api.batch.rule.internal.NewActiveRule; import org.sonar.api.impl.server.RulesDefinitionContext; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; @@ -283,7 +281,6 @@ public class ScannerMediumTester extends ExternalResource implements BeforeTestE } } - public AnalysisBuilder newAnalysis() { return new AnalysisBuilder(this); } |