From d65e75758bc78e7a95e9005c51d74d1215ac68d4 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Wed, 29 Apr 2026 22:17:42 +0200 Subject: [PATCH] cfengine lint: Fixed looking for body calls in cases where we expect a bundle Co-authored-by: Claude Opus 4.6 (1M context) Signed-off-by: Ole Herman Schumacher Elgesem --- src/cfengine_cli/lint.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cfengine_cli/lint.py b/src/cfengine_cli/lint.py index 7d7fe7a..06af2f4 100644 --- a/src/cfengine_cli/lint.py +++ b/src/cfengine_cli/lint.py @@ -52,6 +52,7 @@ "string", } PROMISE_BLOCK_ATTRIBUTES = ("path", "interpreter") +IMPLIES_BUNDLE = {"usebundle", "servicebundle", "service_bundle"} KNOWN_FAULTY_FUNCTION_DEFS = {"regex_replace", "peers"} # Generally, we don't want to allow creating bodies / bundles with the same # name as a built in function, as it can make things more confusing @@ -653,7 +654,10 @@ def _lint_node( return 1 if state.strict and ( qualified_name not in state.bundles - and qualified_name not in state.bodies + and ( + state.attribute_name in IMPLIES_BUNDLE + or qualified_name not in state.bodies + ) and name not in syntax_data.BUILTIN_FUNCTIONS ): _highlight_range(node, lines) @@ -764,7 +768,10 @@ def _lint_node( f"Error: Expected {expected} arguments, received {len(args)} for bundle '{call}' {location}" ) return 1 - if qualified_name in state.bodies: + if ( + qualified_name in state.bodies + and state.attribute_name not in IMPLIES_BUNDLE + ): definitions = state.bodies[qualified_name] valid_counts = {len(d.get("parameters", [])) for d in definitions} if len(args) not in valid_counts: