inaka / elvis_core

The core of an Erlang linter
Other
61 stars 56 forks source link

New Rule: No Import Type #323

Open paulo-ferraz-oliveira opened 1 year ago

paulo-ferraz-oliveira commented 1 year ago

Name

no_import_type

Brief Description

It is possible that a new import_type directive (⚠️ a previous link was removed - though GitHub doesn't seem to update the target - so that this rule suggestion is not poorly interpreted as an "attack" on the functionality...) lands in OTP soon (27 or later, I imagine). While it may have uses in some specific cases, namely, as the proposer mentions, large code bases, it can easily be avoided in smaller code bases. elvis_core shall propose this rule as "enabled by default".

Reasoning

There seems to be some value in the use of the directive:

but it's probably best to start by avoiding it (as we propose avoiding import). elvis_core proposes, doesn't force, and one can always go about using disable to negative the effect of the new rule 😄.

Refactoring Proposal

Instead of -import_type(m, [t/0])., then t, simply use m:t().


This would potentially be a breaking change, depending on how we consider that to be (we're not changing the interface, but adding a rule, which may cause issues in flows with warnings_as_errors) but the MIGRATION.md file hasn't been updated in a while, either.