]> source.dussan.org Git - sonarqube.git/commitdiff
fix quality flaws
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 6 Apr 2016 19:08:53 +0000 (21:08 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 6 Apr 2016 19:08:53 +0000 (21:08 +0200)
server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java
server/sonar-server/src/main/java/org/sonar/server/app/TomcatStartupLogs.java
server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java
sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/CeTaskBuilder_PostProjectAnalysisTaskTesterTest.java
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/ConditionBuilder_PostProjectAnalysisTaskTesterTest.java
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/ProjectBuilder_PostProjectAnalysisTaskTesterTest.java
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/QualityGateBuilder_PostProjectAnalysisTaskTesterTest.java
sonar-scanner-engine/src/main/java/org/sonar/batch/analysis/DefaultAnalysisMode.java
sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java

index a656f9a56d561cd9b8f4a058fdac812b230aec2e..a3de4ace39a1d0f9bc99ef7a8ae0560fda8ed893 100644 (file)
@@ -60,7 +60,7 @@ class EmbeddedTomcat {
     webappContext = new TomcatContexts().configure(tomcat, props);
     try {
       tomcat.start();
-      new TomcatStartupLogs(props, Loggers.get(getClass())).log(tomcat);
+      new TomcatStartupLogs(Loggers.get(getClass())).log(tomcat);
     } catch (LifecycleException e) {
       Throwables.propagate(e);
     }
index cba0409fc00d37358a3385f347833c472c959cab..321fd727a27fa27d994c417d4446cbda848d96a6 100644 (file)
@@ -23,15 +23,12 @@ import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.utils.log.Logger;
-import org.sonar.process.Props;
 
 class TomcatStartupLogs {
 
   private final Logger log;
-  private final Props props;
 
-  TomcatStartupLogs(Props props, Logger log) {
-    this.props = props;
+  TomcatStartupLogs(Logger log) {
     this.log = log;
   }
 
index bb856924ddaeef3c7e3d122cb5a9fbf95a4681e4..d4fe8613db1eda62de6104143ce46fea2b6b3488 100644 (file)
@@ -37,8 +37,7 @@ public class StartupLogsTest {
 
   Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS);
   Logger logger = mock(Logger.class);
-  Props props = new Props(new Properties());
-  TomcatStartupLogs underTest = new TomcatStartupLogs(props, logger);
+  TomcatStartupLogs underTest = new TomcatStartupLogs(logger);
 
   @Test
   public void logAjp() {
index 1abe451aca1f9eca2d14802ddae81ba622e489c2..218247b433cbb2ca688a13a0d8f1d3445c49f738 100644 (file)
@@ -91,9 +91,10 @@ import static java.util.Objects.requireNonNull;
  */
 @Beta
 public class PostProjectAnalysisTaskTester {
-  private static final String DATE_CAN_NOT_BE_NULL = "date can not be null";
-  private static final String PROJECT_CAN_NOT_BE_NULL = "project can not be null";
-  private static final String CE_TASK_CAN_NOT_BE_NULL = "ceTask can not be null";
+  private static final String DATE_CAN_NOT_BE_NULL = "date cannot be null";
+  private static final String PROJECT_CAN_NOT_BE_NULL = "project cannot be null";
+  private static final String CE_TASK_CAN_NOT_BE_NULL = "ceTask cannot be null";
+  private static final String STATUS_CAN_NOT_BE_NULL = "status cannot be null";
 
   private final PostProjectAnalysisTask underTest;
   @CheckForNull
@@ -106,7 +107,7 @@ public class PostProjectAnalysisTaskTester {
   private QualityGate qualityGate;
 
   private PostProjectAnalysisTaskTester(PostProjectAnalysisTask underTest) {
-    this.underTest = requireNonNull(underTest, "PostProjectAnalysisTask instance can not be null");
+    this.underTest = requireNonNull(underTest, "PostProjectAnalysisTask instance cannot be null");
   }
 
   public static PostProjectAnalysisTaskTester of(PostProjectAnalysisTask underTest) {
@@ -191,8 +192,7 @@ public class PostProjectAnalysisTaskTester {
 
   @Beta
   public static final class CeTaskBuilder {
-    private static final String ID_CAN_NOT_BE_NULL = "id can not be null";
-    private static final String STATUS_CAN_NOT_BE_NULL = "status can not be null";
+    private static final String ID_CAN_NOT_BE_NULL = "id cannot be null";
 
     @CheckForNull
     private String id;
@@ -240,9 +240,9 @@ public class PostProjectAnalysisTaskTester {
 
   @Beta
   public static final class ProjectBuilder {
-    private static final String UUID_CAN_NOT_BE_NULL = "uuid can not be null";
-    private static final String KEY_CAN_NOT_BE_NULL = "key can not be null";
-    private static final String NAME_CAN_NOT_BE_NULL = "name can not be null";
+    private static final String UUID_CAN_NOT_BE_NULL = "uuid cannot be null";
+    private static final String KEY_CAN_NOT_BE_NULL = "key cannot be null";
+    private static final String NAME_CAN_NOT_BE_NULL = "name cannot be null";
     private String uuid;
     private String key;
     private String name;
@@ -301,9 +301,8 @@ public class PostProjectAnalysisTaskTester {
 
   @Beta
   public static final class QualityGateBuilder {
-    private static final String ID_CAN_NOT_BE_NULL = "id can not be null";
-    private static final String NAME_CAN_NOT_BE_NULL = "name can not be null";
-    private static final String STATUS_CAN_NOT_BE_NULL = "status can not be null";
+    private static final String ID_CAN_NOT_BE_NULL = "id cannot be null";
+    private static final String NAME_CAN_NOT_BE_NULL = "name cannot be null";
 
     private String id;
     private String name;
@@ -330,7 +329,7 @@ public class PostProjectAnalysisTaskTester {
     }
 
     public QualityGateBuilder add(QualityGate.Condition condition) {
-      conditions.add(requireNonNull(condition, "condition can not be null"));
+      conditions.add(requireNonNull(condition, "condition cannot be null"));
       return this;
     }
 
@@ -380,8 +379,8 @@ public class PostProjectAnalysisTaskTester {
 
   @Beta
   public static final class ConditionBuilder {
-    private static final String METRIC_KEY_CAN_NOT_BE_NULL = "metricKey can not be null";
-    private static final String OPERATOR_CAN_NOT_BE_NULL = "operator can not be null";
+    private static final String METRIC_KEY_CAN_NOT_BE_NULL = "metricKey cannot be null";
+    private static final String OPERATOR_CAN_NOT_BE_NULL = "operator cannot be null";
 
     private String metricKey;
     private QualityGate.Operator operator;
@@ -472,9 +471,9 @@ public class PostProjectAnalysisTaskTester {
 
     public QualityGate.Condition build(final QualityGate.EvaluationStatus status, final String value) {
       checkCommonProperties();
-      requireNonNull(status, "status can not be null");
-      checkArgument(status != QualityGate.EvaluationStatus.NO_VALUE, "status can not be NO_VALUE, use method buildNoValue() instead");
-      requireNonNull(value, "value can not be null, use method buildNoValue() instead");
+      requireNonNull(status, STATUS_CAN_NOT_BE_NULL);
+      checkArgument(status != QualityGate.EvaluationStatus.NO_VALUE, "status cannot be NO_VALUE, use method buildNoValue() instead");
+      requireNonNull(value, "value cannot be null, use method buildNoValue() instead");
       return new QualityGate.Condition() {
         @Override
         public QualityGate.EvaluationStatus getStatus() {
index 4425b0f228191cffdb165ae97e5ce175241db679..f1f7178cffe9dd15bb4307bc448d55ccb12daf50 100644 (file)
@@ -37,7 +37,7 @@ public class CeTaskBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setId_throws_NPE_if_id_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("id can not be null");
+    expectedException.expectMessage("id cannot be null");
 
     underTest.setId(null);
   }
@@ -45,7 +45,7 @@ public class CeTaskBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setStatus_throws_NPE_if_status_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("status can not be null");
+    expectedException.expectMessage("status cannot be null");
 
     underTest.setStatus(null);
   }
@@ -55,7 +55,7 @@ public class CeTaskBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setStatus(SOME_STATUS);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("id can not be null");
+    expectedException.expectMessage("id cannot be null");
 
     underTest.build();
   }
@@ -65,7 +65,7 @@ public class CeTaskBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setId(SOME_ID);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("status can not be null");
+    expectedException.expectMessage("status cannot be null");
 
     underTest.build();
   }
index c6ab146015de6fdc241335a6a377cb81d54f4609..a5cfc43b52c39ae08d8b7dfbb1f3fbf20871c965 100644 (file)
@@ -41,7 +41,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setMetricKey_throws_NPE_if_operator_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("metricKey can not be null");
+    expectedException.expectMessage("metricKey cannot be null");
 
     underTest.setMetricKey(null);
   }
@@ -49,7 +49,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setOperator_throws_NPE_if_operator_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("operator can not be null");
+    expectedException.expectMessage("operator cannot be null");
 
     underTest.setOperator(null);
   }
@@ -59,7 +59,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setOperator(SOME_OPERATOR).setErrorThreshold(SOME_ERROR_THRESHOLD).setWarningThreshold(SOME_WARNING_THRESHOLD);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("metricKey can not be null");
+    expectedException.expectMessage("metricKey cannot be null");
 
     underTest.buildNoValue();
   }
@@ -69,7 +69,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setMetricKey(SOME_METRIC_KEY).setErrorThreshold(SOME_ERROR_THRESHOLD).setWarningThreshold(SOME_WARNING_THRESHOLD);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("operator can not be null");
+    expectedException.expectMessage("operator cannot be null");
 
     underTest.buildNoValue();
   }
@@ -151,7 +151,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     initValidBuilder();
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("status can not be null");
+    expectedException.expectMessage("status cannot be null");
 
     underTest.build(null, SOME_VALUE);
   }
@@ -161,7 +161,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     initValidBuilder();
 
     expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("status can not be NO_VALUE, use method buildNoValue() instead");
+    expectedException.expectMessage("status cannot be NO_VALUE, use method buildNoValue() instead");
 
     underTest.build(QualityGate.EvaluationStatus.NO_VALUE, SOME_VALUE);
   }
@@ -171,7 +171,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     initValidBuilder();
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("value can not be null, use method buildNoValue() instead");
+    expectedException.expectMessage("value cannot be null, use method buildNoValue() instead");
 
     underTest.build(SOME_STATUS_BUT_NO_VALUE, null);
   }
@@ -181,7 +181,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setOperator(SOME_OPERATOR).setErrorThreshold(SOME_ERROR_THRESHOLD).setWarningThreshold(SOME_WARNING_THRESHOLD);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("metricKey can not be null");
+    expectedException.expectMessage("metricKey cannot be null");
 
     underTest.build(SOME_STATUS_BUT_NO_VALUE, SOME_VALUE);
   }
@@ -191,7 +191,7 @@ public class ConditionBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setMetricKey(SOME_METRIC_KEY).setErrorThreshold(SOME_ERROR_THRESHOLD).setWarningThreshold(SOME_WARNING_THRESHOLD);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("operator can not be null");
+    expectedException.expectMessage("operator cannot be null");
 
     underTest.build(SOME_STATUS_BUT_NO_VALUE, SOME_VALUE);
   }
index 320a3349e2cccf3f0d90d769e118180360825488..3b1eddb7a744687a84f988ac9758ce6f827899f2 100644 (file)
@@ -43,7 +43,7 @@ public class PostProjectAnalysisTaskTesterTest {
   @Test
   public void of_throws_NPE_if_PostProjectAnalysisTask_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("PostProjectAnalysisTask instance can not be null");
+    expectedException.expectMessage("PostProjectAnalysisTask instance cannot be null");
 
     PostProjectAnalysisTaskTester.of(null);
   }
@@ -51,7 +51,7 @@ public class PostProjectAnalysisTaskTesterTest {
   @Test
   public void withCeTask_throws_NPE_if_ceTask_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("ceTask can not be null");
+    expectedException.expectMessage("ceTask cannot be null");
 
     underTest.withCeTask(null);
   }
@@ -59,7 +59,7 @@ public class PostProjectAnalysisTaskTesterTest {
   @Test
   public void withProject_throws_NPE_if_project_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("project can not be null");
+    expectedException.expectMessage("project cannot be null");
 
     underTest.withProject(null);
   }
@@ -67,7 +67,7 @@ public class PostProjectAnalysisTaskTesterTest {
   @Test
   public void at_throws_NPE_if_date_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("date can not be null");
+    expectedException.expectMessage("date cannot be null");
 
     underTest.at(null);
   }
@@ -82,7 +82,7 @@ public class PostProjectAnalysisTaskTesterTest {
     underTest.withProject(project).at(someDate);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("ceTask can not be null");
+    expectedException.expectMessage("ceTask cannot be null");
 
     underTest.execute();
   }
@@ -92,7 +92,7 @@ public class PostProjectAnalysisTaskTesterTest {
     underTest.withCeTask(ceTask).at(someDate);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("project can not be null");
+    expectedException.expectMessage("project cannot be null");
 
     underTest.execute();
   }
@@ -130,7 +130,7 @@ public class PostProjectAnalysisTaskTesterTest {
     underTest.withCeTask(ceTask).withProject(project);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("date can not be null");
+    expectedException.expectMessage("date cannot be null");
 
     underTest.execute();
   }
index 25bc2d4614d5d75b6f138a8086e6383f5d6d8343..5536c0e8d2bfab0c901d0b47be0e72b39a8862fe 100644 (file)
@@ -38,7 +38,7 @@ public class ProjectBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setKey_throws_NPE_if_key_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("key can not be null");
+    expectedException.expectMessage("key cannot be null");
 
     underTest.setKey(null);
   }
@@ -46,7 +46,7 @@ public class ProjectBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setName_throws_NPE_if_name_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("name can not be null");
+    expectedException.expectMessage("name cannot be null");
 
     underTest.setName(null);
   }
@@ -54,7 +54,7 @@ public class ProjectBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setUuid_throws_NPE_if_uuid_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("uuid can not be null");
+    expectedException.expectMessage("uuid cannot be null");
 
     underTest.setUuid(null);
   }
@@ -64,7 +64,7 @@ public class ProjectBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setUuid(SOME_UUID).setName(SOME_NAME);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("key can not be null");
+    expectedException.expectMessage("key cannot be null");
 
     underTest.build();
   }
@@ -74,7 +74,7 @@ public class ProjectBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setUuid(SOME_UUID).setKey(SOME_KEY);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("name can not be null");
+    expectedException.expectMessage("name cannot be null");
 
 
     underTest.build();
@@ -85,7 +85,7 @@ public class ProjectBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setKey(SOME_KEY).setName(SOME_NAME);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("uuid can not be null");
+    expectedException.expectMessage("uuid cannot be null");
 
     underTest.build();
   }
index 61a466b372ed5f3ba2940c653a706faacce0048e..847b9a3cf6967bd748c797bcee670a6c09466e0c 100644 (file)
@@ -42,7 +42,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setId_throws_NPE_if_id_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("id can not be null");
+    expectedException.expectMessage("id cannot be null");
 
     underTest.setId(null);
   }
@@ -50,7 +50,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setStatus_throws_NPE_if_status_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("status can not be null");
+    expectedException.expectMessage("status cannot be null");
 
     underTest.setStatus(null);
   }
