-
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 Rule: Consistent Generic Type #259
New Rule: Consistent Generic Type #259
Conversation
@jackyhui96, if you change your description to e.g. |
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.
I ask for a few tweaks but I like the overall direction and implementation.
I'm Ok with all the recent changes. I'll approve, assuming you'll eventually accept the only new suggestion I've added. I'll also add @elbrujohalcon as a reviewer so he can give this a look. Many thanks. |
Co-authored-by: Paulo F. Oliveira <[email protected]>
4482056
to
e43da1b
Compare
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.
I like the idea.
I think this rule is very similar to Behaviour Spelling and so I would expect its implementation, documentation, tests, etc. to be more similar to it..
That's the goal of all the suggestions I made.
Besides that, can you add more tests to showcase the different places where the type can be, like…
% Type definitions when this is alone or combined
-type my_type() :: any().
-type combined() :: term() | my_type().
% Callback definitions (with or without when)
-callback my_callback(term()) -> any().
-callback my_callback(X) -> X when X :: term().
% Specs with when
-spec my_spec(X) -> X when X :: any().
% Record definitions
-record(my_record, {t :: term(), a :: any()}).
…and can you add tests where this should not be validated, like these…
% A parametric type called any
-type any(Thing) :: Thing.
% A function called any
-spec any() -> term().
any() -> any.
% A function that calls the function called any
my_function() -> any().
Sorry for the back and forth, @jackyhui96 … Multiple maintainers, multiple views on the project… 🤷🏻 |
In any case, the only meaningful request to change I see is the fact that the rule should not be restricted to
I agree with adding more tests. |
I agree not to activate the rule by default (i.e. not to put it in the default ruleset rules => [{elvis_style, whatever_name_it_ends_up_with, #{}}] …without the need to specify a preferred value explicitly.
Yeah… easy to act on is fine, but consistent with other messages is important to me, too.
🤝 |
Alright @jackyhui96 … You have green light to move forward with the changes. Sorry again for the back-and-forth. |
@elbrujohalcon, is the rule to be renamed as |
I'm summarising the requested changes below:
|
comment updated, @paulo-ferraz-oliveira ;) |
Currently it looks like the rule doesn’t apply to callbacks |
@jackyhui96 you mean that Or maybe elements within callbacks are not categorized as types… 🤔 … If that's so, same thing: it merits a bug report. |
@paulo-ferraz-oliveira I already approved the PR. I leave it up to you to merge it, if you're comfortable with it :) |
Yeah it doesn't categorise them as types 😞 this is what the nodes look like for a callback:
|
Oooooh… that's bad. Do you mind filing a bug for that, @jackyhui96 ? |
@elbrujohalcon sure thing, is this a bug with elvis or with |
I would start with elvis_core… if upon further investigation it turns out it comes from ktn_code… we can then report a bug there. |
@elbrujohalcon, I left a minor comment (hopefully the last 😄). |
@jackyhui96, I'm merging... many thanks for this. |
Closes #258