Browse Source

fix quality flaws

tags/5.5-RC1
Sébastien Lesaint 8 years ago
parent
commit
3b2d595782

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/app/EmbeddedTomcat.java View 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);
}

+ 1
- 4
server/sonar-server/src/main/java/org/sonar/server/app/TomcatStartupLogs.java View 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;
}


+ 1
- 2
server/sonar-server/src/test/java/org/sonar/server/app/StartupLogsTest.java View 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() {

+ 17
- 18
sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java View 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() {

+ 4
- 4
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/CeTaskBuilder_PostProjectAnalysisTaskTesterTest.java View 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();
}

+ 9
- 9
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/ConditionBuilder_PostProjectAnalysisTaskTesterTest.java View 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);
}

+ 7
- 7
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java View 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();
}

+ 6
- 6
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/ProjectBuilder_PostProjectAnalysisTaskTesterTest.java View 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();
}

+ 7
- 7
sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/QualityGateBuilder_PostProjectAnalysisTaskTesterTest.java View 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();
}

+ 1
- 2
sonar-scanner-engine/src/main/java/org/sonar/batch/analysis/DefaultAnalysisMode.java View 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";

+ 2
- 4
sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java View File

@@ -19,13 +19,11 @@
*/
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) {

Loading…
Cancel
Save