Skip to content

Commit 18ef09a

Browse files
Apply some hlint suggestions, silence some others.
1 parent b1d912a commit 18ef09a

File tree

30 files changed

+107
-94
lines changed

30 files changed

+107
-94
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: 10 additions & 1 deletion
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,16 @@
2524
- ignore: {name: "Use uncurry"}
2625
- ignore: {name: "Avoid lambda using `infix`"}
2726

27+
# We are using the "redundant" return/pure to assign a name. We do not want to
28+
# delete it. In particular, this is not an improvement:
29+
# Found:
30+
# do options <- somethingComplicated
31+
# pure options
32+
# Perhaps:
33+
# do somethingComplicated
34+
- ignore: {name: "Redundant return"}
35+
- ignore: {name: "Redundant pure"}
36+
2837
# Off by default hints we like
2938
- warn: {name: Use module export list}
3039

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ documentHighlight hf rf pos = MaybeT $ pure (Just highlights)
5656
ns = concat $ pointCommand hf pos (rights . M.keys . nodeIdentifiers . nodeInfo)
5757
highlights = do
5858
n <- ns
59-
ref <- maybe [] id (M.lookup (Right n) rf)
59+
ref <- fromMaybe [] (M.lookup (Right n) rf)
6060
pure $ makeHighlight ref
6161
makeHighlight (sp,dets) =
6262
DocumentHighlight (realSrcSpanToRange sp) (Just $ highlightType $ identInfo dets)
@@ -199,5 +199,3 @@ pointCommand hf pos k =
199199
sp fs = mkRealSrcSpan (sloc fs) (sloc fs)
200200
line = _line pos
201201
cha = _character pos
202-
203-

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ clientSupportsDocumentChanges caps =
142142
WorkspaceEditClientCapabilities mDc <- _workspaceEdit wCaps
143143
mDc
144144
in
145-
fromMaybe False supports
145+
Just True == supports
146146

147147
-- ---------------------------------------------------------------------
148148

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

227227

228228
allLspCmdIds :: T.Text -> [(PluginId, [PluginCommand ideState])] -> [T.Text]
229-
allLspCmdIds pid commands = concat $ map go commands
229+
allLspCmdIds pid commands = concatMap go commands
230230
where
231231
go (plid, cmds) = map (mkLspCmdId pid plid . commandId) cmds
232232

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

plugins/default/src/Ide/Plugin/Fourmolu.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ provider lf ideState typ contents fp fo = withIndefiniteProgress lf title Cancel
100100

101101
convertDynFlags :: DynFlags -> IO [DynOption]
102102
convertDynFlags df =
103-
let pp = if null p then [] else ["-pgmF=" <> p]
103+
let pp = ["-pgmF=" <> p | not (null p)]
104104
p = D.sPgm_F $ D.settings df
105105
pm = map (("-fplugin=" <>) . moduleNameString) $ D.pluginModNames df
106106
ex = map showExtension $ S.toList $ D.extensionFlags df

plugins/default/src/Ide/Plugin/Ormolu.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ provider lf ideState typ contents fp _ = withIndefiniteProgress lf title Cancell
4545
let
4646
pp =
4747
let p = D.sPgm_F $ D.settings df
48-
in if null p then [] else ["-pgmF=" <> p]
48+
in ["-pgmF=" <> p | not (null p)]
4949
pm = map (("-fplugin=" <>) . moduleNameString) $ D.pluginModNames df
5050
ex = map showExtension $ S.toList $ D.extensionFlags df
5151
in

plugins/default/src/Ide/Plugin/Pragmas.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Ide.Plugin.Pragmas
1414
import Control.Lens hiding (List)
1515
import Data.Aeson
1616
import qualified Data.HashMap.Strict as H
17+
import Data.Maybe (catMaybes)
1718
import qualified Data.Text as T
1819
import Development.IDE as D
1920
import qualified GHC.Generics as Generics
@@ -85,7 +86,7 @@ codeActionProvider _ state _plId docId _ (J.CodeActionContext (J.List diags) _mo
8586
disabled
8687
| Just dynFlags <- mDynflags
8788
-- GHC does not export 'OnOff', so we have to view it as string
88-
= [ e | Just e <- T.stripPrefix "Off " . T.pack . prettyPrint <$> extensions dynFlags]
89+
= catMaybes $ T.stripPrefix "Off " . T.pack . prettyPrint <$> extensions dynFlags
8990
| otherwise
9091
-- When the module failed to parse, we don't have access to its
9192
-- dynFlags. In that case, simply don't disable any pragmas.

0 commit comments

Comments
 (0)