From 1ea8f035a6840b14404d9e67b24f7ea0df60a01c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 29 Aug 2013 16:15:07 +0200 Subject: [PATCH] Fix quality flaws --- .../sonar/core/persistence/DryRunDatabaseFactory.java | 11 +++++++---- .../sonar/server/issue/InternalRubyIssueService.java | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java index 9d37ae9101c..e2da68aeeb3 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java @@ -40,8 +40,11 @@ public class DryRunDatabaseFactory implements ServerComponent { private static final String DIALECT = "h2"; private static final String DRIVER = "org.h2.Driver"; private static final String URL = "jdbc:h2:"; - private static final String USER = "sonar"; - private static final String PASSWORD = "sonar"; + private static final String H2_FILE_SUFFIX = ".h2.db"; + private static final String SONAR = "sonar"; + private static final String USER = SONAR; + private static final String PASSWORD = SONAR; + private final Database database; private final ServerFileSystem serverFileSystem; @@ -62,7 +65,7 @@ public class DryRunDatabaseFactory implements ServerComponent { close(destination); if (LOG.isDebugEnabled()) { - File dbFile = new File(name + ".h2.db"); + File dbFile = new File(name + H2_FILE_SUFFIX); long size = dbFile.length(); long duration = System.currentTimeMillis() - startup; if (projectId == null) { @@ -136,7 +139,7 @@ public class DryRunDatabaseFactory implements ServerComponent { private byte[] dbFileContent(String name) { try { - File dbFile = new File(name + ".h2.db"); + File dbFile = new File(name + H2_FILE_SUFFIX); byte[] content = Files.toByteArray(dbFile); dbFile.delete(); return content; diff --git a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java index d5ab2fe3aca..41696ec744f 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java @@ -65,6 +65,7 @@ public class InternalRubyIssueService implements ServerComponent { private static final String ID_PARAM = "id"; private static final String NAME_PARAM = "name"; private static final String DESCRIPTION_PARAM = "description"; + private static final String ACTION_PLANS_ERRORS_ACTION_PLAN_DOES_NOT_EXIST = "action_plans.errors.action_plan_does_not_exist"; private final IssueService issueService; private final IssueCommentService commentService; @@ -248,7 +249,7 @@ public class InternalRubyIssueService implements ServerComponent { DefaultActionPlan existingActionPlan = (DefaultActionPlan) actionPlanService.findByKey(key, UserSession.get()); if (existingActionPlan == null) { Result result = Result.of(); - result.addError(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", key)); + result.addError(Result.Message.ofL10n(ACTION_PLANS_ERRORS_ACTION_PLAN_DOES_NOT_EXIST, key)); return result; } else { Result result = createActionPlanResult(parameters, existingActionPlan); @@ -362,7 +363,7 @@ public class InternalRubyIssueService implements ServerComponent { private Result createResultForExistingActionPlan(String actionPlanKey) { Result result = Result.of(); if (findActionPlan(actionPlanKey) == null) { - result.addError(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", actionPlanKey)); + result.addError(Result.Message.ofL10n(ACTION_PLANS_ERRORS_ACTION_PLAN_DOES_NOT_EXIST, actionPlanKey)); } return result; } -- 2.39.5