Skip to content

Commit

Permalink
Remove duplicate deprecated-command-syntax rule (#3119)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Mar 3, 2023
1 parent e29560c commit aade575
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 168 deletions.
1 change: 0 additions & 1 deletion .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ firewalld
fontawesome
formatstr
formetting
formsyntax
fqcn
fqrn
fulltoc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 809
PYTEST_REQPASS: 808
steps:
- name: Activate WSL1
if: "contains(matrix.shell, 'wsl')"
Expand Down
3 changes: 1 addition & 2 deletions docs/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ and formatting. It extends [min](#min) profile.
- [command-instead-of-module](rules/command-instead-of-module.md)
- [command-instead-of-shell](rules/command-instead-of-shell.md)
- [deprecated-bare-vars](rules/deprecated-bare-vars.md)
- [deprecated-command-syntax](rules/deprecated-command-syntax.md)
- [deprecated-local-action](rules/deprecated-local-action.md)
- [deprecated-module](rules/deprecated-module.md)
- [inline-env-var](rules/inline-env-var.md)
- [key-order](rules/key-order.md)
- [literal-compare](rules/literal-compare.md)
- [jinja](rules/jinja.md)
- [no-free-form](https://github.com/ansible/ansible-lint/issues/2117)
- [no-jinja-when](rules/no-jinja-when.md)
- [no-tabs](rules/no-tabs.md)
- [partial-become](rules/partial-become.md)
Expand All @@ -56,7 +56,6 @@ content easier to read and maintain. It extends [basic](#basic) profile.
- [name[template]](rules/name.md)
- [name[imperative]](https://github.com/ansible/ansible-lint/issues/2170)
- [name[casing]](rules/name.md)
- [no-free-form](https://github.com/ansible/ansible-lint/issues/2117)
- [spell-var-name](https://github.com/ansible/ansible-lint/issues/2168)

## safety
Expand Down
3 changes: 3 additions & 0 deletions docs/redirects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- type: page
from_url: /rules/hg-latest/
to_url: /rules/latest/
- type: page
from_url: /rules/deprecated-command-syntax/
to_url: /rules/no-free-form/
- type: page
from_url: /default_rules/index/
to_url: /rules/
Expand Down
1 change: 0 additions & 1 deletion docs/rules/deprecated-command-syntax.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- [command-instead-of-module][]
- [command-instead-of-shell][]
- [deprecated-bare-vars][]
- [deprecated-command-syntax][]
- [deprecated-local-action][]
- [deprecated-module][]
- [empty-string-compare][]
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ a task, which does not skip line-based rules. You can use the
_command_ or _shell_ modules, for example:

```yaml
- name: This would typically fire deprecated-command-syntax
- name: This would typically fire no-free-form
command: warn=no chmod 644 X
- name: This would typically fire command-instead-of-module
Expand Down
7 changes: 7 additions & 0 deletions examples/playbooks/rule-deprecated-command-syntax.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Fixture
hosts: localhost
tasks:
- name: Shell with pipe
ansible.builtin.command: creates=/tmp/foo touch /tmp/foo
changed_when: false
4 changes: 2 additions & 2 deletions examples/playbooks/skiptasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ansible.builtin.command: git log
changed_when: false

- name: Test deprecated-command-syntax
- name: Test no-free-form
ansible.builtin.command: creates=B chmod 644 A

- name: Test latest[git] (skip)
Expand All @@ -30,7 +30,7 @@
tags:
- skip_ansible_lint

- name: Test deprecated-command-syntax (skip)
- name: Test no-free-form (skip)
ansible.builtin.command: chmod 644 A
tags:
- skip_ansible_lint
Expand Down
32 changes: 23 additions & 9 deletions examples/playbooks/test_skip_inside_yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,30 @@
tags:
- skip_ansible_lint # should disable error at playbook level
tasks:
- name: Test # <-- 0 latest[hg]
action: ansible.builtin.hg # noqa: fqcn[canonical]
- name: Test latest[hg] (skipped) # noqa: latest[hg] fqcn[canonical]
action: ansible.builtin.hg
- name: Test
action: community.general.hg
args:
repo: foo
version: HEAD

- name: Test latest[git] and partial-become
- name: Test latest[hg] (skipped)
action: community.general.hg
args:
repo: foo
# revision: HEAD

- name: Test latest[git] and partial-become # noqa: latest[git]
action: ansible.builtin.git
args:
repo: foo
version: HEAD
become_user: alice

- name: Test latest[git] and partial-become (skipped) # noqa: latest[git] partial-become
action: ansible.builtin.git
args:
repo: foo
version: HEAD
become_user: alice

- name: Test YAML # <-- 1 jinja[spacing]
Expand All @@ -27,13 +41,13 @@
url: http://example.com/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/file.conf # noqa: yaml[line-length]
dest: "{{dest_proj_path}}/foo.conf" # noqa: jinja[spacing]

- name: Test deprecated-command-syntax # <-- 3 deprecated-command-syntax
- name: Test no-free-form # <-- 3 no-free-form
ansible.builtin.command: creates=B chmod 644 A # noqa: no-free-form
- name: Test deprecated-command-syntax # <-- 4 deprecated-command-syntax
- name: Test no-free-form # <-- 4 no-free-form
ansible.builtin.command: warn=yes creates=B chmod 644 A # noqa: no-free-form
- name: Test deprecated-command-syntax (skipped via no warn)
- name: Test no-free-form (skipped via no warn)
ansible.builtin.command: warn=no creates=B chmod 644 A # noqa: no-free-form
- name: Test deprecated-command-syntax (skipped via skip_ansible_lint)
- name: Test no-free-form (skipped via skip_ansible_lint)
ansible.builtin.command: creates=B chmod 644 A # noqa: no-free-form
tags:
- skip_ansible_lint
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ nav:
- rules/command-instead-of-module.md
- rules/command-instead-of-shell.md
- rules/deprecated-bare-vars.md
- rules/deprecated-command-syntax.md
- rules/deprecated-local-action.md
- rules/deprecated-module.md
- rules/empty-string-compare.md
Expand Down
7 changes: 4 additions & 3 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ def main():
"703": "meta-incorrect",
"704": "meta-video-links",
"911": "syntax-check",
"var-spacing": "jinja[spacing]",
"unnamed-task": "name[missing]",
"deprecated-command-syntax": "no-free-form",
"fqcn-builtins": "fqcn[action-core]",
"git-latest": "latest[git]",
"hg-latest": "latest[hg]",
"no-jinja-nesting": "jinja[invalid]",
"no-loop-var-prefix": "loop-var-prefix",
"fqcn-builtins": "fqcn[action-core]",
"unnamed-task": "name[missing]",
"var-spacing": "jinja[spacing]",
}

PLAYBOOK_TASK_KEYWORDS = [
Expand Down
5 changes: 2 additions & 3 deletions src/ansiblelint/data/profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ basic:
command-instead-of-module:
command-instead-of-shell:
deprecated-bare-vars:
deprecated-command-syntax:
deprecated-local-action:
deprecated-module:
inline-env-var:
key-order:
literal-compare:
jinja:
no-free-form: # schema-related
url: https://github.com/ansible/ansible-lint/issues/2117
no-jinja-when:
no-tabs:
partial-become:
Expand All @@ -49,8 +50,6 @@ moderate:
name[imperative]:
url: https://github.com/ansible/ansible-lint/issues/2170
name[casing]:
no-free-form: # schema-related
url: https://github.com/ansible/ansible-lint/issues/2117
spell-var-name:
url: https://github.com/ansible/ansible-lint/issues/2168
safety:
Expand Down
32 changes: 0 additions & 32 deletions src/ansiblelint/rules/deprecated_command_syntax.md

This file was deleted.

101 changes: 0 additions & 101 deletions src/ansiblelint/rules/deprecated_command_syntax.py

This file was deleted.

12 changes: 6 additions & 6 deletions src/ansiblelint/rules/no_free_form.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ autocomplete and validation for the edited line.
!!! note

As long you just pass a YAML string that contains a `=` character inside as the
parameter to the action module name, we consider this as using free-formsyntax.
parameter to the action module name, we consider this as using free-form syntax.
Be sure you pass a dictionary to the module, so the free-form parsing is never
triggered.

As `raw` module only accepts free-form, we trigger `no-free-form[raw]` only if
we detect the presence of `executable=` inside raw calls. We advice the explicit
use of `args:` dictionary for configuring the executable to be run.
we detect the presence of `executable=` inside raw calls. We advise the explicit
use of `args:` for configuring the executable to be run.

This rule can produce messages such:
This rule can produce messages as:

- `no-free-form` - Free-form syntax is discouraged.
- `no-free-form[raw-non-string]` - Passing a non string value to `raw` module is
neither documented or supported.
- `no-free-form[raw-non-string]` - Passing a non-string value to `raw` module is
neither documented nor supported.

## Problematic code

Expand Down
1 change: 0 additions & 1 deletion src/ansiblelint/schemas/ansible-lint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
"command-instead-of-module",
"command-instead-of-shell",
"deprecated-bare-vars",
"deprecated-command-syntax",
"deprecated-local-action",
"deprecated-module",
"empty-string-compare",
Expand Down
1 change: 0 additions & 1 deletion test/schemas/negative_test/.ansible-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"command-instead-of-module",
"command-instead-of-shell",
"deprecated-bare-vars",
"deprecated-command-syntax",
"deprecated-local-action",
"deprecated-module",
"empty-string-compare",
Expand Down
2 changes: 1 addition & 1 deletion test/test_rules_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ def test_rules_id_format() -> None:
rule.help != "" or rule.description or rule.__doc__
), f"Rule {rule.id} must have at least one of: .help, .description, .__doc__"
assert "yaml" in keys, "yaml rule is missing"
assert len(rules) == 51 # update this number when adding new rules!
assert len(rules) == 50 # update this number when adding new rules!
assert len(keys) == len(rules), "Duplicate rule ids?"
2 changes: 1 addition & 1 deletion test/test_skip_inside_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_role_tasks_with_block(default_text_runner: RunFromText) -> None:

@pytest.mark.parametrize(
("lintable", "expected"),
(pytest.param("examples/playbooks/test_skip_inside_yaml.yml", 10, id="yaml"),),
(pytest.param("examples/playbooks/test_skip_inside_yaml.yml", 2, id="yaml"),),
)
def test_inline_skips(
default_rules_collection: RulesCollection, lintable: str, expected: int
Expand Down

0 comments on commit aade575

Please sign in to comment.