From 0c7a1360859c33233ba66962e735691feb9beb92 Mon Sep 17 00:00:00 2001 From: Diego Marcilio Date: Wed, 12 Jun 2019 03:00:56 -0300 Subject: [PATCH] Using already-defined constants instead of duplicating their values Fixes multiple squid:S1192 violations (only for already defined constants) --- .../src/main/java/org/sonar/db/property/PropertiesDao.java | 2 +- .../version/v61/RemoveViewsDefinitionFromProperties.java | 2 +- .../src/main/java/org/sonar/server/platform/UrlSettings.java | 2 +- .../java/org/sonar/server/authentication/ws/ValidateAction.java | 2 +- .../org/sonar/server/qualityprofile/QProfileBackuperImpl.java | 2 +- .../main/java/org/sonar/server/user/ws/DeactivateAction.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java index bad536ddf3e..77129395c49 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/property/PropertiesDao.java @@ -116,7 +116,7 @@ public class PropertiesDao implements Dao { res.setString(1, projectUuid); int index = 2; for (String dispatcherKey : dispatcherKeys) { - res.setString(index, "notification." + dispatcherKey + ".%"); + res.setString(index, NOTIFICATION_PREFIX + dispatcherKey + ".%"); index++; } return res; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java index e069c555747..0370ad27b8f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v61/RemoveViewsDefinitionFromProperties.java @@ -64,7 +64,7 @@ public class RemoveViewsDefinitionFromProperties extends DataChange { " (?,?,?,?)")) { long now = system2.now(); insert - .setString(1, "views.def") + .setString(1, VIEWS_DEFINITION_PROPERTY_KEY) .setBoolean(2, false) .setString(3, property) .setLong(4, now) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java b/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java index 7545fa69da4..3ba9e89bc78 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/platform/UrlSettings.java @@ -68,7 +68,7 @@ public class UrlSettings { private String computeBaseUrl() { String host = config.get("sonar.web.host").orElse(""); int port = config.getInt("sonar.web.port").orElse(0); - String context = config.get("sonar.web.context").orElse(""); + String context = config.get(PROPERTY_CONTEXT).orElse(""); StringBuilder res = new StringBuilder(); res.append("http://"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java index edcda3f80c9..4647695654f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/ws/ValidateAction.java @@ -59,7 +59,7 @@ public class ValidateAction extends ServletFilter implements AuthenticationWsAct @Override public void define(WebService.NewController controller) { - controller.createAction("validate") + controller.createAction(VALIDATE_ACTION) .setDescription("Check credentials.") .setSince("3.3") .setHandler(ServletFilterHandler.INSTANCE) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java index 16fda06a01f..48658b6afd0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java @@ -148,7 +148,7 @@ public class QProfileBackuperImpl implements QProfileBackuper { SMInputFactory inputFactory = initStax(); SMHierarchicCursor rootC = inputFactory.rootElementCursor(backup); rootC.advance(); // - if (!"profile".equals(rootC.getLocalName())) { + if (!ATTRIBUTE_PROFILE.equals(rootC.getLocalName())) { throw new IllegalArgumentException("Backup XML is not valid. Root element must be ."); } SMInputCursor cursor = rootC.childElementCursor(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/DeactivateAction.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/DeactivateAction.java index 56973560f1e..c53c29885bd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/DeactivateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/DeactivateAction.java @@ -74,7 +74,7 @@ public class DeactivateAction implements UsersWsAction { .setResponseExample(getClass().getResource("deactivate-example.json")) .setHandler(this); - action.createParam("login") + action.createParam(PARAM_LOGIN) .setDescription("User login") .setRequired(true) .setExampleValue("myuser"); -- 2.39.5