@@ -58,7 +58,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void setName_throws_NPE_if_name_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("name can not be null");
+    expectedException.expectMessage("name cannot be null");
 
     underTest.setName(null);
   }
@@ -66,7 +66,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
   @Test
   public void addCondition_throws_NPE_if_condition_is_null() {
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("condition can not be null");
+    expectedException.expectMessage("condition cannot be null");
 
     underTest.add(null);
   }
@@ -92,7 +92,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setStatus(SOME_STATUS).setName(SOME_NAME);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("id can not be null");
+    expectedException.expectMessage("id cannot be null");
 
     underTest.build();
   }
@@ -102,7 +102,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setId(SOME_ID).setName(SOME_NAME);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("status can not be null");
+    expectedException.expectMessage("status cannot be null");
 
     underTest.build();
   }
@@ -112,7 +112,7 @@ public class QualityGateBuilder_PostProjectAnalysisTaskTesterTest {
     underTest.setId(SOME_ID).setStatus(SOME_STATUS);
 
     expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("name can not be null");
+    expectedException.expectMessage("name cannot be null");
 
     underTest.build();
   }
index bd27cf81ca0a9011b8746bd2ffa936614816d08e..32a872ed16f1faf1239ce33026073698b54e0a72 100644 (file)
@@ -24,7 +24,6 @@ import javax.annotation.CheckForNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.batch.bootstrap.AbstractAnalysisMode;
 import org.sonar.batch.bootstrap.GlobalProperties;
 import org.sonar.batch.mediumtest.FakePluginInstaller;
@@ -32,7 +31,7 @@ import org.sonar.batch.mediumtest.FakePluginInstaller;
 /**
  * @since 4.0
  */
-public class DefaultAnalysisMode extends AbstractAnalysisMode implements AnalysisMode {
+public class DefaultAnalysisMode extends AbstractAnalysisMode {
 
   private static final Logger LOG = LoggerFactory.getLogger(DefaultAnalysisMode.class);
   private static final String KEY_SCAN_ALL = "sonar.scanAllFiles";
index 774dac71361e3d5cb21c682e878a4a7794d4aeaa..88127f28f74544f9056df81fb584a33968929376 100644 (file)
  */
 package org.sonar.batch.bootstrap;
 
-import org.sonar.api.CoreProperties;
-
-import org.sonar.api.batch.AnalysisMode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.CoreProperties;
 
-public class GlobalMode extends AbstractAnalysisMode implements AnalysisMode {
+public class GlobalMode extends AbstractAnalysisMode {
   private static final Logger LOG = LoggerFactory.getLogger(GlobalMode.class);
 
   public GlobalMode(GlobalProperties props) {