-
Notifications
You must be signed in to change notification settings - Fork 640
/
var-spacing.yml
87 lines (83 loc) · 2.94 KB
/
var-spacing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
# Should raise var-spacing at tasks line 23, 26, 29, 54, 65
- hosts: all
tasks:
- name: good variable format
ansible.builtin.debug:
msg: "{{ good_format }}"
- name: good variable format
ansible.builtin.debug:
msg: "Value: {{ good_format }}"
- name: good variable filter format
ansible.builtin.debug:
msg: "{{ good_format | filter }}"
- name: good variable filter format
ansible.builtin.debug:
msg: "Value: {{ good_format | filter }}"
- name: jinja escaping allowed
ansible.builtin.debug:
msg: "{{ '{{' }}"
- name: jinja escaping allowed
# noqa: 306
ansible.builtin.shell: docker info --format '{{ '{{' }}json .Swarm.LocalNodeState{{ '}}' }}' | tr -d '"'
changed_when: false
- name: jinja whitespace control allowed
ansible.builtin.debug:
msg: |
{{ good_format }}/
{{- good_format }}
{{- good_format -}}
- name: bad variable format
ansible.builtin.debug:
msg: "{{bad_format}}"
- name: bad variable format
ansible.builtin.debug:
msg: "Value: {{ bad_format}}"
- name: bad variable format
ansible.builtin.debug:
msg: "{{bad_format }}"
- name: bad variable filter format
ansible.builtin.debug:
msg: "{{ bad_format|filter }}"
- name: bad variable filter format
ansible.builtin.debug:
msg: "Value: {{ bad_format |filter }}"
- name: bad variable filter format
ansible.builtin.debug:
msg: "{{ bad_format| filter }}"
- name: not a jinja variable # noqa var-spacing
ansible.builtin.debug:
# spell-checker: disable-next-line
msg: data = ${lookup{$local_part}lsearch{/etc/aliases}}
- name: JSON inside jinja is valid
ansible.builtin.debug:
msg: "{{ {'test': {'subtest': variable}} }}"
- name: Avoid false positive on multiline
vars:
cases:
case1: >-
http://example.com/{{
case1 }}
case2: >-
http://example.com/{{
case2 }}
ansible.builtin.debug:
var: cases
- name: Valid single line nested JSON false positive
ansible.builtin.debug:
msg: "{{ {'dummy_2': {'nested_dummy_1': 'value_1', 'nested_dummy_2': value_2}} | combine(dummy_1) }}"
- name: Invalid single line nested JSON
ansible.builtin.debug:
msg: "{{ {'dummy_2': {'nested_dummy_1': 'value_1', 'nested_dummy_2': value_2}} | combine(dummy_1)}}"
- name: Valid multiline nested JSON false positive
ansible.builtin.debug:
msg: >-
{{ {'dummy_2': {'nested_dummy_1': value_1,
'nested_dummy_2': value_2}} |
combine(dummy_1) }}
- name: Invalid multiline nested JSON
ansible.builtin.debug:
msg: >-
{{ {'dummy_2': {'nested_dummy_1': value_1,
'nested_dummy_2': value_2}} |
combine(dummy_1)}}