Repository: decorators-squad/eo-yaml
Pull request #534 (2022-11-26 13:38:47)

#532 remove guessIndentation logic and parameters (incl public params)
PR for #532 

Removed guessIndentation logic and parameters (incl. public parameters);
Bugfix in WellIndented related to >| inner indentation (ignore indentation when we are within a folded or literal block scalar).


Patch:
diff --git a/README.md b/README.md
index 8beb3f5..666c111 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,6 @@ Here is what we have so far:
 * Building and Reading YAML Streams, integrated with Java 8's Stream API ([wiki](https://github.com/decorators-squad/eo-yaml/wiki/YAML-Streams));
 * Java Beans to YAML ([wiki](https://github.com/decorators-squad/eo-yaml/wiki/Java-Bean-To-YAML));
 * Others:
-    - Automatic validation of the input's indentation ([wiki](https://github.com/decorators-squad/eo-yaml/wiki/Validation-of-Indentation)).
     - Clear and detailed Exceptions. For instance, in the case of bad indentation, it will tell you exactly which line is problematic and why.
     - Fully encapsulated. The user works only with a few Java Interfaces.
     - All objects are immutable and thread-safe.
diff --git a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
index 2b3001c..37b83c2 100644
--- a/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
+++ b/src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
@@ -104,26 +104,21 @@ final class AllYamlLines implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
+    public YamlNode toYamlNode(final YamlLine prev) {
         final YamlNode node;
         final String prevLine = prev.trimmed();
         if(prevLine.isEmpty()) {
-            node = this.mappingSequenceOrPlainScalar(prev, guessIndentation);
+            node = this.mappingSequenceOrPlainScalar(prev);
         } else {
             final String lastChar = prevLine.substring(prevLine.length() - 1);
             if (prevLine.matches(Follows.FOLDED_SEQUENCE)) {
-                node = new ReadYamlSequence(prev, this, guessIndentation);
+                node = new ReadYamlSequence(prev, this);
             } else if (lastChar.equals(Follows.LITERAL_BLOCK_SCALAR)) {
                 node = new ReadLiteralBlockScalar(prev, this);
             } else if (lastChar.equals(Follows.FOLDED_BLOCK_SCALAR)) {
                 node = new ReadFoldedBlockScalar(prev, this);
             } else {
-                node = this.mappingSequenceOrPlainScalar(
-                    prev, guessIndentation
-                );
+                node = this.mappingSequenceOrPlainScalar(prev);
             }
         }
         return node;
@@ -138,17 +133,12 @@ final class AllYamlLines implements YamlLines {
      * Try to figure out what YAML node (mapping, sequence or scalar) is found
      * after the given line.
      * @param prev YamlLine just previous to the node we're trying to find.
-     * @param guessIndentation If true, we will guess the correct indentation,
-     *  if any YAML line is misplaced.
      * @return Found YamlNode.
      * @todo #529:60min Implement, test and use Edited YamlLine here.
      *  A YamlLine to which we append some text and it keeps the indentation,
      *  number etc of the original line.
      */
-    private YamlNode mappingSequenceOrPlainScalar(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
+    private YamlNode mappingSequenceOrPlainScalar(final YamlLine prev) {
         YamlNode node = null;
         final Iterator<YamlLine> nodeLines = new Skip(
             this,
@@ -178,10 +168,9 @@ final class AllYamlLines implements YamlLines {
             Matcher matcher = SEQUENCE_OR_MAP.matcher(first.trimmed());
             if (matcher.matches()) {
                 if (matcher.group(2) != null) {
-                    node = new ReadYamlSequence(prev, this, guessIndentation);
+                    node = new ReadYamlSequence(prev, this);
                 } else if (matcher.group(4) != null) {
-                    node = new ReadYamlMapping(prev.number(),
-                        prev, this, guessIndentation);
+                    node = new ReadYamlMapping(prev.number(), prev, this);
                 }
             } else if (this.original().size() == 1) {
                 node = new ReadPlainScalar(this, first);
diff --git a/src/main/java/com/amihaiemil/eoyaml/Backwards.java b/src/main/java/com/amihaiemil/eoyaml/Backwards.java
index 02d2695..cb174ed 100644
--- a/src/main/java/com/amihaiemil/eoyaml/Backwards.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Backwards.java
@@ -56,11 +56,8 @@ final class Backwards implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
-        return this.lines.toYamlNode(prev, guessIndentation);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.lines.toYamlNode(prev);
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java b/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java
index 25922d6..dbb2cfe 100644
--- a/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java
+++ b/src/main/java/com/amihaiemil/eoyaml/FirstCommentFound.java
@@ -94,11 +94,8 @@ final class FirstCommentFound implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
-        return this.lines.toYamlNode(prev, guessIndentation);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.lines.toYamlNode(prev);
     }
 
     /**
diff --git a/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java b/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java
index 107b69b..f4d667a 100644
--- a/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java
+++ b/src/main/java/com/amihaiemil/eoyaml/GreaterIndentation.java
@@ -96,10 +96,7 @@ final class GreaterIndentation implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
-        return this.yamlLines.toYamlNode(prev, guessIndentation);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.yamlLines.toYamlNode(prev);
     }
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java
index 7af9515..1fe61a5 100644
--- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java
+++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlMapping.java
@@ -82,12 +82,6 @@ final class ReadYamlMapping extends BaseYamlMapping {
      */
     private final YamlLines significant;
 
-    /**
-     * If set to true we will try to guess the correct indentation
-     * of misplaced lines.
-     */
-    private final boolean guessIndentation;
-
     /**
      * Where to stop looking for comments.
      */
@@ -98,21 +92,7 @@ final class ReadYamlMapping extends BaseYamlMapping {
      * @param lines Given lines.
      */
     ReadYamlMapping(final AllYamlLines lines) {
-        this(lines, Boolean.FALSE);
-    }
-
-    /**
-     * Ctor.
-     * @param lines Given lines.
-     * @param guessIndentation If true, we will try to guess the correct
-     *  indentation of misplaced lines.
-     */
-    ReadYamlMapping(
-        final AllYamlLines lines,
-        final boolean guessIndentation
-    ) {
-        this(UNKNOWN_LINE_NUMBER, new YamlLine.NullYamlLine(), lines,
-            guessIndentation);
+        this(UNKNOWN_LINE_NUMBER, new YamlLine.NullYamlLine(), lines);
     }
 
     /**
@@ -121,14 +101,11 @@ final class ReadYamlMapping extends BaseYamlMapping {
      * @param commentStop Where to
      * @param previous Line just before the start of this mapping.
      * @param lines Given lines.
-     * @param guessIndentation If true, we will try to guess the correct
-     *  indentation of misplaced lines.
      */
     ReadYamlMapping(
         final int commentStop,
         final YamlLine previous,
-        final AllYamlLines lines,
-        final boolean guessIndentation
+        final AllYamlLines lines
     ) {
         this.commentStop = commentStop;
         this.previous = previous;
@@ -144,10 +121,9 @@ final class ReadYamlMapping extends BaseYamlMapping {
                     line -> line.trimmed().startsWith("%"),
                     line -> line.trimmed().startsWith("!!")
                 ),
-                guessIndentation
+                Boolean.FALSE
             )
         );
-        this.guessIndentation = guessIndentation;
     }
 
     @Override
@@ -162,9 +138,7 @@ final class ReadYamlMapping extends BaseYamlMapping {
             ) {
                 continue;
             } else if ("?".equals(trimmed)) {
-                keys.add(
-                    this.significant.toYamlNode(line, this.guessIndentation)
-                );
+                keys.add(this.significant.toYamlNode(line));
             } else {
                 if(!trimmed.contains(":")) {
                     continue;
@@ -251,21 +225,17 @@ final class ReadYamlMapping extends BaseYamlMapping {
                     || trimmed.matches("^" + Pattern.quote(relaxedKey) + ":[ ]*>$")
                     || trimmed.matches("^" + Pattern.quote(relaxedKey) + ":[ ]*\\|[+-]?$")
                 ) {
-                    value = this.significant.toYamlNode(
-                        line, this.guessIndentation
-                    );
+                    value = this.significant.toYamlNode(line);
                 } else if (trimmed.matches(relaxedKey + ":[ ]*\\{}")) {
                     value = new EmptyYamlMapping(new ReadYamlMapping(
-                            line.number(),
-                            this.all.line(line.number()),
-                            this.all,
-                            this.guessIndentation
+                        line.number(),
+                        this.all.line(line.number()),
+                        this.all
                     ));
                 } else if (trimmed.matches(relaxedKey + ":[ ]*\\[]")) {
                     value = new EmptyYamlSequence(new ReadYamlSequence(
                             this.all.line(line.number()),
-                            this.all,
-                            this.guessIndentation
+                            this.all
                     ));
                 } else if((trimmed.startsWith(tryKey + ":")
                         || trimmed.startsWith("- " + tryKey + ":"))
@@ -316,18 +286,14 @@ final class ReadYamlMapping extends BaseYamlMapping {
             final YamlLine line = linesIt.next();
             final String trimmed = line.trimmed();
             if("?".equals(trimmed)) {
-                final YamlNode keyNode = this.significant.toYamlNode(
-                    line, this.guessIndentation
-                );
+                final YamlNode keyNode = this.significant.toYamlNode(line);
                 if(keyNode.equals(key)) {
                     final YamlLine colonLine = linesIt.next();
                     if(":".equals(colonLine.trimmed())
                         || colonLine.trimmed().matches("^\\:[ ]*\\>$")
                         || colonLine.trimmed().matches("^\\:[ ]*\\|$")
                     ) {
-                        value = this.significant.toYamlNode(
-                            colonLine, this.guessIndentation
-                        );
+                        value = this.significant.toYamlNode(colonLine);
                     } else if(colonLine.trimmed().startsWith(":")
                         && (colonLine.trimmed().length() > 1)
                     ){
diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java
index 50d7d34..72a529e 100644
--- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java
+++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlSequence.java
@@ -66,31 +66,12 @@ final class ReadYamlSequence extends BaseYamlSequence {
      */
     private final YamlLines significant;
 
-    /**
-     * If set to true we will try to guess the correct indentation
-     * of misplaced lines.
-     */
-    private final boolean guessIndentation;
-
     /**
      * Ctor.
      * @param lines Given lines.
      */
     ReadYamlSequence(final AllYamlLines lines) {
-        this(lines, false);
-    }
-
-    /**
-     * Ctor.
-     * @param lines Given lines.
-     * @param guessIndentation If set to true, we will try to
-     *  guess the correct indentation of misplaced lines.
-     */
-    ReadYamlSequence(
-        final AllYamlLines lines,
-        final boolean guessIndentation
-    ) {
-        this(new YamlLine.NullYamlLine(), lines, guessIndentation);
+        this(new YamlLine.NullYamlLine(), lines);
     }
 
     /**
@@ -99,21 +80,6 @@ final class ReadYamlSequence extends BaseYamlSequence {
      * @param lines Given lines.
      */
     ReadYamlSequence(final YamlLine previous, final AllYamlLines lines) {
-        this(previous, lines, false);
-    }
-
-    /**
-     * Ctor.
-     * @param previous Line just before the start of this sequence.
-     * @param lines Given lines.
-     * @param guessIndentation If set to true, we will try to guess the
-     *  correct indentation of misplaced lines.
-     */
-    ReadYamlSequence(
-        final YamlLine previous,
-        final AllYamlLines lines,
-        final boolean guessIndentation
-    ) {
         this.previous = previous;
         this.all = lines;
         this.significant = new SameIndentationLevel(
@@ -127,10 +93,9 @@ final class ReadYamlSequence extends BaseYamlSequence {
                     line -> line.trimmed().startsWith("%"),
                     line -> line.trimmed().startsWith("!!")
                 ),
-                guessIndentation
+                Boolean.FALSE
             )
         );
-        this.guessIndentation = guessIndentation;
     }
 
     /**
@@ -150,23 +115,17 @@ final class ReadYamlSequence extends BaseYamlSequence {
                     || trimmed.endsWith("|")
                     || trimmed.endsWith(">")
                 ) {
-                    kids.add(
-                            this.significant.toYamlNode(
-                                    line, this.guessIndentation
-                            )
-                    );
+                    kids.add(this.significant.toYamlNode(line));
                 } else if (trimmed.matches("^-[ ]*\\{}")) {
                     kids.add(new EmptyYamlMapping(new ReadYamlMapping(
-                            line.number(),
-                            this.all.line(line.number()),
-                            this.all,
-                            this.guessIndentation
+                        line.number(),
+                        this.all.line(line.number()),
+                        this.all
                     )));
                 } else if (trimmed.matches("^-[ ]*\\[]")) {
                     kids.add(new EmptyYamlSequence(new ReadYamlSequence(
                             this.all.line(line.number()),
-                            this.all,
-                            this.guessIndentation
+                            this.all
                     )));
                 } else {
                     if(this.mappingStartsAtDash(line)) {
@@ -180,8 +139,7 @@ final class ReadYamlSequence extends BaseYamlSequence {
                             new ReadYamlMapping(
                                 line.number() + 1,
                                 dashMapPrevious,
-                                this.all,
-                                this.guessIndentation
+                                this.all
                             )
                         );
                     } else {
diff --git a/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java b/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java
index 6d2995d..1165e66 100644
--- a/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java
+++ b/src/main/java/com/amihaiemil/eoyaml/ReadYamlStream.java
@@ -49,27 +49,11 @@ final class ReadYamlStream extends BaseYamlStream {
      */
     private final YamlLines startMarkers;
 
-    /**
-     * If set to true we will try to guess the correct indentation
-     * of misplaced lines.
-     */
-    private final boolean guessIndentation;
-
     /**
      * Constructor.
      * @param lines All YAML lines as they are read from the input.
      */
     ReadYamlStream(final AllYamlLines lines) {
-        this(lines, false);
-    }
-
-    /**
-     * Constructor.
-     * @param lines All YAML lines as they are read from the input.
-     * @param guessIndentation If set to true, we will try to guess
-     *  the correct indentation of misplaced lines.
-     */
-    ReadYamlStream(final AllYamlLines lines, final boolean guessIndentation) {
         this.startMarkers = new WellIndented(
             new StartMarkers(
                 new Skip(
@@ -83,7 +67,6 @@ final class ReadYamlStream extends BaseYamlStream {
             lines,
             line -> line.trimmed().startsWith("%")
         );
-        this.guessIndentation = guessIndentation;
     }
 
     @Override
@@ -93,9 +76,7 @@ final class ReadYamlStream extends BaseYamlStream {
             final YamlLines document = this.readDocument(startDoc);
             if(!document.original().isEmpty()) {
                 values.add(
-                    document.toYamlNode(
-                        startDoc, this.guessIndentation
-                    )
+                    document.toYamlNode(startDoc)
                 );
             }
         }
diff --git a/src/main/java/com/amihaiemil/eoyaml/RtYamlInput.java b/src/main/java/com/amihaiemil/eoyaml/RtYamlInput.java
index 1bdbd81..3ab322f 100644
--- a/src/main/java/com/amihaiemil/eoyaml/RtYamlInput.java
+++ b/src/main/java/com/amihaiemil/eoyaml/RtYamlInput.java
@@ -49,44 +49,27 @@ final class RtYamlInput implements YamlInput {
      */
     private final InputStream source;
 
-    /**
-     * If set to true, we will try to guess the correct indentation
-     * of misplaced lines.
-     */
-    private final boolean guessIndentation;
-
     /**
      * Ctor.
      * @param source Given source.
      */
     RtYamlInput(final InputStream source) {
-        this(source, false);
-    }
-
-    /**
-     * Ctor.
-     * @param source Given source.
-     * @param guessIndentation If set to true, we will try to guess
-     *  the correct indentation of misplaced lines.
-     */
-    RtYamlInput(final InputStream source, final boolean guessIndentation) {
         this.source = source;
-        this.guessIndentation = guessIndentation;
     }
 
     @Override
     public YamlMapping readYamlMapping() throws IOException {
-        return new ReadYamlMapping(this.readInput(), this.guessIndentation);
+        return new ReadYamlMapping(this.readInput());
     }
 
     @Override
     public YamlSequence readYamlSequence() throws IOException {
-        return new ReadYamlSequence(this.readInput(), this.guessIndentation);
+        return new ReadYamlSequence(this.readInput());
     }
 
     @Override
     public YamlStream readYamlStream() throws IOException {
-        return new ReadYamlStream(this.readInput(), this.guessIndentation);
+        return new ReadYamlStream(this.readInput());
     }
 
     @Override
diff --git a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java
index a554892..291bb8b 100644
--- a/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java
+++ b/src/main/java/com/amihaiemil/eoyaml/SameIndentationLevel.java
@@ -101,11 +101,8 @@ final class SameIndentationLevel implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
-        return this.yamlLines.toYamlNode(prev, guessIndentation);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.yamlLines.toYamlNode(prev);
     }
 
     /**
diff --git a/src/main/java/com/amihaiemil/eoyaml/Skip.java b/src/main/java/com/amihaiemil/eoyaml/Skip.java
index 660ac13..f5d243e 100644
--- a/src/main/java/com/amihaiemil/eoyaml/Skip.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Skip.java
@@ -94,11 +94,8 @@ final class Skip implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
-        return this.yamlLines.toYamlNode(prev, guessIndentation);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.yamlLines.toYamlNode(prev);
     }
 
     /**
diff --git a/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java b/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java
index 9a31687..386e4cb 100644
--- a/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java
+++ b/src/main/java/com/amihaiemil/eoyaml/StartMarkers.java
@@ -103,10 +103,7 @@ final class StartMarkers implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndentation
-    ) {
-        return this.yamlLines.toYamlNode(prev, guessIndentation);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.yamlLines.toYamlNode(prev);
     }
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
index a4d24ce..363994d 100644
--- a/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
+++ b/src/main/java/com/amihaiemil/eoyaml/WellIndented.java
@@ -104,30 +104,33 @@ final class WellIndented implements YamlLines {
      * correct.
      * @checkstyle LineLength (50 lines)
      * @return Iterator over these yaml lines.
-     * @todo #529:60min Remove the guessIndentation logic. It doesn't make
-     *  sense anymore and it's too unpredictible.
      */
     @Override
     public Iterator<YamlLine> iterator() {
         final Iterator<YamlLine> iterator = this.yamlLines.iterator();
         final List<YamlLine> wellIndented = new ArrayList<>();
         YamlLine previous;
+        boolean withinBlockScalar = false;
         if(iterator.hasNext()) {
             previous = iterator.next();
             wellIndented.add(previous);
             while(iterator.hasNext()) {
                 YamlLine line = iterator.next();
                 if(!(previous instanceof YamlLine.NullYamlLine)) {
+                    final CharSequence prevLineLastChar =
+                        previous.trimmed().substring(previous.trimmed().length() - 1);
+                    if(">|".contains(prevLineLastChar)) {
+                        withinBlockScalar = true;
+                    }
                     int prevIndent = previous.indentation();
                     if(previous.trimmed().matches("^\\s*-.*:(|\\s.*)$")) {
+                        withinBlockScalar = false;
                         prevIndent += 2;
                     }
-                    int lineIndent = line.indentation();
-                    if(previous.requireNestedIndentation()) {
-                        if(lineIndent < prevIndent + 2) {
-                            if (this.guessIndentation) {
-                                line = new Indented(line, prevIndent + 2);
-                            } else {
+                    if(!withinBlockScalar) {
+                        int lineIndent = line.indentation();
+                        if (previous.requireNestedIndentation()) {
+                            if (lineIndent < prevIndent + 2) {
                                 throw new YamlIndentationException(
                                     "Indentation of line " + (line.number() + 1)
                                     + " [" + line.trimmed() + "]"
@@ -137,22 +140,16 @@ final class WellIndented implements YamlLines {
                                     + " by at least 2 spaces."
                                 );
                             }
-                        }
-                    } else {
-                        if(!"---".equals(previous.trimmed()) && lineIndent > prevIndent) {
-                            final CharSequence prevLineLastChar =
-                                previous.trimmed().substring(previous.trimmed().length() - 1);
-                            if (!">|:".contains(prevLineLastChar)) {
-                                if (this.guessIndentation) {
-                                    line = new Indented(line, prevIndent);
-                                } else {
+                        } else {
+                            if (!"---".equals(previous.trimmed()) && lineIndent > prevIndent) {
+                                if (!":".contains(prevLineLastChar)) {
                                     throw new YamlIndentationException(
                                         "Indentation of line " + (line.number() + 1)
-                                            + " [" + line.trimmed() + "]"
-                                            + " is greater than the one of line "
-                                            + (previous.number() + 1)
-                                            + " [" + previous.trimmed() + "]. "
-                                            + "It should be less or equal."
+                                        + " [" + line.trimmed() + "]"
+                                        + " is greater than the one of line "
+                                        + (previous.number() + 1)
+                                        + " [" + previous.trimmed() + "]. "
+                                        + "It should be less or equal."
                                     );
                                 }
                             }
@@ -172,11 +169,8 @@ final class WellIndented implements YamlLines {
     }
 
     @Override
-    public YamlNode toYamlNode(
-        final YamlLine prev,
-        final boolean guessIndent
-    ) {
-        return this.yamlLines.toYamlNode(prev, guessIndent);
+    public YamlNode toYamlNode(final YamlLine prev) {
+        return this.yamlLines.toYamlNode(prev);
     }
 
 }
diff --git a/src/main/java/com/amihaiemil/eoyaml/Yaml.java b/src/main/java/com/amihaiemil/eoyaml/Yaml.java
index 2745a9d..e8bd9f2 100644
--- a/src/main/java/com/amihaiemil/eoyaml/Yaml.java
+++ b/src/main/java/com/amihaiemil/eoyaml/Yaml.java
@@ -97,31 +97,13 @@ public final class Yaml {
     /**
      * Create a {@link YamlInput} from a File.
      * @return YamlInput, reader of Yaml.
-     * @param input File to read from.
-     * @throws FileNotFoundException If the file is not found.
-     */
-    public static YamlInput createYamlInput(final File input)
-        throws FileNotFoundException {
-        return Yaml.createYamlInput(input, Boolean.FALSE);
-    }
-
-    /**
-     * Create a {@link YamlInput} from a File.
-     * @return YamlInput, reader of Yaml.
-     * @param input File to read from.
-     * @param guessIndentation If set to true, we will try to guess the correct
-     *  indentation of misplaced lines. The default value is false
-     *  and an exception is thrown if indentation is not correct.
+     * @param input File to read from
      * @throws FileNotFoundException If the file is not found.
      */
     public static YamlInput createYamlInput(
-        final File input,
-        final boolean guessIndentation
+        final File input
     ) throws FileNotFoundException {
-        return Yaml.createYamlInput(
-            new FileInputStream(input),
-            guessIndentation
-        );
+        return Yaml.createYamlInput(new FileInputStream(input));
     }
 
     /**
@@ -130,25 +112,7 @@ public final class Yaml {
      * @return YamlInput, reader of Yaml.
      */
     public static YamlInput createYamlInput(final String input) {
-        return Yaml.createYamlInput(input, Boolean.FALSE);
-    }
-
-    /**
-     * Create a {@link YamlInput} from a String.
-     * @param input String to read from.
-     * @param guessIndentation If set to true, we will try to guess the correct
-     *  indentation of misplaced lines. The default value is false
-     *  and an exception is thrown if indentation is not correct.
-     * @return YamlInput, reader of Yaml.
-     */
-    public static YamlInput createYamlInput(
-        final String input,
-        final boolean guessIndentation
-    ) {
-        return Yaml.createYamlInput(
-            new ByteArrayInputStream(input.getBytes()),
-            guessIndentation
-        );
+        return Yaml.createYamlInput(new ByteArrayInputStream(input.getBytes()));
     }
 
     /**
@@ -157,22 +121,7 @@ public final class Yaml {
      * @return YamlInput, reader of Yaml.
      */
     public static YamlInput createYamlInput(final InputStream input) {
-        return Yaml.createYamlInput(input, Boolean.FALSE);
-    }
-
-    /**
-     * Create a {@link YamlInput} from an InputStream.
-     * @param input InputStream to read from.
-     * @param guessIndentation If set to true, we will try to guess the correct
-     *  indentation of misplaced lines. The default value is false
-     *  and an exception is thrown if indentation is not correct.
-     * @return YamlInput, reader of Yaml.
-     */
-    public static YamlInput createYamlInput(
-        final InputStream input,
-        final boolean guessIndentation
-    ) {
-        return new RtYamlInput(input, guessIndentation);
+        return new RtYamlInput(input);
     }
 
     /**
diff --git a/src/main/java/com/amihaiemil/eoyaml/YamlLines.java b/src/main/java/com/amihaiemil/eoyaml/YamlLines.java
index 3ca17cb..f6c7736 100644
--- a/src/main/java/com/amihaiemil/eoyaml/YamlLines.java
+++ b/src/main/java/com/amihaiemil/eoyaml/YamlLines.java
@@ -50,11 +50,9 @@ interface YamlLines extends Iterable<YamlLine> {
     /**
      * Turn these lines into a YamlNode.
      * @param prev Previous YamlLine
-     * @param guessIndentation If set to true, we will try to guess
-     *  the correct indentation of misplaced lines.
      * @return YamlNode
      */
-    YamlNode toYamlNode(final YamlLine prev, final boolean guessIndentation);
+    YamlNode toYamlNode(final YamlLine prev);
 
     /**
      * Default iterator which doesn't skip any line,


Test patch:
diff --git a/src/test/java/com/amihaiemil/eoyaml/AllYamlLinesTest.java b/src/test/java/com/amihaiemil/eoyaml/AllYamlLinesTest.java
index 08def79..d5d00d1 100644
--- a/src/test/java/com/amihaiemil/eoyaml/AllYamlLinesTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/AllYamlLinesTest.java
@@ -80,8 +80,7 @@ public final class AllYamlLinesTest {
         final YamlLines yamlLines = new AllYamlLines(lines);
         MatcherAssert.assertThat(
             yamlLines.toYamlNode(
-                new RtYamlLine("literalScalar:|", 0),
-                false
+                new RtYamlLine("literalScalar:|", 0)
             ),
             Matchers.instanceOf(ReadLiteralBlockScalar.class)
         );
@@ -100,8 +99,7 @@ public final class AllYamlLinesTest {
         final YamlLines yamlLines = new AllYamlLines(lines);
         MatcherAssert.assertThat(
             yamlLines.toYamlNode(
-                new RtYamlLine("foldedScalar:>", 0),
-                false
+                new RtYamlLine("foldedScalar:>", 0)
             ),
             Matchers.instanceOf(ReadFoldedBlockScalar.class)
         );
@@ -119,7 +117,7 @@ public final class AllYamlLinesTest {
         lines.add(new RtYamlLine("value3", 3));
         final YamlLines yamlLines = new AllYamlLines(lines);
         final YamlNode seq =  yamlLines.toYamlNode(
-            new RtYamlLine("foldedSequence:|-", 0), false
+            new RtYamlLine("foldedSequence:|-", 0)
         );
         MatcherAssert.assertThat(
             seq, Matchers.instanceOf(ReadYamlSequence.class)
@@ -156,7 +154,7 @@ public final class AllYamlLinesTest {
         lines.add(new RtYamlLine("value3", 3));
         final YamlLines yamlLines = new AllYamlLines(lines);
         final YamlNode seq =  yamlLines.toYamlNode(
-            new RtYamlLine("foldedSequence:| -", 0), false
+            new RtYamlLine("foldedSequence:| -", 0)
         );
         MatcherAssert.assertThat(
             seq, Matchers.instanceOf(ReadYamlSequence.class)
@@ -189,7 +187,9 @@ public final class AllYamlLinesTest {
         final List<YamlLine> lines = new ArrayList<>();
         lines.add(new RtYamlLine("arn:something:something", 1));
         final YamlLines yamlLines = new AllYamlLines(lines);
-        YamlNode actual = yamlLines.toYamlNode(new RtYamlLine("---", 0), false);
+        YamlNode actual = yamlLines.toYamlNode(
+            new RtYamlLine("---", 0)
+        );
         MatcherAssert.assertThat(
                 actual,
                 Matchers.instanceOf(Scalar.class)
@@ -209,7 +209,9 @@ public final class AllYamlLinesTest {
         final List<YamlLine> lines = new ArrayList<>();
         lines.add(new RtYamlLine("-foo", 1));
         final YamlLines yamlLines = new AllYamlLines(lines);
-        YamlNode actual = yamlLines.toYamlNode(new RtYamlLine("---", 0), false);
+        YamlNode actual = yamlLines.toYamlNode(
+            new RtYamlLine("---", 0)
+        );
         MatcherAssert.assertThat(
                 actual,
                 Matchers.instanceOf(Scalar.class)
@@ -230,7 +232,9 @@ public final class AllYamlLinesTest {
         lines.add(new RtYamlLine("some: mapping", 1));
         lines.add(new RtYamlLine("for: test", 2));
         final YamlLines yamlLines = new AllYamlLines(lines);
-        YamlNode actual = yamlLines.toYamlNode(new RtYamlLine("---", 0), false);
+        YamlNode actual = yamlLines.toYamlNode(
+            new RtYamlLine("---", 0)
+        );
         MatcherAssert.assertThat(
                 actual,
                 Matchers.instanceOf(ReadYamlMapping.class)
@@ -248,7 +252,7 @@ public final class AllYamlLinesTest {
         lines.add(new RtYamlLine("- sequence", 2));
         final YamlLines yamlLines = new AllYamlLines(lines);
         MatcherAssert.assertThat(
-            yamlLines.toYamlNode(new RtYamlLine("?", 0), false),
+            yamlLines.toYamlNode(new RtYamlLine("?", 0)),
             Matchers.instanceOf(ReadYamlSequence.class)
         );
     }
@@ -263,7 +267,7 @@ public final class AllYamlLinesTest {
         lines.add(new RtYamlLine("justAScalar", 1));
         final YamlLines yamlLines = new AllYamlLines(lines);
         MatcherAssert.assertThat(
-            yamlLines.toYamlNode(new RtYamlLine("---", 0), false),
+            yamlLines.toYamlNode(new RtYamlLine("---", 0)),
             Matchers.instanceOf(ReadPlainScalar.class)
         );
     }
@@ -284,7 +288,7 @@ public final class AllYamlLinesTest {
         lines.add(new RtYamlLine("a folded or literal scalar", 4));
         final YamlLines yamlLines = new AllYamlLines(lines);
         try {
-            yamlLines.toYamlNode(new RtYamlLine("---", -1), false);
+            yamlLines.toYamlNode(new RtYamlLine("---", -1));
             Assert.fail("Expected IllegalStateException!");
         } catch (final YamlReadingException ex) {
             final String message = ex.getMessage();
diff --git a/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java b/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java
index 717ea66..5fc605f 100644
--- a/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/BackwardsTest.java
@@ -67,9 +67,9 @@ public final class BackwardsTest {
         final YamlLines initial = Mockito.mock(YamlLines.class);
         final YamlLine prev = Mockito.mock(YamlLine.class);
         final YamlNode node = Mockito.mock(YamlNode.class);
-        Mockito.when(initial.toYamlNode(prev, false)).thenReturn(node);
+        Mockito.when(initial.toYamlNode(prev)).thenReturn(node);
         MatcherAssert.assertThat(
-            new Backwards(initial).toYamlNode(prev, false),
+            new Backwards(initial).toYamlNode(prev),
             Matchers.is(node)
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java b/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java
index 618d927..1d96985 100644
--- a/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/FirstCommentFoundTest.java
@@ -66,9 +66,9 @@ public final class FirstCommentFoundTest {
         final YamlLines initial = Mockito.mock(YamlLines.class);
         final YamlLine prev = Mockito.mock(YamlLine.class);
         final YamlNode node = Mockito.mock(YamlNode.class);
-        Mockito.when(initial.toYamlNode(prev, false)).thenReturn(node);
+        Mockito.when(initial.toYamlNode(prev)).thenReturn(node);
         MatcherAssert.assertThat(
-            new FirstCommentFound(initial).toYamlNode(prev, false),
+            new FirstCommentFound(initial).toYamlNode(prev),
             Matchers.is(node)
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/ReadLiteralBlockScalarTest.java b/src/test/java/com/amihaiemil/eoyaml/ReadLiteralBlockScalarTest.java
index f12284f..8efbf02 100644
--- a/src/test/java/com/amihaiemil/eoyaml/ReadLiteralBlockScalarTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/ReadLiteralBlockScalarTest.java
@@ -222,7 +222,7 @@ public final class ReadLiteralBlockScalarTest {
     public void printsLiteralBlockScalarFromString() throws IOException {
         final String input = readTestResource("issue_480_bug_printing.yml");
 
-        YamlMapping mapping = Yaml.createYamlInput(input, true)
+        YamlMapping mapping = Yaml.createYamlInput(input)
             .readYamlMapping();
         MatcherAssert.assertThat(
             mapping.string("test1"),
diff --git a/src/test/java/com/amihaiemil/eoyaml/ReadYamlMappingTest.java b/src/test/java/com/amihaiemil/eoyaml/ReadYamlMappingTest.java
index 268f098..638df79 100644
--- a/src/test/java/com/amihaiemil/eoyaml/ReadYamlMappingTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/ReadYamlMappingTest.java
@@ -1197,9 +1197,7 @@ public final class ReadYamlMappingTest {
         lines.add(new RtYamlLine("key: | ", 0));
         lines.add(new RtYamlLine("  line1", 1));
         lines.add(new RtYamlLine("    line2", 2));
-        final YamlMapping map = new ReadYamlMapping(
-            new AllYamlLines(lines), Boolean.TRUE
-        );
+        final YamlMapping map = new ReadYamlMapping(new AllYamlLines(lines));
         final Collection<String> literalLines = map.literalBlockScalar("key");
         MatcherAssert.assertThat(
             literalLines.size(),
diff --git a/src/test/java/com/amihaiemil/eoyaml/SkipTest.java b/src/test/java/com/amihaiemil/eoyaml/SkipTest.java
index f85ab79..13f54dd 100644
--- a/src/test/java/com/amihaiemil/eoyaml/SkipTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/SkipTest.java
@@ -167,9 +167,9 @@ public final class SkipTest {
         final YamlLines initial = Mockito.mock(YamlLines.class);
         final YamlLine prev = Mockito.mock(YamlLine.class);
         final YamlNode node = Mockito.mock(YamlNode.class);
-        Mockito.when(initial.toYamlNode(prev, false)).thenReturn(node);
+        Mockito.when(initial.toYamlNode(prev)).thenReturn(node);
         MatcherAssert.assertThat(
-            new Skip(initial).toYamlNode(prev, false),
+            new Skip(initial).toYamlNode(prev),
             Matchers.is(node)
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java b/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java
index 2d1c904..c7e2009 100644
--- a/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/StartMarkersTest.java
@@ -68,9 +68,9 @@ public final class StartMarkersTest {
         final YamlLines lines = Mockito.mock(YamlLines.class);
         final YamlLine prev = Mockito.mock(YamlLine.class);
         final YamlNode result = Mockito.mock(YamlNode.class);
-        Mockito.when(lines.toYamlNode(prev, false)).thenReturn(result);
+        Mockito.when(lines.toYamlNode(prev)).thenReturn(result);
         MatcherAssert.assertThat(
-            new StartMarkers(lines).toYamlNode(prev, false),
+            new StartMarkers(lines).toYamlNode(prev),
             Matchers.is(result)
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java b/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java
index 35b6bea..9d61a6d 100644
--- a/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java
+++ b/src/test/java/com/amihaiemil/eoyaml/WellIndentedTest.java
@@ -70,9 +70,9 @@ public final class WellIndentedTest {
         final YamlLines lines = Mockito.mock(YamlLines.class);
         final YamlLine prev = Mockito.mock(YamlLine.class);
         final YamlNode result = Mockito.mock(YamlNode.class);
-        Mockito.when(lines.toYamlNode(prev, false)).thenReturn(result);
+        Mockito.when(lines.toYamlNode(prev)).thenReturn(result);
         MatcherAssert.assertThat(
-            new WellIndented(lines).toYamlNode(prev, false),
+            new WellIndented(lines).toYamlNode(prev),
             Matchers.is(result)
         );
     }
diff --git a/src/test/java/com/amihaiemil/eoyaml/YamlIndentationTestCase.java b/src/test/java/com/amihaiemil/eoyaml/YamlIndentationTestCase.java
index ab9fb7c..cfd9919 100644
--- a/src/test/java/com/amihaiemil/eoyaml/YamlIndentationTestCase.java
+++ b/src/test/java/com/amihaiemil/eoyaml/YamlIndentationTestCase.java
@@ -85,8 +85,7 @@ public final class YamlIndentationTestCase {
     @Test
     public void readsBadlyIndentedMappingWithEmptyKey() throws Exception {
         final YamlMapping map = Yaml.createYamlInput(
-            new File("src/test/resources/badMappingIndentation.yml"),
-            Boolean.FALSE
+            new File("src/test/resources/badMappingIndentation.yml")
         ).readYamlMapping();
         System.out.println(map);
         MatcherAssert.assertThat(
@@ -132,7 +131,7 @@ public final class YamlIndentationTestCase {
             lines.add(new RtYamlLine("value3", 3));
             final YamlLines yamlLines = new AllYamlLines(lines);
             final YamlNode seq = yamlLines.toYamlNode(
-                    new RtYamlLine("foldedSequence:|-", 0), false);
+                    new RtYamlLine("foldedSequence:|-", 0));
             final Collection<YamlNode> values = ((YamlSequence) seq).values();
             Assert.fail("badlyIntendedSequenceThrowsException "
                     + "should have thrown YamlIndentationException");