How to ignore within class function
pbrisbin opened this issue · 0 comments
pbrisbin commented
We have a few IsString
instances that use some safe conversion function and error
on invalid input:
module Example.Whatever where
instance IsString Whatever where
fromString = either error id . whateverFromString
whateverFromString :: String -> Either String Whatever
whateverFromString = undefined
But we also have a rule to avoid error
generally, which this trips over:
- warn:
name: "Avoid error"
lhs: "error"
rhs: "error"
note: ...
We consider using error
in fromString
acceptable because there is no other way to signal failure and it's (as long as we're disciplined) used only on literals we control. So I would like to tell HLint to ignore the error
lint specifically in any function named fromString
. Seems easy, but I can't make it work.
# I confirmed this works, just to make sure my config is being respected
- ignore: {name: "Avoid error"}
# This also works, but is too broad
- ignore: {name: "Avoid error", within: "Example.Whatever"}
# This does not work
- ignore: {name: "Avoid error", within: "fromString"}
# This does not work either
- ignore: {name: "Avoid error", within: "**.*.fromString"}
# Nor this
- ignore: {name: "Avoid error", within: "Example.Whatever.fromString"}
# Or this
- ignore: {name: "Avoid error", within: "Example.Whatever.IsString.fromString"}
# Or this
- ignore: {name: "Avoid error", within: "Example.Whatever.IsString"}
I'm assuming it's the fact that it's a class function and not a normal top-level. Is that it? Is there any way to do what I'm after here?