Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcards in no_call_functions MFA #325

Closed
attah opened this issue Nov 2, 2023 · 4 comments · Fixed by #326
Closed

Wildcards in no_call_functions MFA #325

attah opened this issue Nov 2, 2023 · 4 comments · Fixed by #326

Comments

@attah
Copy link
Contributor

attah commented Nov 2, 2023

Is your feature request related to a problem? Please describe

Wildcards in no_call_functions MFA, i.e. rules that applies regardless of module name and/or function name and/or arity.

Describe the solution you'd like

Being able to do:

#{dirs => ["."],
       filter => "*tests.erl",
       rules =>
           [{elvis_style, no_call,
             #{no_call_functions => [{'*', handle_event, 4}]]
      }

Describe alternatives you've considered

Dynamically generating rule definitions... too much work.

Additional Context

It is ridiculous to test a state machine without a running process, and with state data that it has not produced itself.
Running the statem/server callbacks explicitly from tests is the biggest antipattern i know in testing.

@elbrujohalcon
Copy link
Member

I think this is a great idea. I would use '_' as the "anything" pattern and maybe consider accepting {module_name, function_name} tuples to indicate "any arity", but I do like the idea.

@attah
Copy link
Contributor Author

attah commented Nov 2, 2023

Right, underscore is a lot more "Erlang". Not sold on the two-tuple though; why not just wildcard arity?

@elbrujohalcon
Copy link
Member

Yeah, wildcard ariity is fine.

@attah
Copy link
Contributor Author

attah commented Nov 2, 2023

Looks like your two-tuple may already work.

fun_spec_match({M, F}, {M, F, _}) ->

And it looks like it will be very easy to add what i want... let's see if i can't get some time for this soon.

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

Successfully merging a pull request may close this issue.

2 participants