aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-11-27 10:13:44 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-11-27 10:13:44 +0100
commitfd0ac42b099bf88748d6606735f2eea5c913ab0b (patch)
tree78b77763773054266869ebe8c33f6819bfc76a57
parent8a53eea50483ac9e31e73028ce707b26aa2e9632 (diff)
downloadsonarqube-fd0ac42b099bf88748d6606735f2eea5c913ab0b.tar.gz
sonarqube-fd0ac42b099bf88748d6606735f2eea5c913ab0b.zip
Fix quality flaws (sorry for previous commit)
-rw-r--r--server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java
index aad18588ed8..d28989fa656 100644
--- a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java
+++ b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java
@@ -19,7 +19,10 @@
*/
package org.sonar.search.script;
-import java.util.Objects;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.script.AbstractExecutableScript;
@@ -27,11 +30,6 @@ import org.elasticsearch.script.ExecutableScript;
import org.elasticsearch.script.NativeScriptFactory;
import org.sonar.process.ProcessProperties;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
public class ListUpdate extends AbstractExecutableScript {
public static class UpdateListScriptFactory implements NativeScriptFactory {
@@ -51,7 +49,7 @@ public class ListUpdate extends AbstractExecutableScript {
throw new IllegalStateException(String.format("Missing '%s' parameter", ProcessProperties.ES_PLUGIN_LISTUPDATE_FIELD));
}
- //NULL case is deletion of nested item
+ // NULL case is deletion of nested item
if (params.containsKey(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE)) {
Object obj = params.get(ProcessProperties.ES_PLUGIN_LISTUPDATE_VALUE);
if (obj != null) {
@@ -63,7 +61,6 @@ public class ListUpdate extends AbstractExecutableScript {
}
}
-
private final String idField;
private final String idValue;
private final String field;
@@ -92,10 +89,10 @@ public class ListUpdate extends AbstractExecutableScript {
@Override
public Object run() {
try {
- //Get the Document's source from ctx
+ // Get the Document's source from ctx
Map<String, Object> source = XContentMapValues.nodeMapValue(ctx.get("_source"), "source from context");
- //Get the Object for list update
+ // Get the Object for list update
Object fieldValue = source.get(field);
if (fieldValue == null && value != null) {
@@ -126,12 +123,11 @@ public class ListUpdate extends AbstractExecutableScript {
break;
}
}
- if (target != null && items != null) {
-
+ if (target != null) {
items.remove(target);
}
- //Supporting the update by NULL = deletion case
+ // Supporting the update by NULL = deletion case
if (value != null) {
items.add(value);
}