Skip to content

ENT-13833: Added checks for correct number of args for bundle-/body-calls#72

Open
SimonThalvorsen wants to merge 3 commits intocfengine:mainfrom
SimonThalvorsen:ENT-13833
Open

ENT-13833: Added checks for correct number of args for bundle-/body-calls#72
SimonThalvorsen wants to merge 3 commits intocfengine:mainfrom
SimonThalvorsen:ENT-13833

Conversation

@SimonThalvorsen
Copy link
Copy Markdown
Contributor

No description provided.

@SimonThalvorsen SimonThalvorsen marked this pull request as draft April 17, 2026 13:50
@SimonThalvorsen SimonThalvorsen marked this pull request as ready for review April 17, 2026 14:01
string => canonify();
^--------^
Error: Expected 1 arguments, received 0 at tests/lint/013_function_call_arg_count.x.cf:5:15
Error: Expected 1 arguments, received 0 for function 'canonify'at tests/lint/013_function_call_arg_count.x.cf:5:15
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Error: Expected 1 arguments, received 0 for function 'canonify'at tests/lint/013_function_call_arg_count.x.cf:5:15
Error: Expected 1 arguments, received 0 for function 'canonify' at tests/lint/013_function_call_arg_count.x.cf:5:15

string => canonify("test", "test");
^----------------------^
Error: Expected 1 arguments, received 2 at tests/lint/013_function_call_arg_count.x.cf:9:15
Error: Expected 1 arguments, received 2 for function 'canonify'at tests/lint/013_function_call_arg_count.x.cf:9:15
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Error: Expected 1 arguments, received 2 for function 'canonify'at tests/lint/013_function_call_arg_count.x.cf:9:15
Error: Expected 1 arguments, received 2 for function 'canonify' at tests/lint/013_function_call_arg_count.x.cf:9:15

Comment thread src/cfengine_cli/lint.py
if len(params) != len(args):
_highlight_range(node, lines)
print(
f"Error: Expected {len(params)} arguments, received {len(args)} for body '{call}'{location}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Error: Expected {len(params)} arguments, received {len(args)} for body '{call}'{location}"
f"Error: Expected {len(params)} arguments, received {len(args)} for body '{call}' {location}"

Comment on lines +5 to +15
Error: Expected 2 arguments, received 0 for bundle 'test' at tests/lint/014_num_args_bundle_body.x.cf:5:20

"test2"
usebundle => test("a");
^-------^
Error: Expected 2 arguments, received 1 for bundle 'test' at tests/lint/014_num_args_bundle_body.x.cf:7:20

"test4"
usebundle => test("a", "b", "c");
^-----------------^
Error: Expected 2 arguments, received 3 for bundle 'test' at tests/lint/014_num_args_bundle_body.x.cf:11:20
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 3 cases are for bundle, maybe make one for body as well :)

Copy link
Copy Markdown
Member

@nickanderson nickanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks nicer than cf-promises today:

bundle agent main
{
      methods:
        "t" usebundle => t();
}
bundle agent t( param )
{
  defaults:
      "param" string => "DEFAULT VALUE", if_match_regex => "";

      reports: "$(param)";
}
cf-promises -cf ./test.cf 
./test.cf:5:0: error: Conflicting arity in calling bundle t, expected 1 arguments, 0 given
   error: There are syntax errors in policy files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants