]> source.dussan.org Git - sonarqube.git/commitdiff
[NO-JIRA] Addressing some code smells
authorBelen Pruvost <belen.pruvost@sonarsource.com>
Thu, 16 Sep 2021 07:53:08 +0000 (09:53 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 16 Sep 2021 20:03:30 +0000 (20:03 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/ComponentNewValue.java
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/package-info.java [new file with mode: 0644]
server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentKeyUpdaterDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/package-info.java [new file with mode: 0644]
server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
server/sonar-webserver-api/src/main/java/org/sonar/server/rule/package-info.java [new file with mode: 0644]
server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/setting/ws/ValuesAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
sonar-core/src/main/java/org/sonar/core/config/SvnProperties.java

index 75b64af6947cfaf645ff9ab8f35f13157ed39f15..73e0b0c2e72809d4236511d16a6903662fb0a634 100644 (file)
@@ -90,7 +90,7 @@ public class ComponentNewValue extends NewValue {
   }
 
   @CheckForNull
-  public boolean isPrivate() {
+  public Boolean isPrivate() {
     return isPrivate;
   }
 
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/package-info.java b/server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/package-info.java
new file mode 100644 (file)
index 0000000..77b47ce
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.db.audit.model;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index 80638b887e67eb90a5b5a0f2bd627236792362e4..489e9d4c31cc3fb3eb991c0875c9f25c1ad217c9 100644 (file)
@@ -156,10 +156,6 @@ public class ComponentKeyUpdaterDao implements Dao {
     }
   }
 
-  private static ComponentKeyUpdaterMapper mapper(DbSession dbSession) {
-    return dbSession.getMapper(ComponentKeyUpdaterMapper.class);
-  }
-
   public static void checkExistentKey(ComponentKeyUpdaterMapper mapper, String resourceKey) {
     if (mapper.countResourceByKey(resourceKey) > 0) {
       throw new IllegalArgumentException("Impossible to update key: a component with key \"" + resourceKey + "\" already exists.");
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/package-info.java b/server/sonar-db-dao/src/main/java/org/sonar/db/portfolio/package-info.java
new file mode 100644 (file)
index 0000000..9a2d320
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.db.portfolio;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index 140a0f6944a20d590501425cde3ceb1ccc17dc53..aef62f219224892fd2ceb3c89329d92e9f8852e3 100644 (file)
@@ -136,13 +136,13 @@ public class ClusterSettings implements Consumer<Props> {
   }
 
   private Set<AddressAndPort> parseAndCheckHosts(Property property, String value) {
-    Set<AddressAndPort> res = parseHosts( value);
+    Set<AddressAndPort> res = parseHosts(value);
     checkValidHosts(property, res);
     return res;
   }
 
   private void checkValidHosts(Property property, Set<AddressAndPort> addressAndPorts) {
-   List<String> invalidHosts = addressAndPorts.stream()
+    List<String> invalidHosts = addressAndPorts.stream()
       .map(AddressAndPort::getHost)
       .filter(t -> !network.toInetAddress(t).isPresent())
       .sorted()
@@ -231,7 +231,9 @@ public class ClusterSettings implements Consumer<Props> {
   private static class AddressAndPort {
     private static final int NO_PORT = -1;
 
-    /** the host from setting, can be a hostname or an IP address */
+    /**
+     * the host from setting, can be a hostname or an IP address
+     */
     private final String host;
     private final int port;
 
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/rule/package-info.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/rule/package-info.java
new file mode 100644 (file)
index 0000000..d96ac2b
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 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.rule;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index b1e11e52d673410ee62f470cdbd60f42315f6051..d89132956dd90adecfb7223168ba1d1d0f303c24 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.authentication;
 
-import org.picocontainer.Startable;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.db.DbClient;
index bf0cb2109725a66a92b2c6803b77a07cb2e0745b..84f491d17424ebae0530478ae4e62f2484e98e10 100644 (file)
@@ -35,7 +35,6 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import org.sonar.api.config.Configuration;
 import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.server.ws.Change;
@@ -60,7 +59,6 @@ import static org.sonar.api.CoreProperties.SERVER_ID;
 import static org.sonar.api.CoreProperties.SERVER_STARTTIME;
 import static org.sonar.api.PropertyType.PROPERTY_SET;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED;
 import static org.sonar.server.setting.ws.PropertySetExtractor.extractPropertySetKeys;
 import static org.sonar.server.setting.ws.SettingsWsParameters.PARAM_COMPONENT;
 import static org.sonar.server.setting.ws.SettingsWsParameters.PARAM_KEYS;
@@ -81,16 +79,14 @@ public class ValuesAction implements SettingsWsAction {
   private final UserSession userSession;
   private final PropertyDefinitions propertyDefinitions;
   private final SettingsWsSupport settingsWsSupport;
-  private final boolean isSonarCloud;
 
   public ValuesAction(DbClient dbClient, ComponentFinder componentFinder, UserSession userSession, PropertyDefinitions propertyDefinitions,
-    SettingsWsSupport settingsWsSupport, Configuration configuration) {
+    SettingsWsSupport settingsWsSupport) {
     this.dbClient = dbClient;
     this.componentFinder = componentFinder;
     this.userSession = userSession;
     this.propertyDefinitions = propertyDefinitions;
     this.settingsWsSupport = settingsWsSupport;
-    this.isSonarCloud = configuration.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false);
   }
 
   @Override
index 8ac58cda4e2c6c98cadfe8919a705e2b52bbb42b..7bf27b1ae0b5c18e9d4a9278f6ab23008353a1c8 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.setting.ws;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableMap;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -31,7 +30,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.api.PropertyType;
-import org.sonar.api.config.Configuration;
 import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.PropertyFieldDefinition;
@@ -72,7 +70,6 @@ import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
 import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
 import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
-import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED;
 import static org.sonarqube.ws.MediaTypes.JSON;
 import static org.sonarqube.ws.Settings.Setting.ParentValueOneOfCase.PARENTVALUEONEOF_NOT_SET;
 
@@ -935,13 +932,7 @@ public class ValuesActionTest {
 
   private WsActionTester newTester() {
     MapSettings settings = new MapSettings();
-    Configuration configuration = settings.asConfig();
-    return new WsActionTester(new ValuesAction(dbClient, TestComponentFinder.from(db), userSession, definitions, support, configuration));
+    return new WsActionTester(new ValuesAction(dbClient, TestComponentFinder.from(db), userSession, definitions, support));
   }
 
-  private WsActionTester newSonarCloudTester() {
-    MapSettings settings = new MapSettings().setProperty(SONARCLOUD_ENABLED.getKey(), "true");
-    Configuration configuration = settings.asConfig();
-    return new WsActionTester(new ValuesAction(dbClient, TestComponentFinder.from(db), userSession, definitions, support, configuration));
-  }
 }
index 1c282cc846d980c6493dd819256c647355e319af..3e4d7704c434420fda1138ac56b64d5d648675ec 100644 (file)
  */
 package org.sonar.core.config;
 
-import java.util.Arrays;
-import java.util.List;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.PropertyType;
-import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.resources.Qualifiers;
-
 public class SvnProperties {
 
-  private static final String CATEGORY_SVN = "SVN";
   public static final String USER_PROP_KEY = "sonar.svn.username";
   public static final String PRIVATE_KEY_PATH_PROP_KEY = "sonar.svn.privateKeyPath";
   public static final String PASSWORD_PROP_KEY = "sonar.svn.password.secured";