Add action for ignoring HLint hint for a single definition #4670
Draft
Add action for ignoring HLint hint for a single definition #4670
Conversation
georgefst
commented
Jul 22, 2025
| srcLocLine, | ||
| srcSpanStart, | ||
| topDir, | ||
| wopt) |
Collaborator
Author
There was a problem hiding this comment.
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.
georgefst
commented
Jul 22, 2025
05170e9 to
97db3bc
Compare
97db3bc to
5a95caa
Compare
georgefst
commented
Jul 22, 2025
| 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) |
Collaborator
Author
There was a problem hiding this comment.
@fendor Do you know a better way to go LHsDecl GhcPs -> Maybe Text?
Collaborator
Author
There was a problem hiding this comment.
Otherwise we can factor out the required part of documentSymbolForDecl, and use it there and here.
Collaborator
There was a problem hiding this comment.
Sorry for the delay, I can't think of a better way, and think factoring out documentSymbolForDecl is reasonable!
georgefst
commented
Jul 22, 2025
| 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 |
Collaborator
Author
There was a problem hiding this comment.
I need to look in to this...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.