Repository metrics
- Stars
- (26 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
As some have probably already run into, NoUnused.CustomTypeConstructorArgs has some false positives, where it tells you that Int in type A = A Int is unused because it is never extracted but in some places you do value == A 0.
The way I’m currently thinking of resolving this is to register all the types that are used directly or indirectly in comparisons (== or /=), and to not report issues for those types at all. So if you have a type alias Record = { a : A, ... } and I notice that something is a Record and is being used in a comparison, then it won’t report the constructor arguments of A.
This would require (or become a lot easier?) with type information, though I think it’ll still be a difficult rule to write.
In some cases, it might still be complicated to notice that something is used as a comparison. For instance, when something is used as the key of a Dictionary (like AssocList). One option here is to look at dependencies’ code to notice that == is used in the implementation on the key, therefore whatever key is passed to an AssocList.Dict is marked as being compared. If that doesn’t work, then asking for configuration could be used as a stop-gap measure (or a temporary measure until we can visit dependencies)
I’m thinking the same thing will probably be useful for other data that is stored, like tuples and record fields. So I’m thinking maybe instead of having NoUnused.CustomTypeConstructorArgs, NoUnused.RecordFields (#15) and NoUnused.TupleFields (#16), we could have a single NoUnused.Data/NoUnused.Fields rule (name TBD).