From ae4c7b72d7d9b64a970bad102606b398e61b2243 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 30 Jun 2014 14:48:07 +0200 Subject: [PATCH] Remove useless constructors with System2.INSTANCE --- .../java/org/sonar/batch/profiling/ModuleProfiling.java | 4 ++-- .../org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java | 7 +------ .../org/sonar/batch/scan/ProjectScanContainerTest.java | 2 ++ .../org/sonar/core/permission/PermissionTemplateDao.java | 6 +----- sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java | 4 ++-- .../permission/GroupWithPermissionTemplateDaoTest.java | 3 ++- .../org/sonar/core/permission/PermissionFacadeTest.java | 3 ++- .../core/permission/UserWithPermissionTemplateDaoTest.java | 3 ++- .../core/resource/DefaultResourcePermissionsTest.java | 3 ++- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java index 8dc520e3d9d..af2d888c854 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/ModuleProfiling.java @@ -25,7 +25,7 @@ import org.sonar.api.utils.System2; import org.sonar.batch.phases.Phases; import org.sonar.batch.phases.Phases.Phase; -import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import java.util.HashMap; import java.util.LinkedHashMap; @@ -38,7 +38,7 @@ public class ModuleProfiling extends AbstractTimeProfiling { private Map profilingPerBatchStep = new LinkedHashMap(); private final Project module; - public ModuleProfiling(@CheckForNull Project module, System2 system) { + public ModuleProfiling(@Nullable Project module, System2 system) { super(system); this.module = module; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java index a31cc144830..c2eec6f34a5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java @@ -60,10 +60,6 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx private final System2 system; - public PhasesSumUpTimeProfiler() { - this(System2.INSTANCE); - } - static void println(String msg) { LOG.info(msg); } @@ -77,8 +73,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx println(sb.toString()); } - @VisibleForTesting - PhasesSumUpTimeProfiler(System2 system) { + public PhasesSumUpTimeProfiler(System2 system) { this.totalProfiling = new ModuleProfiling(null, system); this.system = system; } diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java index 8f585fd36c4..7f01b5fb55d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java @@ -31,6 +31,7 @@ import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.config.Settings; import org.sonar.api.platform.ComponentContainer; import org.sonar.api.task.TaskExtension; +import org.sonar.api.utils.System2; import org.sonar.batch.bootstrap.ExtensionInstaller; import org.sonar.batch.profiling.PhasesSumUpTimeProfiler; import org.sonar.batch.scan.maven.MavenPluginExecutor; @@ -53,6 +54,7 @@ public class ProjectScanContainerTest { settings = new Settings(); parentContainer = new ComponentContainer(); parentContainer.add(settings); + parentContainer.add(System2.INSTANCE); container = new ProjectScanContainer(parentContainer); } diff --git a/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java index 12de7d95c95..9ec979bc283 100644 --- a/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java @@ -46,15 +46,11 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent { private final MyBatis myBatis; private final System2 system; - PermissionTemplateDao(MyBatis myBatis, System2 system) { + public PermissionTemplateDao(MyBatis myBatis, System2 system) { this.myBatis = myBatis; this.system = system; } - public PermissionTemplateDao(MyBatis myBatis) { - this(myBatis, System2.INSTANCE); - } - /** * @return a paginated list of users. */ diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java index e1859e925e3..fd3909bcc58 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java @@ -305,8 +305,8 @@ public final class RuleDto extends Dto { return effortToFixDescription; } - public RuleDto setEffortToFixDescription(@Nullable String effortToFixDescription) { - this.effortToFixDescription = effortToFixDescription; + public RuleDto setEffortToFixDescription(@Nullable String s) { + this.effortToFixDescription = s; return this; } diff --git a/sonar-core/src/test/java/org/sonar/core/permission/GroupWithPermissionTemplateDaoTest.java b/sonar-core/src/test/java/org/sonar/core/permission/GroupWithPermissionTemplateDaoTest.java index dce3a2ac30b..f91e616233a 100644 --- a/sonar-core/src/test/java/org/sonar/core/permission/GroupWithPermissionTemplateDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/permission/GroupWithPermissionTemplateDaoTest.java @@ -22,6 +22,7 @@ package org.sonar.core.permission; import org.junit.Before; import org.junit.Test; +import org.sonar.api.utils.System2; import org.sonar.core.persistence.AbstractDaoTestCase; import java.util.List; @@ -36,7 +37,7 @@ public class GroupWithPermissionTemplateDaoTest extends AbstractDaoTestCase { @Before public void setUp() { - dao = new PermissionTemplateDao(getMyBatis()); + dao = new PermissionTemplateDao(getMyBatis(), System2.INSTANCE); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java b/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java index a4efe7cac33..e76001acafc 100644 --- a/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java +++ b/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java @@ -26,6 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.config.Settings; +import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; import org.sonar.core.persistence.AbstractDaoTestCase; import org.sonar.core.persistence.MyBatis; @@ -49,7 +50,7 @@ public class PermissionFacadeTest extends AbstractDaoTestCase { public void setUp() { RoleDao roleDao = new RoleDao(getMyBatis()); UserDao userDao = new UserDao(getMyBatis()); - permissionTemplateDao = new PermissionTemplateDao(getMyBatis()); + permissionTemplateDao = new PermissionTemplateDao(getMyBatis(), System2.INSTANCE); Settings settings = new Settings(); permissionFacade = new PermissionFacade(getMyBatis(), roleDao, userDao, new ResourceDao(getMyBatis()), permissionTemplateDao, settings); } diff --git a/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionTemplateDaoTest.java b/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionTemplateDaoTest.java index 27ab2e61418..ed0dc5358fb 100644 --- a/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionTemplateDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionTemplateDaoTest.java @@ -22,6 +22,7 @@ package org.sonar.core.permission; import org.junit.Before; import org.junit.Test; +import org.sonar.api.utils.System2; import org.sonar.core.persistence.AbstractDaoTestCase; import java.util.List; @@ -36,7 +37,7 @@ public class UserWithPermissionTemplateDaoTest extends AbstractDaoTestCase { @Before public void setUp() { - dao = new PermissionTemplateDao(getMyBatis()); + dao = new PermissionTemplateDao(getMyBatis(), System2.INSTANCE); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java b/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java index 7522e3180d1..e24d07ba7ef 100644 --- a/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java @@ -27,6 +27,7 @@ import org.sonar.api.config.Settings; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.security.DefaultGroups; +import org.sonar.api.utils.System2; import org.sonar.core.permission.PermissionFacade; import org.sonar.core.permission.PermissionTemplateDao; import org.sonar.core.persistence.AbstractDaoTestCase; @@ -49,7 +50,7 @@ public class DefaultResourcePermissionsTest extends AbstractDaoTestCase { project = new Project("project").setId(123); settings = new Settings(); PermissionFacade permissionFacade = new PermissionFacade(getMyBatis(), - new RoleDao(getMyBatis()), new UserDao(getMyBatis()), new ResourceDao(getMyBatis()), new PermissionTemplateDao(getMyBatis()), settings); + new RoleDao(getMyBatis()), new UserDao(getMyBatis()), new ResourceDao(getMyBatis()), new PermissionTemplateDao(getMyBatis(), System2.INSTANCE), settings); permissions = new DefaultResourcePermissions(getMyBatis(), permissionFacade); } -- 2.39.5