Skip to content

Commit 21c8e9b

Browse files
andys8michaelpj
andauthored
Hlint: A handful of fixes to hints (#3259)
* CI: rwe/actions-hlint-run v2 * fmt script: Fix missing directories Otherwise will fail * Hlint: Automatically fix warnings via apply-refact * Hlint: Do not suggest fromMaybe Co-authored-by: Michael Peyton Jones <[email protected]>
1 parent 050497a commit 21c8e9b

File tree

18 files changed

+41
-38
lines changed

18 files changed

+41
-38
lines changed

.github/workflows/hlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
version: '3.4'
1919

2020
- name: 'Checking code'
21-
uses: rwe/actions-hlint-run@v1
21+
uses: rwe/actions-hlint-run@v2
2222
with:
2323
hlint-bin: "hlint --with-group=extra"
2424
fail-on: error

.hlint.yaml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- ignore: {name: "Use camelCase"}
2424
- ignore: {name: "Use uncurry"}
2525
- ignore: {name: "Avoid lambda using `infix`"}
26+
- ignore: {name: "Replace case with fromMaybe"}
2627

2728
# Gives at least one suggestion we don't like.
2829
- ignore: {name: "Use <=<"}
@@ -65,11 +66,11 @@
6566
- Wingman.Types
6667
- AutoTupleSpec
6768
- name: unsafeInterleaveIO
68-
within:
69+
within:
6970
- Development.IDE.LSP.LanguageServer
7071
- {name: unsafeDupablePerformIO, within: []}
7172
- name: unsafeCoerce
72-
within:
73+
within:
7374
- Ide.Plugin.Eval.Code
7475
- Development.IDE.Core.Compile
7576
- Development.IDE.Types.Shake
@@ -85,12 +86,12 @@
8586
- Compat.HieBin
8687

8788
# Partial functions
88-
89+
8990
# We need to check fucntions which
9091
# are typically exported multiple ways under both names,
9192
# see https://github.com/ndmitchell/hlint/issues/1389
9293
- name: [Prelude.head, Data.List.head]
93-
within:
94+
within:
9495
- Main
9596
- Experiments
9697
- Development.Benchmark.Rules
@@ -116,7 +117,7 @@
116117
- Wingman.Tactics
117118

118119
- name: [Prelude.tail, Data.List.tail]
119-
within:
120+
within:
120121
- Main
121122
- Development.Benchmark.Rules
122123
- Development.IDE.Plugin.CodeAction
@@ -125,7 +126,7 @@
125126
- UnificationSpec
126127

127128
- name: [Prelude.last, Data.List.last]
128-
within:
129+
within:
129130
- Main
130131
- Development.IDE.Plugin.CodeAction
131132
- Development.IDE.Plugin.CodeAction.ExactPrint
@@ -136,7 +137,7 @@
136137
- Ide.Plugin.Eval.CodeLens
137138

138139
- name: [Prelude.init, Data.List.init]
139-
within:
140+
within:
140141
- Main
141142
- Development.IDE.Spans.Common
142143
- Ide.PluginUtils
@@ -151,7 +152,7 @@
151152
within: []
152153

153154
- name: ["Prelude.!!", "Data.List.!!"]
154-
within:
155+
within:
155156
- Main
156157
- Experiments
157158
- FunctionalCodeAction
@@ -171,11 +172,11 @@
171172
within: []
172173

173174
- name: Data.Foldable.foldr1
174-
within:
175+
within:
175176
- Wingman.Tactics
176177

177-
- name: Data.Maybe.fromJust
178-
within:
178+
- name: Data.Maybe.fromJust
179+
within:
179180
- Experiments
180181
- Main
181182
- MultipleImports
@@ -193,7 +194,7 @@
193194
- Ide.Plugin.Class
194195

195196
- name: "Data.Map.!"
196-
within:
197+
within:
197198
- Wingman.LanguageServer
198199

199200
- name: "Data.IntMap.!"
@@ -210,7 +211,7 @@
210211
# Debug.Trace, because that module also
211212
# includes the eventlog tracing functions,
212213
# which are legitimate to use.
213-
- name:
214+
- name:
214215
- Debug.Trace.trace
215216
- Debug.Trace.traceId
216217
- Debug.Trace.traceShow
@@ -220,7 +221,7 @@
220221
- Debug.Trace.traceM
221222
- Debug.Trace.traceShowM
222223
- Debug.Trace.putTraceMsg
223-
within:
224+
within:
224225
- Development.IDE.Core.Compile
225226
- Development.IDE.Graph.Internal.Database
226227
- Development.IDE.GHC.Util

bench/Main.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
{-# LANGUAGE DerivingStrategies #-}
4545
{-# LANGUAGE TypeFamilies #-}
4646
{-# OPTIONS -Wno-orphans #-}
47-
{-# LANGUAGE PackageImports #-}
4847

4948
import Control.Lens (preview, (^.))
5049
import Control.Monad.Extra

exe/Wrapper.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
module Main where
1313

1414
import Control.Monad.Extra
15-
import Data.Char (isSpace)
1615
import Data.Default
1716
import Data.Either.Extra (eitherToMaybe)
1817
import Data.Foldable
1918
import Data.List
19+
import Data.List.Extra (trimEnd)
2020
import Data.Void
2121
import qualified Development.IDE.Session as Session
2222
import qualified HIE.Bios.Environment as HieBios
@@ -232,7 +232,7 @@ findProjectCradle' log = do
232232
trim :: String -> String
233233
trim s = case lines s of
234234
[] -> s
235-
ls -> dropWhileEnd isSpace $ last ls
235+
ls -> trimEnd $ last ls
236236

237237
data WrapperSetupError
238238
= FailedToObtainGhcVersion (ActionName Void) CradleError

fmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22
set -eou pipefail
3-
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s ghcide/src ghcide/exe ghcide/bench/lib ghcide/bench/exe ghcide/bench/hist shake-bench/src ghcide/test/exe --with-group=extra --hint=ghcide/.hlint.yaml
3+
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s ghcide/src ghcide/exe ghcide-bench/exe shake-bench/src ghcide/test/exe --with-group=extra --hint=.hlint.yaml

ghcide-bench/src/Experiments.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ runBench runSess b = handleAny (\e -> print e >> return badRun)
538538
output (showDuration t)
539539
-- Wait for the delayed actions to finish
540540
td <- waitForBuildQueue
541-
loop' (timeForFirstResponse <|> (Just (t,td))) (userWaits+t) (delayedWork+td) (n -1)
541+
loop' (timeForFirstResponse <|> Just (t,td)) (userWaits+t) (delayedWork+td) (n -1)
542542
loop = loop' Nothing
543543

544544
(runExperiment, result) <- duration $ loop 0 0 samples

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ captureSplicesAndDeps TypecheckHelpers{..} env k = do
308308
mods_transitive = getTransitiveMods hsc_env needed_mods
309309

310310
-- If we don't support multiple home units, ModuleNames are sufficient because all the units will be the same
311-
mods_transitive_list =
311+
mods_transitive_list =
312312
#if MIN_VERSION_ghc(9,3,0)
313313
mapMaybe nodeKeyToInstalledModule $ Set.toList mods_transitive
314314
#else
@@ -362,7 +362,7 @@ captureSplicesAndDeps TypecheckHelpers{..} env k = do
362362
#endif
363363

364364
-- Compute the transitive set of linkables required
365-
getTransitiveMods hsc_env needed_mods
365+
getTransitiveMods hsc_env needed_mods
366366
#if MIN_VERSION_ghc(9,3,0)
367367
= Set.unions (Set.fromList (map moduleToNodeKey mods) : [ dep | m <- mods
368368
, Just dep <- [Map.lookup (moduleToNodeKey m) (mgTransDeps (hsc_mod_graph hsc_env))]
@@ -561,7 +561,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
561561

562562

563563
when (not $ null diffs) $
564-
panicDoc "verify core failed!" (vcat $ punctuate (text "\n\n") (diffs )) -- ++ [ppr binds , ppr binds']))
564+
panicDoc "verify core failed!" (vcat $ punctuate (text "\n\n") diffs) -- ++ [ppr binds , ppr binds']))
565565
_ -> pure ()
566566

567567
pure ([], Just $! mkHiFileResult ms final_iface details (tmrRuntimeModules tcm) core_file)

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ typeCheckRuleDefinition hsc pm = do
697697

698698
unlift <- askUnliftIO
699699
let dets = TypecheckHelpers
700-
{ getLinkablesToKeep = unliftIO unlift $ currentLinkables
700+
{ getLinkablesToKeep = unliftIO unlift currentLinkables
701701
, getLinkables = unliftIO unlift . uses_ GetLinkable
702702
}
703703
addUsageDependencies $ liftIO $

ghcide/src/Development/IDE/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ testing recorder logger =
283283
hlsPlugins = pluginDescToIdePlugins $
284284
idePluginsToPluginDesc argsHlsPlugins
285285
++ [Test.blockCommandDescriptor "block-command", Test.plugin]
286-
ideOptions = \config sessionLoader ->
286+
ideOptions config sessionLoader =
287287
let
288288
defOptions = argsIdeOptions config sessionLoader
289289
in

hie-compat/src-ghc86/Compat/HieTypes.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ For more information see https://gitlab.haskell.org/ghc/ghc/wikis/hie-files
55
-}
66
{-# LANGUAGE DeriveTraversable #-}
77
{-# LANGUAGE DeriveDataTypeable #-}
8-
{-# LANGUAGE TypeSynonymInstances #-}
8+
99
{-# LANGUAGE FlexibleInstances #-}
1010
{-# LANGUAGE ScopedTypeVariables #-}
1111
{-# OPTIONS_GHC -Wno-orphans #-}

0 commit comments

Comments
 (0)