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

Support ignore for ignored variable used #97

Merged

Conversation

cypherfox
Copy link
Contributor

This change adds the ability to add a list of ignored modules to the rule ignored_variable_used.

This is needed as elvis will fail on an ignored variable in a eunit ?assertMatch macro.

    ?assertMatch({ok, {a_valid_message, _V}}, fut(Args))

Not ignoring the variable will cause the compiler to report a warning instead.

@elbrujohalcon
Copy link
Member

elbrujohalcon commented Apr 13, 2018

I think the idea is useful, but what if you fully ignore the variable (i.e. using _)?

To expand on this, be aware that if you use _V in two consecutive ?assertMatch's, for the second one to work, _V will probably (haven't reviewed eunit macros intensively lately) need to have the same value in both. Which is exactly what this linter rule is trying to prevent.

@elbrujohalcon
Copy link
Member

Would you mind adding / adjusting some tests for this functionality?

@cypherfox
Copy link
Contributor Author

Ah! Fully ignoring works. While I dislike it from a standpoint of literate programming (IMHO it reduces the readability of the test), that explains why nobody else has been asking for it for a long time.

Yes, I will try to add some tests.

@elbrujohalcon elbrujohalcon merged commit 1ac0ddd into inaka:master Apr 18, 2018
@elbrujohalcon
Copy link
Member

Thanks @cypherfox ! Don't forget to also update the wiki with this change

@cypherfox
Copy link
Contributor Author

@elbrujohalcon done.

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

Successfully merging this pull request may close these issues.

2 participants