From c7105c9b3c2cce569a2db6eaf0279161f45bd313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Alet?= Date: Wed, 4 May 2022 13:13:02 +1100 Subject: [PATCH] Added support for 'found forbidden document start|end'. --- README.md | 4 +++- TODO.md | 18 ++++++++---------- tests/test_listfixers.py | 2 ++ yamlfixer/problemfixer.py | 8 ++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bd7e0dd..0aba892 100644 --- a/README.md +++ b/README.md @@ -164,9 +164,11 @@ This GitHub Action will automatically create Pull Requests to your repository wi # Fixers -yamlfixer currently (as of 0.6.4) can fix the following problems as reported by `yamllint` : +yamlfixer currently (as of 0.9.6) can fix the following problems as reported by `yamllint` : - comment not indented like content (comments-indentation) + - found forbidden document end + - found forbidden document start - line too long - missing document end - missing document start diff --git a/TODO.md b/TODO.md index bdef7dd..5a9a923 100644 --- a/TODO.md +++ b/TODO.md @@ -4,13 +4,11 @@ Here's a list of problems reported by yamllint which are not currently supported by yamlfixer, but which might be supported in a future release : -* too few spaces inside brackets -* too few spaces inside empty brackets -* too many spaces after question mark -* found forbidden document end "..." -* found forbidden document start "---" -* forbidden implicit octal value "%s" -* forbidden explicit octal value "%s" -* string value is not quoted with %s quotes -* string value is not quoted -* string value is redundantly quoted with %s quotes +- too few spaces inside brackets +- too few spaces inside empty brackets +- too many spaces after question mark +- forbidden implicit octal value "%s" +- forbidden explicit octal value "%s" +- string value is not quoted with %s quotes +- string value is not quoted +- string value is redundantly quoted with %s quotes diff --git a/tests/test_listfixers.py b/tests/test_listfixers.py index 177345a..f9cf74a 100644 --- a/tests/test_listfixers.py +++ b/tests/test_listfixers.py @@ -35,6 +35,8 @@ def test_listfixers(self): """\ Fixers: - comment not indented like content (comments-indentation) + - found forbidden document end + - found forbidden document start - line too long - missing document end - missing document start diff --git a/yamlfixer/problemfixer.py b/yamlfixer/problemfixer.py index 4dcae93..a50adc0 100755 --- a/yamlfixer/problemfixer.py +++ b/yamlfixer/problemfixer.py @@ -100,6 +100,14 @@ def fix_missing_docend(self, left, right): # pylint: disable=unused-argument self.ffixer.lines.insert(self.linenum + 1, '...') self.ffixer.loffset += 1 + def fix_forbidden_docstartend(self, left, right): # pylint: disable=unused-argument + """Fix: + - found forbidden document end + - found forbidden document start + """ # noqa: D205, D208, D400 + del self.ffixer.lines[self.linenum] + self.ffixer.loffset -= 1 + def fix_newlineateof(self, left, right): # pylint: disable=unused-argument,no-self-use r"""Fix: - no new line character at the end of file