You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
for large code bases, where the use of "externally-defined" types is done by means of an auxiliary (internal) type
for potential removal of boilerplate, also potentially at the expense of more "difficult to reason about" code: where does the type come from? (it might be Ok if you use a language server, but not all developers do, and some might actually prefer the clarify of having Module:<type>)
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.
The text was updated successfully, but these errors were encountered:
Name
no_import_type
Brief Description
It is possible that a new⚠️ 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.
import_type
directive (elvis_core
shall propose this rule as "enabled by default".Reasoning
There seems to be some value in the use of the directive:
Module:<type>
)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 usingdisable
to negative the effect of the new rule 😄.Refactoring Proposal
Instead of
-import_type(m, [t/0]).
, thent
, simply usem: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.The text was updated successfully, but these errors were encountered: