-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Apply some hlint suggestions, silence some others. #1227
Apply some hlint suggestions, silence some others. #1227
Conversation
@@ -145,6 +145,8 @@ tokens = concatMap (\(l, vs) -> map (Located l) vs) . zip [0 ..] . reverse . snd | |||
Right (st', tokens') -> (st', tokens' : tokens) | |||
Left err -> error $ unwords ["Tokens.next failed to parse", ln, err] | |||
|
|||
{- HLINT ignore tokens "Use zipFrom" -} | |||
|
|||
-- | Parse a line of input | |||
aline :: State -> TParser | |||
aline InCode = optionStart <|> multi <|> singleOpen <|> codeLine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 142.
I don't think this is an improvement but we can do whatever.
Found:
zip [0 .. ]
Perhaps:
zipFrom 0```
@@ -18,6 +18,7 @@ library | |||
build-depends: aeson | |||
, base >=4.12 && <5 | |||
, containers | |||
, extra | |||
, foldl | |||
, haskell-lsp | |||
, hls-plugin-api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively: don't incur a dependency just to satisfy hlint's obsession with eitherM. But the rest of hls already depends on extra so why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HLint only suggests extra functions if you pass the appropriate option, so if you don't want to use more option, then don't pass that.
False -> pure [] | ||
if xopt ext dflags | ||
then tp dflags plId uri range jdg | ||
else pure [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of "case ... True ... False" is consistent and obviously deliberate in the tactics plugin. Should we just ignore the "use if then else" suggestion for this module and leave the code alone?
(I don't care either way, I basically made an arbitrary decision just to get the PR started.)
Please don't change anything in |
@@ -33,6 +36,9 @@ mkContext locals tcg = Context | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this function is one operation per line. The suggested changes would combine some of the lines, which seems worse.
plugins/tactics/src/Ide/Plugin/Tactic/Context.hs:(29,22)-(31,30): Suggestion: Use <=<
Found:
(getFunBindId =<<) . fmap unLoc . bagToList
Perhaps:
(getFunBindId Control.Monad.<=< (fmap unLoc . bagToList))```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
((getFunBindId . unLoc) <=< bagToList)
is better?
I'm not super inclined to this though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could move these:
{- HLINT ignore mkContext "Redundant fmap" -}
{- HLINT ignore mkContext "Use <=<" -}
to the .hlint.yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Redundant fmap
rule may be useful for some cases... but for <=<
, I agree that would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the fish recommendation ignore to the hlint.yaml and left the fmap recommendation in the module.
50fc3af
to
1e2fd7a
Compare
The failing build is this thing:
|
@peterwicksstringfield It's eval plugin's non-deterministic bug, and it may be gone after a few trials. |
@peterwicksstringfield Could you rebase this? Now the eval subtlety has (presumably) fixed, and it will be better to merge (or close) this PR before sending a style formatter PR. |
Ailrun: happy too. Wasn't sure what the state of the this PR was and wasn't sure how to ask. Will push in an hour or so. |
1872dc4
to
6576637
Compare
@@ -55,6 +55,8 @@ type Loc = Located Line | |||
|
|||
type Line = Int | |||
|
|||
{- HLINT ignore locate "Use zipWithFrom" -} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not use the rule for code like this, then will we ever use this rule?
If we won't, I think it's better to put this in the hlint setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll just apply this hint too.
@@ -89,6 +89,8 @@ withNewGoal :: a -> Judgement' a -> Judgement' a | |||
withNewGoal t = field @"_jGoal" .~ t | |||
|
|||
|
|||
{- HLINT ignore introducing "Use zipFrom" -} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for here
@@ -218,6 +218,8 @@ filterSameTypeFromOtherPositions dcon pos jdg = | |||
in disallowing Shadowed (M.keys to_remove) jdg | |||
|
|||
|
|||
{- HLINT ignore getAncestry "Replace case with maybe" -} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I ask why this is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember what I was thinking. The version with maybe looks fine to me now. Fixed.
stack.yaml
Outdated
@@ -1,4 +1,4 @@ | |||
resolver: lts-14.27 # Last 8.6.5 | |||
resolver: nightly-2020-12-09 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why did you update this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge error. I very carefully checked to make sure that that wasn't included before I pushed. Apparently I checked wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the help. :) |
Could you rebase this PR? |
c28e00a
to
8877b7c
Compare
Meanwhile, on the other side of the code base: Rebased. Dropped use of zipFrom and zipFromWith. Moved the zipFrom and zipFromWith ignores to .hlint.yaml. Dropped all changes to hls-tactics-plugin/**. |
8877b7c
to
00fd613
Compare
Lets try merge this asap to avoid more conflicts |
FYI this commit seems to have broken the install script. There's no clear error message: $ stack ./install.hs hls-8.8.4
-- While building package hls-install-0.8.0.0 (scroll up to its section to see the error) using:
/home/jhrcek/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.4.0.1 build lib:hls-install --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1 |
@@ -54,7 +54,7 @@ findInstalledGhcs = do | |||
-- sort by version to make it coherent with getHlsVersions | |||
$ sortBy (comparing fst) | |||
-- nub by version. knownGhcs takes precedence. | |||
$ nubBy ((==) `on` fst) | |||
$ nubOrdBy (compare `on` fst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this change has broken the install script??? It shouldn't but is the unique direct change in that component.
@jhrcek please, could you try the install reverting this change manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the change broke it, hlint suggestion was very wrong 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jneira Just tried with latest master and I had to revert both this change (nubOrdBy back to nubBy) AND one more change done in install/src/Print.hs
below. After reverting those two changes it started working again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's some kind of implicit import going on or something ,but those functions come from extra
and I don't see them imported in either of the 2 modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No implicit imports afaik, fortunately 🙂
The fix would be add those imports probably
@jhrcek Thanks for reporting it, would you like to open a pr adding the appropiate imports? i'll do myself in other case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll do it later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the install script is not being tested, but it does not change frequently so 🤷
These suggested changes come from running hlint on the entire code base, using the configuration at ghcide/.hlint.yaml
If we plan to expand hlint coverage across the code base we will need to apply or silence all of these at some point.
cf. #693