Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore within class function #1562

Open
pbrisbin opened this issue Jan 30, 2024 · 0 comments
Open

How to ignore within class function #1562

pbrisbin opened this issue Jan 30, 2024 · 0 comments

Comments

@pbrisbin
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant