diff --git a/README.md b/README.md index 0aba892..17f2a76 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,8 @@ yamlfixer currently (as of 0.9.6) can fix the following problems as reported by - syntax error: mapping values are not allowed here - too few spaces after comma (commas) - too few spaces before comment (comments) + - too few spaces inside empty brackets (brackets) + - too few spaces inside brackets - too many blank lines - too many spaces after colon (colons) - too many spaces after comma (commas) diff --git a/TODO.md b/TODO.md index 5a9a923..a91cac3 100644 --- a/TODO.md +++ b/TODO.md @@ -4,11 +4,10 @@ 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 - forbidden implicit octal value "%s" - forbidden explicit octal value "%s" +- forbidden flow sequence (brackets) - string value is not quoted with %s quotes - string value is not quoted - string value is redundantly quoted with %s quotes diff --git a/setup.cfg b/setup.cfg index 20d1eab..02d7f05 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [flake8] import-order-style = pep8 max-line-length = 120 -ignore = T101, W503, AAA01 +ignore = T100, T101, W503, AAA01 [pylint.FORMAT] max-line-length = 120 diff --git a/tests/test_listfixers.py b/tests/test_listfixers.py index f9cf74a..c4b48a3 100644 --- a/tests/test_listfixers.py +++ b/tests/test_listfixers.py @@ -50,6 +50,8 @@ def test_listfixers(self): - syntax error: mapping values are not allowed here - too few spaces after comma (commas) - too few spaces before comment (comments) + - too few spaces inside brackets (brackets) + - too few spaces inside empty brackets (brackets) - too many blank lines - too many spaces after colon (colons) - too many spaces after comma (commas) diff --git a/yamlfixer/problemfixer.py b/yamlfixer/problemfixer.py index a50adc0..b37d3bb 100755 --- a/yamlfixer/problemfixer.py +++ b/yamlfixer/problemfixer.py @@ -116,6 +116,7 @@ def fix_newlineateof(self, left, right): # pylint: disable=unused-argument,no-s """ # noqa: D205, D208, D400 # We simply ignore it, because we always add \n when dumping # and rely on universal newlines to handle them correctly. + # FIXME : doesn't work when transcoding files for another OS. def fix_truthy(self, left, right): """Fix: @@ -136,6 +137,7 @@ def fix_toofew_spacesbefore(self, left, right): """Fix: - too few spaces before comment (comments) """ # noqa: D205, D208, D400 + # TODO : read correct value from yamllint's config spaces = ' ' if left[-1] != ' ': spaces += ' ' @@ -172,9 +174,13 @@ def fix_missingspace(self, left, right): """Fix: - missing starting space in comment (comments) - too few spaces after comma (commas) + - too few spaces inside brackets (brackets) + - too few spaces inside empty brackets (brackets) """ # noqa: D205, D208, D400 - self.ffixer.lines[self.linenum] = left + ' ' + right - self.ffixer.coffset += 1 + # TODO : read correct value from yamllint's config + spaces = ' ' + self.ffixer.lines[self.linenum] = left + spaces + right + self.ffixer.coffset += len(spaces) def fix_toomany_spacesafter(self, left, right): """Fix: @@ -182,6 +188,7 @@ def fix_toomany_spacesafter(self, left, right): - too many spaces after comma (commas) - too many spaces after hyphen (hyphens) """ # noqa: D205, D208, D400 + # TODO : read correct value from yamllint's config pos = self.colnum while (pos > 0) and (left[pos - 1] == ' '): pos -= 1 @@ -196,6 +203,7 @@ def fix_toomany_spacesother(self, left, right): - too many spaces before comma (commas) - too many spaces before colon (colons) """ # noqa: D205, D208, D400 + # TODO : read correct value from yamllint's config pos = self.colnum while (pos > 0) and (left[pos - 1] == ' '): pos -= 1