inaka / elvis

Erlang Style Reviewer
Apache License 2.0
426 stars 87 forks source link

elvis_style:is_otp_module only checks `behavior` attribute, not `behaviour` #550

Closed NAR closed 3 years ago

NAR commented 3 years ago

In Erlang both the US and British spelling is accepted for the -behaviour attribute, however, the elvis_style:is_otp_module/1 function only checks for the US spelling and doesn't detect OTP behaviours using the British spelling:

    IsBehaviorAttr = fun(Node) -> behavior == ktn_code:type(Node) end,

Maybe use something like this:

    IsBehaviorAttr = fun(Node) -> behavior == ktn_code:type(Node) orelse behaviour == ktn_code:type(Node) end,
elbrujohalcon commented 3 years ago

I would've expected ktn_code to return behavior in both cases, tho… 🤔 If you're certain that it doesn't, and you feel like submitting a PR with the proposed change, that would be highly appreciated.

NAR commented 3 years ago

When I changed the attribute to -behaviour, I didn't get warning - I presume because the code doesn't detect that the module is an OTP behaviour. WIth -behavior I got the warning. I'll try to cook up a PR.

NAR commented 3 years ago

See https://github.com/inaka/elvis_core/pull/139

paulo-ferraz-oliveira commented 3 years ago

I think I've touched this subject somewhere, and @jfacorro got involved. Let me do a quick search...

paulo-ferraz-oliveira commented 3 years ago

Related: https://github.com/inaka/elvis/issues/490.

paulo-ferraz-oliveira commented 3 years ago

I think I've touched this subject somewhere, and @jfacorro got involved. Let me do a quick search...

My issue was not related to this, but it also boiled down to spelling 😄: https://github.com/inaka/elvis/issues/522.

elbrujohalcon commented 3 years ago

Fixed with inaka/elvis_core#139