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 4669d9b commit 4d8cfe3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ private Object getJson(Map<String, List<MetricResult>> result) {
@Override
public void writeResult(Map<String, List<MetricResult>> result) throws IOException {
Object json = getJson(result);

this.outputWriter.write(json.toString());
this.outputWriter.write(json == null ? "" : json.toString());
this.outputWriter.newLine();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ public void yaml_failureScore() throws FileNotFoundException {
assertEquals(-1, schema.getPathByLabel("about").getRules().get(0).getFailureScore().intValue());
}

@Test
public void yaml_naScore() throws FileNotFoundException {
Schema schema = ConfigurationReader.readSchemaYaml("src/test/resources/configuration/schema/rules/naScore.yaml").asSchema();
assertEquals(-1, schema.getPathByLabel("about").getRules().get(0).getFailureScore().intValue());
assertEquals(0, schema.getPathByLabel("about").getRules().get(0).getNaScore().intValue());
assertEquals(1, schema.getPathByLabel("about").getRules().get(0).getSuccessScore().intValue());
}

@Test
public void yaml_debug() throws FileNotFoundException {
Schema schema = ConfigurationReader.readSchemaYaml("src/test/resources/configuration/schema/rules/debug.yaml").asSchema();
assertEquals(true, schema.getPathByLabel("about").getRules().get(0).getDebug());
}

@Test
public void yaml_successScore() throws FileNotFoundException {
Schema schema = ConfigurationReader.readSchemaYaml("src/test/resources/configuration/schema/rules/successScore.yaml").asSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import de.gwdg.metadataqa.api.configuration.ConfigurationReader;
import de.gwdg.metadataqa.api.configuration.MeasurementConfiguration;
import de.gwdg.metadataqa.api.rule.CheckerTestBase;
import de.gwdg.metadataqa.api.rule.RuleChecker;
import de.gwdg.metadataqa.api.schema.CsvAwareSchema;
import de.gwdg.metadataqa.api.schema.Schema;
import de.gwdg.metadataqa.api.util.CsvReader;
Expand Down
7 changes: 7 additions & 0 deletions src/test/resources/configuration/schema/rules/debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
format: json
fields:
- name: about
path: $.['about']
rules:
- minCount: 1
debug: true
9 changes: 9 additions & 0 deletions src/test/resources/configuration/schema/rules/naScore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: json
fields:
- name: about
path: $.['about']
rules:
- minCount: 1
failureScore: -1
naScore: 0
successScore: 1

0 comments on commit 4d8cfe3

Please sign in to comment.