Skip to content

Commit

Permalink
Avoid false positive with var-naming[no-role-prefix] (#3550)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jun 12, 2023
1 parent 519ecd6 commit 29248a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/test_collection/roles/my_role/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
name: example.test_collection.my_role2
vars:
my_role2_foo: something

- name: Task 2
# this task should NOT trigger var-naming[no-role-prefix]
vars:
foo: bar
ansible.builtin.debug:
msg: "{{ foo }}"
2 changes: 2 additions & 0 deletions src/ansiblelint/rules/var_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def matchtask(
if isinstance(action, dict):
role_fqcn = action.get("name", "")
prefix = role_fqcn.split("/" if "/" in role_fqcn else ".")[-1]
else:
prefix = ""
for key in our_vars:
match_error = self.get_var_naming_matcherror(key, prefix=prefix)
if match_error:
Expand Down

0 comments on commit 29248a4

Please sign in to comment.