mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-25 00:44:42 +00:00
Make ansible-lint and yamllint use more strict rules.
This patch modifies configuration of both ansible-lint and yamllint to check for more rules, resulting in a more strict verification. For ansible-lint verification of errors 301, 305 and 505 are skipped, due to false positives. For the same reason, 'experimental' rules are skipped. ansible-lint error 306 is skipped since the fix is to set pipefail, which is not available in all shells (for example dash, which runs ansible-freeipa CI). Yamllint disabled rules (comments, and indentation) would introduce a huge amount of small changes, and are left for future changes, it deemed necessary.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
exclude_paths:
|
exclude_paths:
|
||||||
- .ansible-freeipa-tests/
|
- .ansible-freeipa-tests/
|
||||||
- .cache/
|
- .cache/
|
||||||
@@ -8,22 +9,21 @@ exclude_paths:
|
|||||||
- .yamllint
|
- .yamllint
|
||||||
- molecule/
|
- molecule/
|
||||||
- tests/azure/
|
- tests/azure/
|
||||||
|
- meta/runtime.yml
|
||||||
|
|
||||||
|
kinds:
|
||||||
|
- playbook: '**/tests/**/test_*.yml'
|
||||||
|
- playbook: '**/playbooks/**/*.yml'
|
||||||
|
|
||||||
parseable: true
|
parseable: true
|
||||||
|
|
||||||
quiet: false
|
quiet: false
|
||||||
|
|
||||||
skip_list:
|
skip_list:
|
||||||
- '201' # Trailing whitespace
|
|
||||||
- '204' # Lines should be no longer than 160 chars
|
|
||||||
- '206' # Variables should have spaces before and after: {{ var_name }}'
|
|
||||||
- '208' # File permissions not mentioned
|
|
||||||
- '301' # Commands should not change things if nothing needs doing'
|
- '301' # Commands should not change things if nothing needs doing'
|
||||||
- '305' # Use shell only when shell functionality is required'
|
- '305' # Use shell only when shell functionality is required
|
||||||
- '306' # Shells that use pipes should set the pipefail option'
|
- '306' # risky-shell-pipe
|
||||||
- '502' # All tasks should be named
|
- yaml # yamllint should be executed separately.
|
||||||
- '505' # Referenced missing file
|
|
||||||
|
|
||||||
use_default_rules: true
|
use_default_rules: true
|
||||||
|
|
||||||
|
|||||||
1
.github/workflows/lint.yml
vendored
1
.github/workflows/lint.yml
vendored
@@ -21,6 +21,7 @@ jobs:
|
|||||||
tests/*/*/*.yml
|
tests/*/*/*.yml
|
||||||
playbooks/*.yml
|
playbooks/*.yml
|
||||||
playbooks/*/*.yml
|
playbooks/*/*.yml
|
||||||
|
roles/*/*/*.yml
|
||||||
env:
|
env:
|
||||||
ANSIBLE_MODULE_UTILS: plugins/module_utils
|
ANSIBLE_MODULE_UTILS: plugins/module_utils
|
||||||
ANSIBLE_LIBRARY: plugins/modules
|
ANSIBLE_LIBRARY: plugins/modules
|
||||||
|
|||||||
@@ -16,13 +16,8 @@ rules:
|
|||||||
truthy:
|
truthy:
|
||||||
allowed-values: ["yes", "no", "true", "false", "True", "False"]
|
allowed-values: ["yes", "no", "true", "false", "True", "False"]
|
||||||
level: error
|
level: error
|
||||||
|
line-length:
|
||||||
|
max: 160
|
||||||
# Disabled rules
|
# Disabled rules
|
||||||
document-start: disable
|
|
||||||
indentation: disable
|
indentation: disable
|
||||||
line-length: disable
|
|
||||||
colons: disable
|
|
||||||
empty-lines: disable
|
|
||||||
comments: disable
|
comments: disable
|
||||||
comments-indentation: disable
|
|
||||||
trailing-spaces: disable
|
|
||||||
new-line-at-end-of-file: disable
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ data_files =
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
extend-ignore = E203, D1, D212, D203, D400, D401
|
extend-ignore = E203, D1, D212, D203, D400, D401
|
||||||
exclude = .git,__pycache__,.tox,.venv
|
exclude = .git,__pycache__,.tox,.venv,.cache,.ansible-freeipa-tests
|
||||||
per-file-ignores =
|
per-file-ignores =
|
||||||
plugins/*:E402
|
plugins/*:E402
|
||||||
roles/*:E402
|
roles/*:E402
|
||||||
|
|||||||
@@ -1,29 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
topdir="`dirname $(dirname $0)`"
|
INFO="\033[37;1m"
|
||||||
|
WARN="\033[33;1m"
|
||||||
|
RST="\033[0m"
|
||||||
|
|
||||||
flake8 .
|
pushd "`dirname $0`/.." >/dev/null 2>&1
|
||||||
pydocstyle .
|
|
||||||
pylint plugins
|
|
||||||
|
|
||||||
ANSIBLE_LIBRARY=${ANSIBLE_LIBRARY:-"${topdir}/plugins/modules"}
|
echo -e "${INFO}Running 'flake8'...${RST}"
|
||||||
ANSIBLE_MODULE_UTILS=${ANSIBLE_MODULE_UTILS:-"${topdir}/plugins/module_utils"}
|
flake8 plugins utils roles *.py
|
||||||
|
echo -e "${INFO}Running 'pydocstyle'...${RST}"
|
||||||
|
pydocstyle plugins utils roles *.py
|
||||||
|
echo -e "${INFO}Running 'pylint'...${RST}"
|
||||||
|
pylint plugins *.py
|
||||||
|
|
||||||
export ANSIBLE_LIBRARY ANSIBLE_MODULE_UTILS
|
ANSIBLE_LIBRARY="${ANSIBLE_LIBRARY:-plugins/modules}"
|
||||||
|
ANSIBLE_MODULE_UTILS="${ANSIBLE_MODULE_UTILS:-plugins/module_utils}"
|
||||||
|
ANSIBLE_DOC_FRAGMENT_PLUGINS="${ANSIBLE_DOC_FRAGMENT_PLUGINS:-plugins/doc_fragments}"
|
||||||
|
export ANSIBLE_LIBRARY ANSIBLE_MODULE_UTILS ANSIBLE_DOC_FRAGMENT_PLUGINS
|
||||||
|
|
||||||
yaml_dirs=(
|
echo -e "${WARN}Missing file warnings are expected and can be ignored.${RST}"
|
||||||
"${topdir}/tests"
|
echo -e "${INFO}Running 'ansible-lint'...${RST}"
|
||||||
"${topdir}/playbooks"
|
playbook_dirs=(
|
||||||
"${topdir}/molecule"
|
"tests"
|
||||||
|
"playbooks"
|
||||||
)
|
)
|
||||||
|
ansible-lint --force-color "${playbook_dirs[@]}"
|
||||||
|
|
||||||
for dir in "${yaml_dirs[@]}"
|
echo -e "${INFO}Running 'ansible-doc-test'...${RST}"
|
||||||
do
|
python "`dirname $0`/ansible-doc-test" -v roles plugins
|
||||||
find "${dir}" -type f -name "*.yml" | xargs ansible-lint --force-color
|
|
||||||
done
|
|
||||||
|
|
||||||
|
echo -e "${INFO}Running 'yamllint'...${RST}"
|
||||||
|
yaml_dirs=(
|
||||||
|
"tests"
|
||||||
|
"playbooks"
|
||||||
|
"molecule"
|
||||||
|
"roles"
|
||||||
|
)
|
||||||
|
yamllint -f colored "${yaml_dirs[@]}"
|
||||||
|
|
||||||
for dir in "${yaml_dirs[@]}"
|
popd >/dev/null 2>&1
|
||||||
do
|
|
||||||
find "${dir}" -type f -name "*.yml" | xargs yamllint
|
|
||||||
done
|
|
||||||
|
|||||||
Reference in New Issue
Block a user