Skip to content

Commit 9b26df8

Browse files
authored
Merge pull request #11093 from cabalism/hlint/onesies
Apply hlint suggestions with a single count
2 parents e97d042 + 7b67d02 commit 9b26df8

File tree

16 files changed

+49
-71
lines changed

16 files changed

+49
-71
lines changed

.hlint.yaml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,55 @@
22
- ignore: {name: "Avoid NonEmpty.unzip"} # 1 hint
33
- ignore: {name: "Avoid lambda"} # 50 hints
44
- ignore: {name: "Avoid lambda using `infix`"} # 23 hints
5-
- ignore: {name: "Eta reduce"} # 132 hints
5+
- ignore: {name: "Eta reduce"} # 136 hints
66
- ignore: {name: "Evaluate"} # 10 hints
77
- ignore: {name: "Functor law"} # 10 hints
88
- ignore: {name: "Fuse concatMap/map"} # 3 hints
99
- ignore: {name: "Fuse foldr/map"} # 3 hints
10-
- ignore: {name: "Fuse traverse_/fmap"} # 1 hint
11-
- ignore: {name: "Fuse traverse_/map"} # 1 hint
1210
- ignore: {name: "Hoist not"} # 16 hints
13-
- ignore: {name: "Missing NOINLINE pragma"} # 1 hint
1411
- ignore: {name: "Monoid law, left identity"} # 3 hints
1512
- ignore: {name: "Monoid law, right identity"} # 3 hints
1613
- ignore: {name: "Move filter"} # 4 hints
1714
- ignore: {name: "Move guards forward"} # 4 hints
18-
- ignore: {name: "Redundant $"} # 192 hints
15+
- ignore: {name: "Redundant $"} # 202 hints
1916
- ignore: {name: "Redundant $!"} # 1 hint
20-
- ignore: {name: "Redundant <$>"} # 17 hints
21-
- ignore: {name: "Redundant =="} # 1 hint
22-
- ignore: {name: "Redundant bracket"} # 260 hints
23-
- ignore: {name: "Redundant fmap"} # 1 hint
17+
- ignore: {name: "Redundant <$>"} # 18 hints
18+
- ignore: {name: "Redundant bracket"} # 274 hints
2419
- ignore: {name: "Redundant guard"} # 2 hints
2520
- ignore: {name: "Redundant if"} # 6 hints
2621
- ignore: {name: "Redundant lambda"} # 19 hints
2722
- ignore: {name: "Redundant maybe"} # 2 hints
2823
- ignore: {name: "Redundant multi-way if"} # 1 hint
29-
- ignore: {name: "Redundant return"} # 9 hints
24+
- ignore: {name: "Redundant return"} # 10 hints
3025
- ignore: {name: "Replace case with fromMaybe"} # 4 hints
3126
- ignore: {name: "Replace case with maybe"} # 10 hints
3227
- ignore: {name: "Use $>"} # 5 hints
3328
- ignore: {name: "Use ++"} # 4 hints
3429
- ignore: {name: "Use :"} # 28 hints
3530
- ignore: {name: "Use <$"} # 2 hints
36-
- ignore: {name: "Use <$>"} # 86 hints
37-
- ignore: {name: "Use <&>"} # 15 hints
31+
- ignore: {name: "Use <$>"} # 88 hints
32+
- ignore: {name: "Use <&>"} # 16 hints
3833
- ignore: {name: "Use <=<"} # 4 hints
3934
- ignore: {name: "Use =<<"} # 7 hints
4035
- ignore: {name: "Use =="} # 3 hints
4136
- ignore: {name: "Use >=>"} # 3 hints
42-
- ignore: {name: "Use ?~"} # 1 hint
4337
- ignore: {name: "Use Down"} # 3 hints
4438
- ignore: {name: "Use bimap"} # 7 hints
45-
- ignore: {name: "Use camelCase"} # 94 hints
46-
- ignore: {name: "Use catMaybes"} # 3 hints
39+
- ignore: {name: "Use camelCase"} # 96 hints
40+
- ignore: {name: "Use catMaybes"} # 4 hints
4741
- ignore: {name: "Use concatMap"} # 2 hints
4842
- ignore: {name: "Use const"} # 37 hints
4943
- ignore: {name: "Use elem"} # 2 hints
5044
- ignore: {name: "Use first"} # 5 hints
5145
- ignore: {name: "Use fmap"} # 24 hints
5246
- ignore: {name: "Use fold"} # 1 hint
53-
- ignore: {name: "Use for"} # 1 hint
54-
- ignore: {name: "Use forM_"} # 1 hint
5547
- ignore: {name: "Use fromMaybe"} # 5 hints
56-
- ignore: {name: "Use fromRight"} # 1 hint
5748
- ignore: {name: "Use fst"} # 2 hints
5849
- ignore: {name: "Use infix"} # 20 hints
5950
- ignore: {name: "Use isAsciiLower"} # 2 hints
6051
- ignore: {name: "Use isAsciiUpper"} # 2 hints
6152
- ignore: {name: "Use isDigit"} # 2 hints
62-
- ignore: {name: "Use isJust"} # 1 hint
63-
- ignore: {name: "Use isNothing"} # 1 hint
6453
- ignore: {name: "Use lambda-case"} # 58 hints
65-
- ignore: {name: "Use lefts"} # 1 hint
6654
- ignore: {name: "Use list comprehension"} # 19 hints
6755
- ignore: {name: "Use list literal"} # 3 hints
6856
- ignore: {name: "Use list literal pattern"} # 11 hints
@@ -71,24 +59,19 @@
7159
- ignore: {name: "Use mapMaybe"} # 13 hints
7260
- ignore: {name: "Use max"} # 2 hints
7361
- ignore: {name: "Use maybe"} # 8 hints
74-
- ignore: {name: "Use minimumBy"} # 1 hint
75-
- ignore: {name: "Use newtype instead of data"} # 29 hints
62+
- ignore: {name: "Use newtype instead of data"} # 31 hints
7663
- ignore: {name: "Use notElem"} # 9 hints
7764
- ignore: {name: "Use null"} # 2 hints
7865
- ignore: {name: "Use record patterns"} # 16 hints
79-
- ignore: {name: "Use replicateM"} # 1 hint
8066
- ignore: {name: "Use replicateM_"} # 2 hints
8167
- ignore: {name: "Use rights"} # 2 hints
8268
- ignore: {name: "Use second"} # 7 hints
8369
- ignore: {name: "Use section"} # 18 hints
84-
- ignore: {name: "Use traverse"} # 1 hint
85-
- ignore: {name: "Use tuple-section"} # 27 hints
70+
- ignore: {name: "Use tuple-section"} # 28 hints
8671
- ignore: {name: "Use typeRep"} # 2 hints
87-
- ignore: {name: "Use uncurry"} # 1 hint
8872
- ignore: {name: "Use unless"} # 23 hints
8973
- ignore: {name: "Use unwords"} # 8 hints
9074
- ignore: {name: "Use void"} # 23 hints
91-
- ignore: {name: "Use when"} # 1 hint
9275

9376
- arguments:
9477
- --ignore-glob=Cabal-syntax/src/Distribution/Fields/Lexer.hs

Cabal-syntax/src/Distribution/Compat/Parsing.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import Control.Monad.Trans.Writer.Lazy as Lazy
5858
import Control.Monad.Trans.Writer.Strict as Strict
5959
import Data.Foldable (asum)
6060

61+
import Control.Monad (replicateM)
6162
import qualified Data.List.NonEmpty as NE
6263
import qualified Text.Parsec as Parsec
6364

@@ -141,7 +142,7 @@ endBy p sep = many (p <* sep)
141142
count :: Applicative m => Int -> m a -> m [a]
142143
count n p
143144
| n <= 0 = pure []
144-
| otherwise = sequenceA (replicate n p)
145+
| otherwise = replicateM n p
145146
{-# INLINE count #-}
146147

147148
-- | @chainr p op x@ parses /zero/ or more occurrences of @p@,

Cabal-tests/tests/UnitTests/Distribution/Version.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ prop_anyVersion v' =
195195

196196
prop_noVersion :: Version -> Bool
197197
prop_noVersion v' =
198-
withinRange v' noVersion == False
198+
not (withinRange v' noVersion)
199199

200200
prop_thisVersion :: Version -> Version -> Bool
201201
prop_thisVersion v v' =

Cabal/src/Distribution/Simple/BuildPaths.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ getSourceFiles
320320
-> [SymbolicPathX allowAbsolute Pkg (Dir Source)]
321321
-> [ModuleName.ModuleName]
322322
-> IO [(ModuleName.ModuleName, SymbolicPathX allowAbsolute Pkg File)]
323-
getSourceFiles verbosity mbWorkDir dirs modules = flip traverse modules $ \m ->
323+
getSourceFiles verbosity mbWorkDir dirs modules = for modules $ \m ->
324324
fmap ((,) m) $
325325
findFileCwdWithExtension
326326
mbWorkDir

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ configurePackage cfg lbc0 pkg_descr00 flags enabled comp platform programDb0 pac
883883
let unknownBuildTools =
884884
[ buildTool
885885
| buildTool <- buildTools bi
886-
, Nothing == desugarBuildTool pkg_descr0 buildTool
886+
, isNothing (desugarBuildTool pkg_descr0 buildTool)
887887
]
888888
externBuildToolDeps ++ unknownBuildTools
889889

@@ -2766,7 +2766,7 @@ checkPackageProblems verbosity dir gpkg pkg = do
27662766
(errors, warnings) =
27672767
partitionEithers (M.mapMaybe classEW $ pureChecks ++ ioChecks)
27682768
if null errors
2769-
then traverse_ (warn verbosity) (map ppPackageCheck warnings)
2769+
then traverse_ (warn verbosity . ppPackageCheck) warnings
27702770
else dieWithException verbosity $ CheckPackageProblems (map ppPackageCheck errors)
27712771
where
27722772
-- Classify error/warnings. Left: error, Right: warning.
@@ -2836,22 +2836,19 @@ checkRelocatable verbosity pkg lbi =
28362836
p = prefix installDirs
28372837
relativeInstallDirs (InstallDirs{..}) =
28382838
all
2839-
isJust
2840-
( fmap
2841-
(stripPrefix p)
2842-
[ bindir
2843-
, libdir
2844-
, dynlibdir
2845-
, libexecdir
2846-
, includedir
2847-
, datadir
2848-
, docdir
2849-
, mandir
2850-
, htmldir
2851-
, haddockdir
2852-
, sysconfdir
2853-
]
2854-
)
2839+
(isJust . stripPrefix p)
2840+
[ bindir
2841+
, libdir
2842+
, dynlibdir
2843+
, libexecdir
2844+
, includedir
2845+
, datadir
2846+
, docdir
2847+
, mandir
2848+
, htmldir
2849+
, haddockdir
2850+
, sysconfdir
2851+
]
28552852

28562853
-- Check if the library dirs of the dependencies that are in the package
28572854
-- database to which the package is installed are relative to the

Cabal/src/Distribution/Simple/GHCJS.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ buildOrReplLib mReplFlags verbosity numJobs _pkg_descr lbi lib clbi = do
537537
whenStaticLib forceStatic =
538538
when (forceStatic || withStaticLib lbi)
539539
-- whenGHCiLib = when (withGHCiLib lbi)
540-
forRepl = maybe False (const True) mReplFlags
540+
forRepl = isJust mReplFlags
541541
-- ifReplLib = when forRepl
542542
comp = compiler lbi
543543
implInfo = getImplInfo comp

Cabal/src/Distribution/Simple/Haddock.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import Distribution.Version
8989

9090
import Control.Monad
9191
import Data.Bool (bool)
92-
import Data.Either (rights)
92+
import Data.Either (lefts, rights)
9393
import System.Directory (doesDirectoryExist, doesFileExist)
9494
import System.FilePath (isAbsolute, normalise)
9595
import System.IO (hClose, hPutStrLn, hSetEncoding, utf8)
@@ -1386,7 +1386,7 @@ haddockPackagePaths ipkgs mkHtmlPath = do
13861386
, pkgName pkgid `notElem` noHaddockWhitelist
13871387
]
13881388

1389-
let missing = [pkgid | Left pkgid <- interfaces]
1389+
let missing = lefts interfaces
13901390
warning =
13911391
"The following packages have no Haddock documentation "
13921392
++ "installed. No links will be generated to these packages: "

cabal-install/src/Distribution/Client/BuildReports/Upload.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Network.TCP (HandleStream)
2121
-}
2222
import Network.URI (URI, uriPath) -- parseRelativeReference, relativeTo)
2323

