diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 6fa6254f98..31e19027b3 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -72,7 +72,7 @@ jobs: env: # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 882 + PYTEST_REQPASS: 881 steps: - uses: actions/checkout@v4 with: diff --git a/examples/playbooks/become.yml b/examples/playbooks/become.yml index bc8aadb867..ce53f56691 100644 --- a/examples/playbooks/become.yml +++ b/examples/playbooks/become.yml @@ -12,4 +12,4 @@ become: true become_user: nobody notify: - - Restart apache2 + - restart apache2 diff --git a/examples/playbooks/name_case_notify_fail.yml b/examples/playbooks/name_case_notify_fail.yml deleted file mode 100644 index d7a2acaa2f..0000000000 --- a/examples/playbooks/name_case_notify_fail.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- name: Test Playbook - hosts: localhost - tasks: - - name: Task that always changes - ansible.builtin.debug: - msg: foo - changed_when: true - notify: my handler - - - name: Task that always changes - ansible.builtin.debug: - msg: foo - changed_when: true - notify: - - my handler - - my other handler - - - name: Only one of these is invalid - ansible.builtin.debug: - msg: foo - changed_when: true - notify: - - "role_name : lowercase handler" - - "role_name : Uppercase handler" - - handlers: - - name: My handler - ansible.builtin.debug: - msg: bar - - - name: my other handler - ansible.builtin.debug: - msg: bar diff --git a/src/ansiblelint/rules/name.py b/src/ansiblelint/rules/name.py index 9c21b8269b..b814a4169f 100644 --- a/src/ansiblelint/rules/name.py +++ b/src/ansiblelint/rules/name.py @@ -93,23 +93,6 @@ def matchtask( ), ) - notify = task.get("notify") - if notify: - if isinstance(notify, str): - notify = [notify] - - results.extend( - [ - self.create_matcherror( - message=f"Task notify '{handler}' should start with an uppercase letter.", - lineno=task[LINE_NUMBER_KEY], - tag="name[casing]", - filename=file, - ) - for handler in notify - if check_handler_case(handler) - ], - ) return results def _prefix_check( @@ -268,27 +251,10 @@ def update_task_name(task_name: str) -> str: if orig_task_name == task["notify"][idx]: task["notify"][idx] = updated_task_name - if isinstance(item, dict) and "handlers" in item: - for task in item["handlers"]: - listener_task_name = task.get("listen", None) - if ( - listener_task_name - and listener_task_name == orig_task_name - ): - task["listen"] = updated_task_name - target_task["name"] = updated_task_name match.fixed = True -def check_handler_case(handler: str) -> bool: - """Check the casing of a handler.""" - # Handlers may be prefixed with "role_name : " to indicate a handler from a specific role - # Strip this before checking - handler = handler.split(" : ", 1)[-1] - return handler[0].isalpha() and handler[0].islower() and not handler[0].isupper() - - if "pytest" in sys.modules: from ansiblelint.rules import RulesCollection from ansiblelint.runner import Runner @@ -381,17 +347,6 @@ def test_rule_name_lowercase() -> None: assert errs[0].tag == "name[casing]" assert errs[0].rule.id == "name" - def test_rule_notify_lowercase() -> None: - """Negative test for a task notify that starts with lowercase.""" - collection = RulesCollection() - collection.register(NameRule()) - failure = "examples/playbooks/name_case_notify_fail.yml" - bad_runner = Runner(failure, rules=collection) - errs = bad_runner.run() - assert len(errs) == 5 - assert all(err.tag == "name[casing]" for err in errs) - assert all(err.rule.id == "name" for err in errs) - def test_name_play() -> None: """Positive test for name[play].""" collection = RulesCollection() diff --git a/test/test_transformer.py b/test/test_transformer.py index b67f78a2f0..0767f4b7e1 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -84,7 +84,6 @@ def fixture_runner_result( id="strings", ), pytest.param("examples/playbooks/vars/empty.yml", 1, False, True, id="empty"), - pytest.param("examples/playbooks/name-case.yml", 6, True, True, id="name_case"), pytest.param("examples/playbooks/fqcn.yml", 3, True, True, id="fqcn"), pytest.param( "examples/playbooks/multi_yaml_doc.yml",