-
Notifications
You must be signed in to change notification settings - Fork 56
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
New elvis_style
rule: no_init_lists
#367
Conversation
Do we want to check that the module implements a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs more tests, specifically:
- A module that implements
gen_server
orgen_statem
and…- has
init([_|_]) -> …
: Should fail. - has
init(A = [1,2,3]) -> …
: Should fail - has
init/1
implemented with multiple clauses, all of them expecting a list: Should fail. - has
init/1
implemented with multiple clauses, one of them not being a list: Should pass, even if other clauses expect a list. - has
init/1
implemented using a map, butinit/2
implemented using a list in one of the arguments: Should pass. - has
init/0
implemented using a tuple, but alsoinit/0
: Should pass.
- has
- A module that doesn't implement a behaviour and has
init([1,2,3]) -> …
: Should pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're on the right path here ❤️ Just a few more tweaks...
elvis_style
rule: no_init_lists
I tweaked the PR title since this'll go directly into the generated release Changelog. |
Thanks for the comments, I will solve all of them if I have some time. ❤️ |
Co-authored-by: Brujo Benavides <[email protected]>
Co-authored-by: Brujo Benavides <[email protected]>
Co-authored-by: Brujo Benavides <[email protected]>
…into no-init-lists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still missing some changes, but I just wanted to add feedback about the recent additions.
I still have some work to do, but it keeps getting better. |
@bormilan do you mind merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small suggestions, but overall great progress @bormilan 👍🏻
Co-authored-by: Brujo Benavides <[email protected]>
Co-authored-by: Brujo Benavides <[email protected]>
Co-authored-by: Brujo Benavides <[email protected]>
Co-authored-by: Brujo Benavides <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more test (or maybe two, if you want a fail and a pass), @bormilan:
- A module that implements
gen_server
AND another behaviour…
-module(fail…).
-behaviour(gen_server).
-behaviour(another_behaviour).
-export([init/1]).
init([]) -> {error, "should not be a list"}.
Oh! And another test! A module that implements a behaviour that's not gen_server
, nor gen_statem
…
-module(pass…).
-behaviour(another_behaviour).
-export([init/1]).
init([]) -> {error, "can be a list"}.
(This one should pass with default options, but it should fail if you adjust the behaviours
list by adding another_behaviour
to it).
Yes! I like making more and more tests to feel that my code is 100% good. |
HA! I just saw that you were matching against a single |
You're right. I'm working on the new logic right now, so it's the perfect time to add new tests and consider all the possible barriers. |
The only test that is not working now is the one with the |
Isn't it as simple as I think |
Oh! Okay, that's nice, I started to dig into the code of katana, thanks for the clarification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're almost there, @bormilan … really really close to the final version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent job, @bormilan !! Only one more change.
Description
A brief description of your changes.
Closes #329;.
EDIT: I made a checklist based on @elbrujohalcon 's comment to to make the progress traceable.
has init([|]) -> …: Should fail.
has init(A = [1,2,3]) -> …: Should fail
has init/1 implemented with multiple clauses, all of them expecting a list: Should fail.
- [ ] A module that has two behaviours and has init([]) -> should fail
has init/1 implemented with multiple clauses, one of them not being a list: Should pass, even if other clauses expect a list.
has init/1 implemented using a map, but init/2 implemented using a list in one of the arguments: Should pass.
has init/0 implemented using a tuple, but also init/0: Should pass.
A module that doesn't implement a behaviour and has init([1,2,3]) -> …: Should pass.
A module that has a behaviour that is not in the list of the rule's config -> should pass(with default config)