Skip to content

Commit 3f6f87f

Browse files
authored
Revert notify related checks, errors, transforms for listen and tests (#4205)
1 parent d1ff289 commit 3f6f87f

File tree

5 files changed

+2
-82
lines changed

5 files changed

+2
-82
lines changed

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
env:
7373
# Number of expected test passes, safety measure for accidental skip of
7474
# tests. Update value if you add/remove tests.
75-
PYTEST_REQPASS: 882
75+
PYTEST_REQPASS: 881
7676
steps:
7777
- uses: actions/checkout@v4
7878
with:

examples/playbooks/become.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
become: true
1313
become_user: nobody
1414
notify:
15-
- Restart apache2
15+
- restart apache2

examples/playbooks/name_case_notify_fail.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/ansiblelint/rules/name.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,6 @@ def matchtask(
9393
),
9494
)
9595

96-
notify = task.get("notify")
97-
if notify:
98-
if isinstance(notify, str):
99-
notify = [notify]
100-
101-
results.extend(
102-
[
103-
self.create_matcherror(
104-
message=f"Task notify '{handler}' should start with an uppercase letter.",
105-
lineno=task[LINE_NUMBER_KEY],
106-
tag="name[casing]",
107-
filename=file,
108-
)
109-
for handler in notify
110-
if check_handler_case(handler)
111-
],
112-
)
11396
return results
11497

11598
def _prefix_check(
@@ -268,27 +251,10 @@ def update_task_name(task_name: str) -> str:
268251
if orig_task_name == task["notify"][idx]:
269252
task["notify"][idx] = updated_task_name
270253

271-
if isinstance(item, dict) and "handlers" in item:
272-
for task in item["handlers"]:
273-
listener_task_name = task.get("listen", None)
274-
if (
275-
listener_task_name
276-
and listener_task_name == orig_task_name
277-
):
278-
task["listen"] = updated_task_name
279-
280254
target_task["name"] = updated_task_name
281255
match.fixed = True
282256

283257

284-
def check_handler_case(handler: str) -> bool:
285-
"""Check the casing of a handler."""
286-
# Handlers may be prefixed with "role_name : " to indicate a handler from a specific role
287-
# Strip this before checking
288-
handler = handler.split(" : ", 1)[-1]
289-
return handler[0].isalpha() and handler[0].islower() and not handler[0].isupper()
290-
291-
292258
if "pytest" in sys.modules:
293259
from ansiblelint.rules import RulesCollection
294260
from ansiblelint.runner import Runner
@@ -381,17 +347,6 @@ def test_rule_name_lowercase() -> None:
381347
assert errs[0].tag == "name[casing]"
382348
assert errs[0].rule.id == "name"
383349

384-
def test_rule_notify_lowercase() -> None:
385-
"""Negative test for a task notify that starts with lowercase."""
386-
collection = RulesCollection()
387-
collection.register(NameRule())
388-
failure = "examples/playbooks/name_case_notify_fail.yml"
389-
bad_runner = Runner(failure, rules=collection)
390-
errs = bad_runner.run()
391-
assert len(errs) == 5
392-
assert all(err.tag == "name[casing]" for err in errs)
393-
assert all(err.rule.id == "name" for err in errs)
394-
395350
def test_name_play() -> None:
396351
"""Positive test for name[play]."""
397352
collection = RulesCollection()

test/test_transformer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def fixture_runner_result(
8484
id="strings",
8585
),
8686
pytest.param("examples/playbooks/vars/empty.yml", 1, False, True, id="empty"),
87-
pytest.param("examples/playbooks/name-case.yml", 6, True, True, id="name_case"),
8887
pytest.param("examples/playbooks/fqcn.yml", 3, True, True, id="fqcn"),
8988
pytest.param(
9089
"examples/playbooks/multi_yaml_doc.yml",

0 commit comments

Comments
 (0)