aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-04 14:25:21 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-04 14:26:32 +0100
commit9df8ed37f34ceb5d26045bf2d75a56b2fe80e172 (patch)
tree15b9d5a4d484ccc809f745a243fd7becf0a05166 /sonar-plugin-api
parent58d45c1b7a60280949d5a3da512cde645e19e1bc (diff)
downloadsonarqube-9df8ed37f34ceb5d26045bf2d75a56b2fe80e172.tar.gz
sonarqube-9df8ed37f34ceb5d26045bf2d75a56b2fe80e172.zip
Fix quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java39
3 files changed, 24 insertions, 19 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java
index 16b780739e7..4e88bc085cc 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileExporter.java
@@ -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;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
index afe3d17e748..d0eeb1ac824 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
@@ -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;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
index 8ecc91898dd..60e24c08174 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
@@ -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;