Sfoglia il codice sorgente

NO-JIRA Fix few code smells introduced in 9.5

tags/9.5.0.56709
Aurelien 1 anno fa
parent
commit
02cfe01520

+ 4
- 2
server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTest.java Vedi File

@@ -28,7 +28,6 @@ import org.junit.runner.RunWith;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.entry;

@RunWith(DataProviderRunner.class)
public class CeTaskTest {
@@ -76,7 +75,10 @@ public class CeTaskTest {
assertThat(task.getSubmitter()).isEqualTo(submitter);
assertThat(task.getComponent()).contains(component);
assertThat(task.getMainComponent()).contains(mainComponent);
assertThat(task.getCharacteristics()).containsExactly(entry("k1", "v1"), entry("k2", "v2"));
assertThat(task.getCharacteristics())
.hasSize(2)
.containsEntry("k1", "v1")
.containsEntry("k2", "v2");
}

@Test

+ 22
- 0
server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDescriptionSectionDtoTest.java Vedi File

@@ -22,12 +22,34 @@ package org.sonar.db.rule;
import org.assertj.core.api.Assertions;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

public class RuleDescriptionSectionDtoTest {
private static final RuleDescriptionSectionDto SECTION = RuleDescriptionSectionDto.builder()
.key("key")
.uuid("uuid")
.content("desc").build();


@Test
public void setDefault_whenKeyAlreadySet_shouldThrow() {
RuleDescriptionSectionDto.RuleDescriptionSectionDtoBuilder builderWithKey = RuleDescriptionSectionDto.builder()
.key("tagada");
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(builderWithKey::setDefault)
.withMessage("Only one of setDefault and key methods can be called");
}

@Test
public void setKey_whenDefaultAlreadySet_shouldThrow() {
RuleDescriptionSectionDto.RuleDescriptionSectionDtoBuilder builderWithDefault = RuleDescriptionSectionDto.builder()
.setDefault();
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> builderWithDefault.key("balbal"))
.withMessage("Only one of setDefault and key methods can be called");
}


@Test
public void testToString() {
Assertions.assertThat(SECTION).hasToString("RuleDescriptionSectionDto[uuid='uuid', key='key', content='desc']");

+ 0
- 1
server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginJarLoader.java Vedi File

@@ -26,7 +26,6 @@ import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

+ 9
- 10
server/sonar-webserver-core/src/main/java/org/sonar/server/plugins/PluginsRiskConsentFilter.java Vedi File

@@ -19,7 +19,15 @@
*/
package org.sonar.server.plugins;

import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.util.Set;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.sonar.api.config.Configuration;
import org.sonar.api.web.ServletFilter;
import org.sonar.core.extension.PluginRiskConsent;
@@ -30,15 +38,6 @@ import static org.sonar.core.config.CorePropertyDefinitions.PLUGINS_RISK_CONSENT
import static org.sonar.core.extension.PluginRiskConsent.NOT_ACCEPTED;
import static org.sonar.core.extension.PluginRiskConsent.REQUIRED;
import static org.sonar.server.authentication.AuthenticationRedirection.redirectTo;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Set;

public class PluginsRiskConsentFilter extends ServletFilter {


+ 23
- 0
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/pull/package-info.java Vedi File

@@ -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.issue.ws.pull;

import javax.annotation.ParametersAreNonnullByDefault;

+ 0
- 1
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java Vedi File

@@ -26,7 +26,6 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.project.ProjectDto;
import org.sonar.db.qualitygate.QualityGateDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.qualitygate.QualityGateFinder;
import org.sonar.server.qualitygate.QualityGateFinder.QualityGateData;

+ 0
- 1
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/ComponentAction.java Vedi File

@@ -49,7 +49,6 @@ import org.sonar.db.measure.LiveMeasureDto;
import org.sonar.db.permission.GlobalPermission;
import org.sonar.db.property.PropertyDto;
import org.sonar.db.property.PropertyQuery;
import org.sonar.db.qualitygate.QualityGateDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;

+ 0
- 1
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java Vedi File

@@ -19,7 +19,6 @@
*/
package org.sonar.server.ui.ws;

import com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;

+ 24
- 0
sonar-core/src/main/java/org/sonar/core/util/issue/package-info.java Vedi File

@@ -0,0 +1,24 @@
/*
* 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.core.util.issue;

import javax.annotation.ParametersAreNonnullByDefault;


+ 24
- 0
sonar-core/src/main/java/org/sonar/core/util/rule/package-info.java Vedi File

@@ -0,0 +1,24 @@
/*
* 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.core.util.rule;

import javax.annotation.ParametersAreNonnullByDefault;


Loading…
Annulla
Salva