24+
import Data.Foldable (forM_)
2425
import Distribution.Client.BuildReports.Anonymous (BuildReport, showBuildReport)
2526
import qualified Distribution.Client.BuildReports.Anonymous as BuildReport
2627
import Distribution.Client.Errors
@@ -41,9 +42,7 @@ uploadReports :: Verbosity -> RepoContext -> Auth -> URI -> [(BuildReport, Maybe
4142
uploadReports verbosity repoCtxt auth uri reports = do
4243
for_ reports $ \(report, mbBuildLog) -> do
4344
buildId <- postBuildReport verbosity repoCtxt auth uri report
44-
case mbBuildLog of
45-
Just buildLog -> putBuildLog verbosity repoCtxt auth buildId buildLog
46-
Nothing -> return ()
45+
forM_ mbBuildLog (putBuildLog verbosity repoCtxt auth buildId)
4746

4847
postBuildReport :: Verbosity -> RepoContext -> Auth -> URI -> BuildReport -> IO BuildReportId
4948
postBuildReport verbosity repoCtxt auth uri buildReport = do

cabal-install/src/Distribution/Client/CmdOutdated.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ outdatedAction flags targetStrings globalFlags =
266266
(ListOutdatedSettings ignorePred minorPred)
267267
when (not quiet) $
268268
showResult verbosity outdatedDeps simpleOutput
269-
if exitCode && (not . null $ outdatedDeps)
270-
then exitFailure
271-
else return ()
269+
when (exitCode && (not . null $ outdatedDeps)) exitFailure
272270
where
273271
OutdatedFlags{..} = extraFlags flags
274272
verbosity =

cabal-install/src/Distribution/Client/CmdRepl.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g
297297
let
298298
sourcePackage =
299299
fakeProjectSourcePackage projectRoot
300-
& lSrcpkgDescription . L.condLibrary
301-
.~ Just (CondNode library [baseDep] [])
300+
& ( (lSrcpkgDescription . L.condLibrary)
301+
?~ (CondNode library [baseDep] [])
302+
)
302303
library = emptyLibrary{libBuildInfo = lBuildInfo}
303304
lBuildInfo =
304305
emptyBuildInfo

0 commit comments

Comments
 (0)