From bca01387134532cb9474907a26f087b93deed669 Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 5 Jul 2026 08:40:23 +0200 Subject: [PATCH 1/6] 536: Reduced number of lines in lambda in SpecDocumentHandlerBuilder to improve readability. --- .../specobject/handler/SpecDocumentHandlerBuilder.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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; } } From 0b68a2ac4c7febb78c3bb41beae81ea37fda3208 Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 5 Jul 2026 08:46:48 +0200 Subject: [PATCH 2/6] 536: Reduced number of static imports to four in `AbstractLightWeightMarkupImporterTest`. --- ...AbstractLightWeightMarkupImporterTest.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) 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())); From 8aab4cb3561af4a188d74938d708eccfb6c02276 Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 5 Jul 2026 14:11:45 +0200 Subject: [PATCH 3/6] 536: Allowed longer method for state transition table. --- .../importer/restructuredtext/RestructuredTextImporter.java | 1 + 1 file changed, 1 insertion(+) 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 From 8d2d1db90f2efd2efda336fd93b0ef0bf584aa4e Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 5 Jul 2026 14:12:56 +0200 Subject: [PATCH 4/6] 536: Allow wildcard generic. --- .../openfasttrace/testutil/importer/ImportAssertions.java | 1 + 1 file changed, 1 insertion(+) 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) From 8a34a6b0c2288231f6d667776ec676cdd71368c2 Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 5 Jul 2026 14:16:12 +0200 Subject: [PATCH 5/6] 536: Suppress warning about catching exceptions. --- .../importer/xmlparser/tree/CallbackContentHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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..19e4687c8 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); @@ -140,8 +141,8 @@ public void startElement(final TreeElement treeElement) } catch (final Exception exception) { - throw new XmlParserException("Error handling " + treeElement + " with consumer " - + consumer + ": " + exception.getMessage(), exception); + throw new XmlParserException("Error handling '" + treeElement + "' with consumer '" + + consumer + "': " + exception.getMessage(), exception); } } From b7838cfd8db421904b6f2171d997639d12bb705e Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 5 Jul 2026 14:28:58 +0200 Subject: [PATCH 6/6] 536: Removed superfluous quoting marks. --- .../importer/xmlparser/tree/CallbackContentHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 19e4687c8..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 @@ -141,8 +141,8 @@ public void startElement(final TreeElement treeElement) } catch (final Exception exception) { - throw new XmlParserException("Error handling '" + treeElement + "' with consumer '" - + consumer + "': " + exception.getMessage(), exception); + throw new XmlParserException("Error handling " + treeElement + " with consumer " + + consumer + ": " + exception.getMessage(), exception); } }