From c4dace3d81d537a0b73d8ebd169c9d6407b46f35 Mon Sep 17 00:00:00 2001 From: zsandoz Date: Thu, 18 Aug 2022 07:52:02 +1000 Subject: [PATCH] 413 Checkstyle updates --- .../com/amihaiemil/eoyaml/ReadYamlSequence.java | 15 +++++++++++---- .../amihaiemil/eoyaml/SameIndentationLevel.java | 4 ++-- .../amihaiemil/eoyaml/ReadYamlSequenceTest.java | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java index 655a6a76..82c81702 100644 --- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java +++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java @@ -133,6 +133,10 @@ final class ReadYamlSequence extends BaseYamlSequence { this.guessIndentation = guessIndentation; } + /** + * Retrieve the values of this sequence. + * @checkstyle CyclomaticComplexity (200 lines) + */ @Override public Collection values() { final List kids = new LinkedList<>(); @@ -166,13 +170,16 @@ public Collection values() { ))); } else { if(this.mappingStartsAtDash(line)) { - final YamlLine previous = line.number() == 0 - ? new YamlLine.NullYamlLine() - : this.all.line(line.number() - 1); + YamlLine dashMapPrevious; + if (line.number() == 0) { + dashMapPrevious = new YamlLine.NullYamlLine(); + } else { + dashMapPrevious = this.all.line(line.number() - 1); + } kids.add( new ReadYamlMapping( line.number() + 1, - previous, + dashMapPrevious, this.all, this.guessIndentation ) diff --git a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java index bcbee909..e4db1cbb 100644 --- a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java +++ b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java @@ -77,11 +77,11 @@ public Iterator iterator() { final YamlLine first = iterator.next(); sameIndentation.add(first); int firstIndentation = first.indentation(); - boolean firstIsMappingStartsWithDash = + boolean firstIsDashMap = this.mappingStartsAtDash(first); while (iterator.hasNext()) { YamlLine current = iterator.next(); - if (firstIsMappingStartsWithDash + if (firstIsDashMap && this.mapping(current) && current.indentation() == firstIndentation + 2) { sameIndentation.add(current); diff --git a/src/test/java/com/amihaiemil/eoyaml/ReadYamlSequenceTest.java b/src/test/java/com/amihaiemil/eoyaml/ReadYamlSequenceTest.java index f2de27a8..7bf247ab 100644 --- a/src/test/java/com/amihaiemil/eoyaml/ReadYamlSequenceTest.java +++ b/src/test/java/com/amihaiemil/eoyaml/ReadYamlSequenceTest.java @@ -139,7 +139,8 @@ public void returnsYamlMappingWithScalarValuesStartingAtDash(){ /** * ReadYamlSequence can return the YamlMapping which starts right at the - * dash line and has only one entry + * dash line and has only one entry. + * @checkstyle ExecutableStatementCount (100 lines) */ @Test public void returnsShortYamlMappingWithScalarValuesStartingAtDash(){