From 3cbff9d0015a8bc27a2b7bcbf5cf7e600b2a5206 Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Thu, 10 Aug 2023 13:03:36 +0530 Subject: [PATCH 1/2] Document yaml[line-length] rule --- src/ansiblelint/rules/yaml.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ansiblelint/rules/yaml.md b/src/ansiblelint/rules/yaml.md index 8dc56eb879..fe4d8bafd7 100644 --- a/src/ansiblelint/rules/yaml.md +++ b/src/ansiblelint/rules/yaml.md @@ -53,6 +53,7 @@ Some of the detailed error codes that you might see are: - `yaml[empty-lines]` - _too many blank lines (...> ...)_ - `yaml[indentation]` - _Wrong indentation: expected ... but found ..._ - `yaml[key-duplicates]` - _Duplication of key "..." in mapping_ +- `yaml[line-length]` - _Line too long (... > ... characters)_ - `yaml[new-line-at-end-of-file]` - _No new line character at the end of file_ - `yaml[octal-values]`: forbidden implicit or explicit [octal](#octals) value - `yaml[syntax]` - YAML syntax is broken @@ -72,6 +73,11 @@ for it does check these. If for some reason, you do not want to follow our defaults, you can create a `.yamllint` file in your project and this will take precedence over our defaults. +## Additional Information + +Adhering to yaml[line-length] rule, for writing multiline strings we recommend using Block Style Indicator: literal style indicated by a pipe (|) or folded style indicated by a right angle bracket (>), instead of escaping the newlines with backslashes. +Reference [guide] for writing multiple line strings in yaml. + ## Problematic code ```yaml @@ -95,3 +101,4 @@ bar: ... # Correct comment indentation. [1.2.0]: https://yaml.org/spec/1.2.0/ [1.2.2]: https://yaml.org/spec/1.2.2/ [yaml specification]: https://yaml.org/ +[guide]: https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html#yaml-basics From 75c9d37f1832bc090c1c97eb6822e6694a34f533 Mon Sep 17 00:00:00 2001 From: shatakshiiii Date: Thu, 10 Aug 2023 13:57:26 +0530 Subject: [PATCH 2/2] Update doc --- src/ansiblelint/rules/yaml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansiblelint/rules/yaml.md b/src/ansiblelint/rules/yaml.md index fe4d8bafd7..60461bb61c 100644 --- a/src/ansiblelint/rules/yaml.md +++ b/src/ansiblelint/rules/yaml.md @@ -73,7 +73,7 @@ for it does check these. If for some reason, you do not want to follow our defaults, you can create a `.yamllint` file in your project and this will take precedence over our defaults. -## Additional Information +## Additional Information for Multiline Strings Adhering to yaml[line-length] rule, for writing multiline strings we recommend using Block Style Indicator: literal style indicated by a pipe (|) or folded style indicated by a right angle bracket (>), instead of escaping the newlines with backslashes. Reference [guide] for writing multiple line strings in yaml.