rule : Review.Rule.Rule
Reports arguments of custom type constructors that are never used.
config =
[ NoUnused.CustomTypeConstructorArgs.rule
]
Custom type constructors can contain data that is never extracted out of the constructor.
This rule will warn arguments that are always pattern matched using a wildcard (_
).
For package projects, custom types whose constructors are exposed as part of the package API are not reported.
Note that this rule may report false positives if you compare custom types with the ==
or /=
operators
(and never destructure the custom type), like when you do value == Just 0
, or store them in lists for instance with
assoc-list
.
This rule attempts to detect when the custom type is used in comparisons, but it may still result in false positives.
type CustomType
= CustomType Used Unused
case customType of
CustomType value _ -> value
type CustomType
= CustomType Used Unused
case customType of
CustomType value maybeUsed -> value
If you like giving names to all arguments when pattern matching, then this rule will not find many problems.
This rule will work well when enabled along with NoUnused.Patterns
.
Also, if you like comparing custom types in the way described above, you might pass on this rule, or want to be very careful when enabling it.
You can try this rule out by running the following command:
elm-review --template jfmengels/elm-review-unused/example --rules NoUnused.CustomTypeConstructorArgs