Skip to content

Commit

Permalink
Implement SonarCloud quality suggestions #159
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 8, 2023
1 parent 99526c1 commit 92fb2e6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ public MeasurementConfiguration withAnnotationColumns(String jsonString) {
ObjectMapper mapper = new ObjectMapper();
annottaionColumns = new LinkedHashMap<>();
try {
Map<String, Object> map = (Map<String, Object>) mapper.readValue(jsonString, Map.class);
Map<String, Object> map = mapper.readValue(jsonString, Map.class);
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object value = entry.getValue();
if (value instanceof String || value instanceof Integer || value instanceof Double)
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/de/gwdg/metadataqa/api/json/DataElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import de.gwdg.metadataqa.api.configuration.schema.Rule;
import de.gwdg.metadataqa.api.model.Category;
import de.gwdg.metadataqa.api.rule.singlefieldchecker.MinCountChecker;
import de.gwdg.metadataqa.api.schema.Format;
import de.gwdg.metadataqa.api.schema.Schema;
import org.apache.commons.lang3.SerializationUtils;
Expand Down Expand Up @@ -254,12 +253,12 @@ public String toString() {
}

public static DataElement copy(DataElement other) throws CloneNotSupportedException {
DataElement cloned = (DataElement) SerializationUtils.clone(other);
DataElement cloned = SerializationUtils.clone(other);

if (other.children != null && !other.children.isEmpty()) {
List<DataElement> clonedChildren = new ArrayList<>();
for (DataElement child : other.children) {
DataElement clonedChild = (DataElement) SerializationUtils.clone(child);
DataElement clonedChild = SerializationUtils.clone(child);
clonedChild.parent = cloned;
clonedChildren.add(clonedChild);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package de.gwdg.metadataqa.api.model.selector;

import de.gwdg.metadataqa.api.model.XmlFieldInstance;
import de.gwdg.metadataqa.api.model.selector.CsvSelector;
import de.gwdg.metadataqa.api.model.selector.JsonSelector;
import de.gwdg.metadataqa.api.model.selector.Selector;
import de.gwdg.metadataqa.api.model.selector.XmlSelector;
import de.gwdg.metadataqa.api.schema.Format;

import java.util.Map;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/gwdg/metadataqa/api/util/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public static Integer asInteger(Object value) {
intValue = (Integer) value;
break;
case "java.lang.Double":
intValue = (Integer) ((Long) Math.round((Double) value)).intValue();
intValue = ((Long) Math.round((Double) value)).intValue();
break;
case "java.lang.Long":
intValue = (Integer) ((Long) value).intValue();
intValue = ((Long) value).intValue();
break;
case "java.lang.Float":
intValue = (Integer) Math.round((float)value);
intValue = Math.round((float)value);
break;
case "java.lang.String":
intValue = asInteger(Double.parseDouble((String)value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ public void testExistenceMap() throws URISyntaxException, IOException {
if (existing)
existingFieldCounter++;
assertEquals(14, existingFieldCounter);
}

@Test
public void testExistenceMap_2() throws URISyntaxException, IOException {
calculator.collectFields(true);
calculator.measure(cache);
Map<String, Boolean> existenceMap = calculator.getExistenceMap();

assertTrue(existenceMap.get("edm:ProvidedCHO/@about"));
assertTrue(existenceMap.get("Proxy/dc:title"));
Expand Down

0 comments on commit 92fb2e6

Please sign in to comment.