Skip to content

Add action for ignoring HLint hint for a single definition #4670

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgefst
Copy link
Collaborator

@georgefst georgefst commented Jul 22, 2025

Based on #4669. While working on that, I realised that this should be fairly easy. Six hours later...

I've only done some light manual testing, but it seems to generally work. The one issue I've found is that the ignore comment is inserted after a value definition's type signature, when there is one, which is probably not what we want.

There's also some general code cleanup to do. See TODO comments. I'll get to that once #4669 is merged. As well as adding tests.

It doesn't actually matter where the ignore comment is placed, but I figured that at the top of the relevant definition is conventional.

topDir,
wopt)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These imports are a bit of a mess, due to this file defining its own RealSrcSpan and others, because of the option to use ghc-lib rather than ghc. I'm not certain I've got it right for all versions. Hopefully CI will let us know.

RealSrcLoc sl _ -> Just (srcLocLine sl - 1)
UnhelpfulLoc _ -> Nothing
-- TODO `documentSymbolForDecl` wasn't intended to be exported, and computes more than we need
-- (although laziness should save us there)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fendor Do you know a better way to go LHsDecl GhcPs -> Maybe Text?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we can factor out the required part of documentSymbolForDecl, and use it there and here.

containingDecl <- find (maybe False (positionInRange pos) . srcSpanToRange . getLoc)
$ hsmodDecls $ unLoc $ pm_parsed_source pm
defStartLine <- case srcSpanStart $ getLoc containingDecl of
-- TODO `srcLocLine` can apparently raise an error, but it's not clear what the safe version is
Copy link
Collaborator Author

@georgefst georgefst Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to look in to this...

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

Successfully merging this pull request may close these issues.

1 participant