From 527d8307c133100a3ca585589d590c598608ef07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Mon, 18 Apr 2016 17:25:39 +0200 Subject: [PATCH] Lint YAML files under test/ This commit extends YAML linting by enabling standard rules from the `yamllint` tool [1]. Since syntax errors and key duplicates are already checked since 4d48711, this change only adds detection for cosmetic problems. It also narrows checks to the test/ dir only. The main goal is to prevent future problems to enter the code base without being noticed. While it would be a huge effort to be PEP8 compliant, it is relatively easy to have correct YAML style *now* and prevent future errors by enabling linting. Note: for those (like me) caring about code attribution: use `git blame -w` to ignore whitespace-only changes. Note: I disabled some linting checks (such as indentation), they can be enforced in the future if needed. Similarly, current checks can also be disabled. See the `.yamllint` file. [1]: https://yamllint.readthedocs.io/ --- .yamllint | 17 +++++++---------- test/utils/shippable/code-smell.sh | 3 ++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.yamllint b/.yamllint index 764780d44a9..45d8b7adcff 100644 --- a/.yamllint +++ b/.yamllint @@ -1,22 +1,19 @@ extends: default -# Disable all cosmetic rules -# (see https://github.com/ansible/ansible/pull/15470#issuecomment-214437876) -# Only keep 'key-duplicates' and 'new-lines: {type: unix}' checks enabled. - rules: - braces: disable - brackets: disable - colons: disable - commas: disable + braces: {max-spaces-inside: 1, level: error} + brackets: {max-spaces-inside: 1, level: error} + colons: {max-spaces-after: -1, level: error} + commas: {max-spaces-after: -1, level: error} comments: disable comments-indentation: disable document-start: disable - empty-lines: disable - hyphens: disable + empty-lines: {max: 3, level: error} + hyphens: {level: error} indentation: disable key-duplicates: enable line-length: disable new-line-at-end-of-file: disable new-lines: {type: unix} trailing-spaces: disable + truthy: disable diff --git a/test/utils/shippable/code-smell.sh b/test/utils/shippable/code-smell.sh index dbcf81c7ba0..da66564bd67 100755 --- a/test/utils/shippable/code-smell.sh +++ b/test/utils/shippable/code-smell.sh @@ -15,7 +15,8 @@ if [ "${install_deps}" != "" ]; then pip list fi -yamllint . +yamllint ./test + test/sanity/code-smell/replace-urlopen.sh test/sanity/code-smell/use-compat-six.sh test/sanity/code-smell/boilerplate.sh