Browse Source

Fix quality flaws

tags/5.3-RC1
Simon Brandhof 8 years ago
parent
commit
9df8ed37f3

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/BarChart.java View File

@@ -178,7 +178,7 @@ public class BarChart extends BaseChartWeb implements DeprecatedChart {

// Series
String seriesParam = params.get(BaseChartWeb.CHART_PARAM_SERIES);
String[] seriesSplit = null;
String[] seriesSplit;
if (seriesParam != null && seriesParam.length() > 0) {
seriesSplit = seriesParam.split(",");
} else {

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java View File

@@ -109,7 +109,7 @@ public class CustomBarChart extends BarChart {

// Categories
String categoriesParam = params.get(CHART_PARAM_CATEGORIES);
String[] categoriesSplit = null;
String[] categoriesSplit;
if (categoriesParam != null && categoriesParam.length() > 0) {
categoriesSplit = categoriesParam.split(",");
} else {

+ 1
- 1
sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java View File

@@ -96,7 +96,7 @@ public class DefaultSensorContext implements SensorContext {

@Override
public <G extends Serializable> NewMeasure<G> newMeasure() {
return new DefaultMeasure<G>(sensorStorage);
return new DefaultMeasure<>(sensorStorage);
}

@Override

+ 1
- 1
sonar-db/src/main/java/org/sonar/db/dashboard/DashboardMapper.java View File

@@ -45,6 +45,6 @@ public interface DashboardMapper {
@Insert("INSERT INTO dashboards (user_id, name, description, column_layout, shared, is_global, created_at, " +
"updated_at) VALUES (#{userId}, #{name}, #{description}, #{columnLayout}, #{shared}, " +
"#{global}, #{createdAt}, #{updatedAt})")
@Options(keyColumn = "id", useGeneratedKeys = true, keyProperty = "id")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void insert(DashboardDto dashboardDto);
}

+ 1
- 1
sonar-db/src/main/java/org/sonar/db/dashboard/WidgetMapper.java View File

@@ -31,7 +31,7 @@ public interface WidgetMapper {
" values (#{dashboardId,jdbcType=INTEGER}, #{widgetKey,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, " +
" #{description,jdbcType=VARCHAR}, #{columnIndex,jdbcType=INTEGER}, " +
" #{rowIndex,jdbcType=INTEGER}, #{configured,jdbcType=BOOLEAN}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{resourceId,jdbcType=INTEGER})")
@Options(keyColumn = "id", useGeneratedKeys = true, keyProperty = "id")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void insert(WidgetDto widgetDto);

WidgetDto selectById(long widgetId);

+ 1
- 1
sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyMapper.java View File

@@ -31,7 +31,7 @@ public interface WidgetPropertyMapper {
String COLUMNS = "wp.id, wp.widget_id as \"widgetId\", wp.kee as \"propertyKey\", wp.text_value as \"textValue\"";

@Insert("insert into widget_properties (widget_id, kee, text_value) values (#{widgetId}, #{propertyKey}, #{textValue})")
@Options(keyColumn = "id", useGeneratedKeys = true, keyProperty = "id")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void insert(WidgetPropertyDto dto);

@CheckForNull

+ 1
- 0
sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java View File

@@ -61,6 +61,7 @@ public class CeActivityDaoTest {
assertThat(saved.get().getStartedAt()).isEqualTo(1_500_000_000_000L);
assertThat(saved.get().getExecutedAt()).isEqualTo(1_500_000_000_500L);
assertThat(saved.get().getExecutionTimeMs()).isEqualTo(500L);
assertThat(saved.get().toString()).isNotEmpty();
}

@Test

+ 1
- 1
sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java View File

@@ -66,7 +66,7 @@ public abstract class ProfileExporter {
}

protected final ProfileExporter setSupportedLanguages(String... languages) {
supportedLanguages = (languages != null ? languages : new String[0]);
supportedLanguages = (languages != null) ? languages : new String[0];
return this;
}


+ 1
- 1
sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java View File

@@ -64,7 +64,7 @@ public abstract class ProfileImporter {
}

protected final ProfileImporter setSupportedLanguages(String... languages) {
supportedLanguages = (languages != null ? languages : new String[0]);
supportedLanguages = (languages != null) ? languages : new String[0];
return this;
}


+ 22
- 17
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java View File

@@ -264,51 +264,51 @@ public class RulesDefinitionXmlLoader {
String nodeName = cursor.getLocalName();

if (equalsIgnoreCase("name", nodeName)) {
name = trim(cursor.collectDescendantText(false));
name = nodeValue(cursor);

} else if (equalsIgnoreCase("description", nodeName)) {
description = trim(cursor.collectDescendantText(false));
description = nodeValue(cursor);

} else if (equalsIgnoreCase("descriptionFormat", nodeName)) {
descriptionFormat = trim(cursor.collectDescendantText(false));
descriptionFormat = nodeValue(cursor);

} else if (equalsIgnoreCase("key", nodeName)) {
key = trim(cursor.collectDescendantText(false));
key = nodeValue(cursor);

} else if (equalsIgnoreCase("configKey", nodeName)) {
// deprecated field, replaced by internalKey
internalKey = trim(cursor.collectDescendantText(false));
internalKey = nodeValue(cursor);

} else if (equalsIgnoreCase("internalKey", nodeName)) {
internalKey = trim(cursor.collectDescendantText(false));
internalKey = nodeValue(cursor);

} else if (equalsIgnoreCase("priority", nodeName)) {
// deprecated field, replaced by severity
severity = trim(cursor.collectDescendantText(false));
severity = nodeValue(cursor);

} else if (equalsIgnoreCase("severity", nodeName)) {
severity = trim(cursor.collectDescendantText(false));
severity = nodeValue(cursor);

} else if (equalsIgnoreCase("cardinality", nodeName)) {
template = Cardinality.MULTIPLE == Cardinality.valueOf(trim(cursor.collectDescendantText(false)));
template = Cardinality.MULTIPLE == Cardinality.valueOf(nodeValue(cursor));

} else if (equalsIgnoreCase("effortToFixDescription", nodeName)) {
effortToFixDescription = trim(cursor.collectDescendantText(false));
effortToFixDescription = nodeValue(cursor);

} else if (equalsIgnoreCase("debtRemediationFunction", nodeName)) {
debtRemediationFunction = trim(cursor.collectDescendantText(false));
debtRemediationFunction = nodeValue(cursor);

} else if (equalsIgnoreCase("debtRemediationFunctionOffset", nodeName)) {
debtRemediationFunctionOffset = trim(cursor.collectDescendantText(false));
debtRemediationFunctionOffset = nodeValue(cursor);

} else if (equalsIgnoreCase("debtRemediationFunctionCoefficient", nodeName)) {
debtRemediationFunctionCoeff = trim(cursor.collectDescendantText(false));
debtRemediationFunctionCoeff = nodeValue(cursor);

} else if (equalsIgnoreCase("debtSubCharacteristic", nodeName)) {
debtSubCharacteristic = trim(cursor.collectDescendantText(false));
debtSubCharacteristic = nodeValue(cursor);

} else if (equalsIgnoreCase("status", nodeName)) {
String s = trim(cursor.collectDescendantText(false));
String s = nodeValue(cursor);
if (s != null) {
status = RuleStatus.valueOf(s);
}
@@ -317,7 +317,7 @@ public class RulesDefinitionXmlLoader {
params.add(processParameter(cursor));

} else if (equalsIgnoreCase("tag", nodeName)) {
tags.add(trim(cursor.collectDescendantText(false)));
tags.add(nodeValue(cursor));
}
}

@@ -371,7 +371,12 @@ public class RulesDefinitionXmlLoader {
}
}

private static String nodeValue(SMInputCursor cursor) throws XMLStreamException {
return trim(cursor.collectDescendantText(false));
}

private static class ParamStruct {

String key;
String description;
String defaultValue;
@@ -396,7 +401,7 @@ public class RulesDefinitionXmlLoader {
SMInputCursor paramC = ruleC.childElementCursor();
while (paramC.getNext() != null) {
String propNodeName = paramC.getLocalName();
String propText = trim(paramC.collectDescendantText(false));
String propText = nodeValue(paramC);
if (equalsIgnoreCase("key", propNodeName)) {
param.key = propText;


Loading…
Cancel
Save