跳至内容

no-tabs

此规则检查制表符字符。\t 制表符字符可能导致意外的显示或格式问题。应始终使用空格代替制表符。

注意

此规则不会针对`ansible.builtin.lineinfile` 模块中的制表符字符触发警报。

问题代码

---
- name: Example playbook
  hosts: all
  tasks:
    - name: Do not trigger the rule
      ansible.builtin.lineinfile:
        path: some.txt
        regexp: '^\t$'
        line: 'string with \t inside'
    - name: Trigger the rule with a debug message
      ansible.builtin.debug:
        msg: "Using the \t character can cause formatting issues." # <- Includes the tab character.

正确代码

---
- name: Example playbook
  hosts: all
  tasks:
    - name: Do not trigger the no-tabs rule
      ansible.builtin.debug:
        msg: "Using space characters avoids formatting issues."