Description
Using ansible-review
version v0.14.0rc2
.
The output of ansible-review when you run the command in the pre-commit hook is different from yamllint
for example. I am not sure if there even is a standard output format for hooks, but I think there should be. This allows users of hooks to filter and do some grep work if they want.
In the least, I think the output in the pre-commit hook for ansible-review is really too "wordy" and hard to read. The yamllint format (seen below in my example) is easier to read and determine what file failed, what line in the file, and what problem it was. It's clearly broken into nice columns.
Additionally, the pre-commit output does not need to tell me if the vars/main.yml
does not declare a standards version. This seems like info I don't need to really know as a developer. I want to know the errors specifically.
Here is the example with my pre-commit hook using ansible-review
and yamllint
:
> git commit -m "Added some files to test linting"
ansible-review...........................................................Failed
hookid: ansible-review
WARN: RoleVars vars/main.yml is in a role that contains a meta/main.yml without a declared standards version. Using latest standards version 0.1
WARN: Best practice "YAML should be correctly indented" not met:
vars/main.yml:4: indentation should increase by 2 chars
WARN: Best practice "Vars should only occur once per file" not met:
vars/main.yml:3: Variable password occurs more than once
WARN: Best practice "Vars should only occur once per file" not met:
vars/main.yml:10: Variable password occurs more than once
WARN: Task tasks/main.yml is in a role that contains a meta/main.yml without a declared standards version. Using latest standards version 0.1
WARN: Best practice "Commands should be idempotent" not met:
tasks/main.yml:27: [301] Commands should not change things if nothing needs doing
WARN: Best practice "YAML should be correctly indented" not met:
tasks/main.yml:5: lines starting with '- ' should have same or less indentation than previous line (indent_list_items is False)
WARN: RoleVars vars/redhat.yml is in a role that contains a meta/main.yml without a declared standards version. Using latest standards version 0.1
WARN: Playbook .pre-commit-config.yaml does not present standards version. Using latest standards version 0.1
WARN: Best practice "YAML should be correctly indented" not met:
.pre-commit-config.yaml:4: lines starting with '- ' should have same or less indentation than previous line (indent_list_items is False)
WARN: Best practice "YAML should be correctly indented" not met:
.pre-commit-config.yaml:7: lines starting with '- ' should have same or less indentation than previous line (indent_list_items is False)
WARN: Best practice "YAML should be correctly indented" not met:
.pre-commit-config.yaml:15: lines starting with '- ' should have same or less indentation than previous line (indent_list_items is False)
WARN: Best practice "YAML should be correctly indented" not met:
.pre-commit-config.yaml:21: lines starting with '- ' should have same or less indentation than previous line (indent_list_items is False)
WARN: RoleVars vars/windows.yml is in a role that contains a meta/main.yml without a declared standards version. Using latest standards version 0.1
ERROR: Standard "Shell should only be used when essential" not met:
tasks/main.yml:27: [305] Use shell only when shell functionality is required
ERROR: Standard "Tasks and handlers must be named" not met:
tasks/main.yml:24: [502] All tasks should be named
ERROR: Standard "Tasks and handlers must be named" not met:
tasks/main.yml:27: [502] All tasks should be named
ERROR: Standard "Variable names should only use lowercase letters and underscore" not met:
tasks/main.yml:24: [CUSTOM0001] Variables must be named using only lowercase and underscores
yamllint.................................................................Failed
hookid: yamllint
vars/main.yml
10:1 error duplication of key "password" in mapping (key-duplicates)
12:1 error too many blank lines (1 > 0) (empty-lines)
tasks/main.yml
28:1 error too many blank lines (1 > 0) (empty-lines)
vars/windows.yml
2:81 error line too long (85 > 80 characters) (line-length)
Activity