diff --git a/importer/restructuredtext/src/main/java/org/itsallcode/openfasttrace/importer/restructuredtext/RestructuredTextImporter.java b/importer/restructuredtext/src/main/java/org/itsallcode/openfasttrace/importer/restructuredtext/RestructuredTextImporter.java index 4a7402b94..caeee4aa5 100644 --- a/importer/restructuredtext/src/main/java/org/itsallcode/openfasttrace/importer/restructuredtext/RestructuredTextImporter.java +++ b/importer/restructuredtext/src/main/java/org/itsallcode/openfasttrace/importer/restructuredtext/RestructuredTextImporter.java @@ -37,6 +37,7 @@ public class RestructuredTextImporter extends AbstractLightWeightMarkupImporter } @Override + @SuppressWarnings("java:S138") // Transition table is OK be larger than 75 lines. protected Transition[] configureTransitions() { // @formatter:off diff --git a/importer/specobject/src/main/java/org/itsallcode/openfasttrace/importer/specobject/handler/SpecDocumentHandlerBuilder.java b/importer/specobject/src/main/java/org/itsallcode/openfasttrace/importer/specobject/handler/SpecDocumentHandlerBuilder.java index 5e529db6f..888d0fe08 100644 --- a/importer/specobject/src/main/java/org/itsallcode/openfasttrace/importer/specobject/handler/SpecDocumentHandlerBuilder.java +++ b/importer/specobject/src/main/java/org/itsallcode/openfasttrace/importer/specobject/handler/SpecDocumentHandlerBuilder.java @@ -65,11 +65,9 @@ public TreeContentHandler build() throw new ImporterException("Element " + elem + " does not have an attribute '" + DOCTYPE_ATTRIBUTE_NAME + "' at " + elem.getLocation()); } - final String defaultDoctype = doctypeAttribute.getValue(); - this.handler.pushDelegate(new SpecObjectsHandlerBuilder(this.file, defaultDoctype, this.listener) - .build()); + this.handler.pushDelegate(new SpecObjectsHandlerBuilder(this.file, doctypeAttribute.getValue(), + this.listener).build()); }); - return this.handler; } } diff --git a/importer/xmlparser/src/main/java/org/itsallcode/openfasttrace/importer/xmlparser/tree/CallbackContentHandler.java b/importer/xmlparser/src/main/java/org/itsallcode/openfasttrace/importer/xmlparser/tree/CallbackContentHandler.java index da64563da..d2457e87a 100644 --- a/importer/xmlparser/src/main/java/org/itsallcode/openfasttrace/importer/xmlparser/tree/CallbackContentHandler.java +++ b/importer/xmlparser/src/main/java/org/itsallcode/openfasttrace/importer/xmlparser/tree/CallbackContentHandler.java @@ -117,6 +117,7 @@ public void init(final TreeParsingController treeParsingController) } @Override + @SuppressWarnings("java:S2221") // Intentionally catching all exceptions to provide better error messages. public void startElement(final TreeElement treeElement) { LOG.finest(() -> "Start element: " + treeElement); diff --git a/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/ImportAssertions.java b/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/ImportAssertions.java index b714f45d6..91b37e0ff 100644 --- a/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/ImportAssertions.java +++ b/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/ImportAssertions.java @@ -38,6 +38,7 @@ private ImportAssertions() * @param importerFactory * factory that generates the importer */ + @SuppressWarnings("java:S4968") // Match type definition comes from Hamcrest. Cannot change. public static void assertImportWithFactory(final Path path, final String input, final Matcher> matcher, final ImporterFactory importerFactory) diff --git a/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/lightweightmarkup/AbstractLightWeightMarkupImporterTest.java b/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/lightweightmarkup/AbstractLightWeightMarkupImporterTest.java index 2a3ef50c5..cca11c292 100644 --- a/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/lightweightmarkup/AbstractLightWeightMarkupImporterTest.java +++ b/testutil/src/main/java/org/itsallcode/openfasttrace/testutil/importer/lightweightmarkup/AbstractLightWeightMarkupImporterTest.java @@ -3,10 +3,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.itsallcode.matcher.auto.AutoMatcher.contains; -import static org.itsallcode.openfasttrace.api.core.SpecificationItemId.createId; import static org.itsallcode.openfasttrace.testutil.core.ItemBuilderFactory.item; -import static org.itsallcode.openfasttrace.testutil.importer.ImportAssertions.assertImportWithFactory; -import static org.itsallcode.openfasttrace.testutil.importer.ImportAssertions.runImporterOnText; import java.nio.file.Path; import java.util.List; @@ -16,6 +13,7 @@ import org.hamcrest.Matcher; import org.itsallcode.openfasttrace.api.core.*; import org.itsallcode.openfasttrace.api.importer.ImporterFactory; +import org.itsallcode.openfasttrace.testutil.importer.ImportAssertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.*; @@ -100,7 +98,7 @@ protected void assertImport(final String path, final String input, protected void assertImport(final Path path, final String input, final Matcher> matcher) { - assertImportWithFactory(path, processTextInput(input), matcher, getImporterFactory()); + ImportAssertions.assertImportWithFactory(path, processTextInput(input), matcher, getImporterFactory()); } private String processTextInput(final String input) @@ -236,7 +234,7 @@ static Stream tags() @MethodSource("tags") void testTags(final String mdContent, final List expected) { - final List items = runImporterOnText(Path.of("irrelevant-filename"), + final List items = ImportAssertions.runImporterOnText(Path.of("irrelevant-filename"), "`a~b~1`\n" + mdContent, getImporterFactory()); assertThat(items.get(0).getTags(), equalTo(expected)); @@ -538,7 +536,7 @@ static Stream needsCoverage() @MethodSource("needsCoverage") void testNeedsCoverage(final String mdContent, final List expected) { - final List items = runImporterOnText(Path.of("irrelevant-filename"), + final List items = ImportAssertions.runImporterOnText(Path.of("irrelevant-filename"), "`a~b~1`\n" + mdContent, getImporterFactory()); assertThat(items.get(0).getNeedsArtifactTypes(), equalTo(expected)); @@ -570,7 +568,7 @@ void testItemIdSupportsUTF8Characaters() Needs: arch """, contains(item() - .id(createId("req", "zellzustandsänderung", 1)) + .id(SpecificationItemId.createId("req", "zellzustandsänderung", 1)) .title("Die Implementierung muss den Zustand einzelner Zellen ändern") .description("Ermöglicht die Aktualisierung des Zustands von lebenden und toten Zellen" + " in jeder Generation.") @@ -591,12 +589,12 @@ void testHeaderBelongsToNextItem() `req~item2~1 Item 2 description """, - contains(item().id(createId("req", "item1", 1)) + contains(item().id(SpecificationItemId.createId("req", "item1", 1)) .title("Item 1") .description("Item 1 description") .location("file", 2 + titleLocationOffset) .build(), - item().id(createId("req", "item2", 1)) + item().id(SpecificationItemId.createId("req", "item2", 1)) .title("Item 2") .description("Item 2 description") .location("file", 6 + (2 * titleLocationOffset)) @@ -614,7 +612,7 @@ void testParsingNeedsIgnoresExtraListItems() { * this must not be in needs section """, contains(item() - .id(createId("feat", "the-feature", 1)) + .id(SpecificationItemId.createId("feat", "the-feature", 1)) .addNeedsArtifactType("arch") .description("* this must not be in needs section") .location("needs_with_extra_list_items.md", 1) @@ -638,12 +636,12 @@ void testNeedsAfterCovers() { Needs: itest """, contains(item() - .id(createId("dsn", "needs", 3)) + .id(SpecificationItemId.createId("dsn", "needs", 3)) .description("Description with a bulleted list" + System.lineSeparator() + System.lineSeparator() + "* this" + System.lineSeparator() + "* that") - .addCoveredId(createId("req", "needs", 2)) + .addCoveredId(SpecificationItemId.createId("req", "needs", 2)) .addNeedsArtifactType("itest") .location("needs_after_covers.md", 1) .build()));