Skip to content

Commit 8877b7c

Browse files
Hlint hints.
1 parent 3312117 commit 8877b7c

File tree

25 files changed

+57
-55
lines changed

25 files changed

+57
-55
lines changed

GenChangelogs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ main = do
2424

2525
prs <- github' $ pullRequestsForR "haskell" "haskell-language-server" stateClosed FetchAll
2626
let prsAfterLastTag = either (error . show)
27-
(foldMap (\pr -> if inRange pr then [pr] else []))
27+
(foldMap (\pr -> [pr | inRange pr]))
2828
prs
2929
inRange pr
3030
| Just mergedDate <- simplePullRequestMergedAt pr = mergedDate > lastDate

ghcide/.hlint.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
- ignore: {name: "Redundant do"}
1212
- ignore: {name: "Avoid lambda"}
1313
- ignore: {name: "Use newtype instead of data"}
14-
- ignore: {name: "Use fromMaybe"}
1514
- ignore: {name: "Use unless"}
1615
- ignore: {name: "Move brackets to avoid $"}
1716
- ignore: {name: "Eta reduce"}
@@ -25,6 +24,21 @@
2524
- ignore: {name: "Use uncurry"}
2625
- ignore: {name: "Avoid lambda using `infix`"}
2726

27+
# Gives at least one suggestion we don't like.
28+
- ignore: {name: "Use <=<"}
29+
- ignore: {name: "Use zipFrom" -}
30+
- ignore: {name: "Use zipWithFrom" -}
31+
32+
# We are using the "redundant" return/pure to assign a name. We do not want to
33+
# delete it. In particular, this is not an improvement:
34+
# Found:
35+
# do options <- somethingComplicated
36+
# pure options
37+
# Perhaps:
38+
# do somethingComplicated
39+
- ignore: {name: "Redundant return"}
40+
- ignore: {name: "Redundant pure"}
41+
2842
# Off by default hints we like
2943
- warn: {name: Use module export list}
3044

@@ -107,7 +121,7 @@
107121
# Things that are unsafe in Haskell base library
108122
- {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]}
109123
- {name: unsafeDupablePerformIO, within: []}
110-
- {name: unsafeCoerce, within: []}
124+
- {name: unsafeCoerce, within: [Ide.Plugin.Eval.Code]}
111125
# Things that are a bit dangerous in the GHC API
112126
- {name: nameModule, within: []}
113127

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ getInitialGhcLibDirDefault = do
123123
hPutStrLn stderr $ "Couldn't load cradle for libdir: " ++ show (err,dir,hieYaml,cradle)
124124
pure Nothing
125125
CradleNone -> do
126-
hPutStrLn stderr $ "Couldn't load cradle (CradleNone)"
126+
hPutStrLn stderr "Couldn't load cradle (CradleNone)"
127127
pure Nothing
128128

129129
-- | Sets `unsafeGlobalDynFlags` on using the hie-bios cradle and returns the GHC libdir

ghcide/src/Development/IDE/GHC/ExactPrint.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
{-# LANGUAGE RankNTypes #-}
66
{-# LANGUAGE TypeFamilies #-}
77

8-
{- HLINT ignore "Use zipFrom" -}
9-
108
module Development.IDE.GHC.ExactPrint
119
( Graft(..),
1210
graft,

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ documentHighlight hf rf pos = pure highlights
158158
ns = concat $ pointCommand hf pos (rights . M.keys . nodeIdentifiers . nodeInfo)
159159
highlights = do
160160
n <- ns
161-
ref <- maybe [] id (M.lookup (Right n) rf)
161+
ref <- fromMaybe [] (M.lookup (Right n) rf)
162162
pure $ makeHighlight ref
163163
makeHighlight (sp,dets) =
164164
DocumentHighlight (realSrcSpanToRange sp) (Just $ highlightType $ identInfo dets)
@@ -266,12 +266,12 @@ typeLocationsAtPoint hiedb lookupModule _ideOptions pos (HAR _ ast _ _ hieKind)
266266
HQualTy a b -> getTypes [a,b]
267267
HCastTy a -> getTypes [a]
268268
_ -> []
269-
in fmap nubOrd $ concatMapM (fmap (maybe [] id) . nameToLocation hiedb lookupModule) (getTypes ts)
269+
in fmap nubOrd $ concatMapM (fmap (fromMaybe []) . nameToLocation hiedb lookupModule) (getTypes ts)
270270
HieFresh ->
271271
let ts = concat $ pointCommand ast pos getts
272272
getts x = nodeType ni ++ (mapMaybe identType $ M.elems $ nodeIdentifiers ni)
273273
where ni = nodeInfo x
274-
in fmap nubOrd $ concatMapM (fmap (maybe [] id) . nameToLocation hiedb lookupModule) (getTypes ts)
274+
in fmap nubOrd $ concatMapM (fmap (fromMaybe []) . nameToLocation hiedb lookupModule) (getTypes ts)
275275

276276
namesInType :: Type -> [Name]
277277
namesInType (TyVarTy n) = [Var.varName n]

hls-plugin-api/src/Ide/PluginUtils.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ clientSupportsDocumentChanges caps =
135135
WorkspaceEditClientCapabilities mDc _ _ <- _workspaceEdit wCaps
136136
mDc
137137
in
138-
fromMaybe False supports
138+
Just True == supports
139139

140140
-- ---------------------------------------------------------------------
141141

@@ -214,7 +214,7 @@ allLspCmdIds' pid mp = mkPlugin (allLspCmdIds pid) (Just . pluginCommands)
214214

215215

216216
allLspCmdIds :: T.Text -> [(PluginId, [PluginCommand ideState])] -> [T.Text]
217-
allLspCmdIds pid commands = concat $ map go commands
217+
allLspCmdIds pid commands = concatMap go commands
218218
where
219219
go (plid, cmds) = map (mkLspCmdId pid plid . commandId) cmds
220220

hls-plugin-api/src/Ide/Types.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# LANGUAGE GADTs #-}
22
{-# LANGUAGE OverloadedStrings #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
4-
{-# LANGUAGE TupleSections #-}
54
{-# LANGUAGE FlexibleContexts #-}
65
{-# LANGUAGE PolyKinds #-}
76
{-# LANGUAGE ViewPatterns #-}

install/src/Cabal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ getProjectFile ver = do
9696
else "cabal.project"
9797

9898
checkCabal_ :: [String] -> Action ()
99-
checkCabal_ args = checkCabal args >> return ()
99+
checkCabal_ args = void $ checkCabal args
100100

101101
-- | check `cabal` has the required version
102102
checkCabal :: [String] -> Action String

install/src/Env.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ findInstalledGhcs = do
5454
-- sort by version to make it coherent with getHlsVersions
5555
$ sortBy (comparing fst)
5656
-- nub by version. knownGhcs takes precedence.
57-
$ nubBy ((==) `on` fst)
57+
$ nubOrdBy (compare `on` fst)
5858
-- filter out stack provided GHCs (assuming that stack programs path is the default one in linux)
5959
$ filter (not . isInfixOf ".stack" . snd) (knownGhcs ++ availableGhcs)
6060

install/src/Print.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ printInStars = liftIO . putStrLn . embedInStars
2525

2626
-- | Trim whitespace of both ends of a string
2727
trim :: String -> String
28-
trim = dropWhileEnd isSpace . dropWhile isSpace
28+
trim = trimEnd . trimStart
2929

3030
-- | Trim the whitespace of the stdout of a command
3131
trimmedStdout :: Stdout String -> String

0 commit comments

Comments
 (0)