Skip to content

Commit a681e64

Browse files
newhoggyjbgi
authored andcommitted
Fix hlint warnings
1 parent d6970b9 commit a681e64

File tree

53 files changed

+145
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+145
-98
lines changed

.hlint.yaml

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
# placed as .hlint.yaml in the root of your project
77

88

9-
# Warnings currently triggered by your code
10-
- ignore: {name: "Move brackets to avoid $"}
11-
129
# Specify additional command line arguments
1310
#
1411
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
@@ -37,6 +34,12 @@
3734
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
3835
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
3936

37+
# The hints are named by the string they display in warning messages.
38+
# For example, if you see a warning starting like
39+
#
40+
# Main.hs:116:51: Warning: Redundant ==
41+
#
42+
# You can refer to that hint with `{name: Redundant ==}` (see below).
4043

4144
# Turn on hints that are off by default
4245
#
@@ -53,7 +56,7 @@
5356
# Ignore some builtin hints
5457
# - ignore: {name: Use let}
5558
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
56-
# - ignore: {name: "Use lambda-case"}
59+
5760

5861
# Define some custom infix operators
5962
# - fixity: infixr 3 ~^#^~

bench/cardano-topology/cardano-topology.hs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
{-# LANGUAGE TupleSections #-}
55
{-# OPTIONS_GHC -Wno-partial-fields -Wno-name-shadowing #-}
66

7+
{- HLINT ignore "Redundant id" -}
8+
{- HLINT ignore "Use concatMap" -}
9+
710
import Prelude hiding (id)
811

912
import Data.Aeson

bench/locli/src/Cardano/Analysis/API/Dictionary.hs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{-# LANGUAGE DeriveAnyClass #-}
2+
3+
{- HLINT ignore "Evaluate" -}
4+
25
module Cardano.Analysis.API.Dictionary (module Cardano.Analysis.API.Dictionary) where
36

47
import Cardano.Prelude

bench/locli/src/Cardano/Analysis/API/Ground.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ dumpAssociatedObjects ident xs = liftIO $
329329

330330
readAssociatedObjects :: forall a.
331331
FromJSON a => String -> [JsonLogfile] -> ExceptT Text IO [(JsonLogfile, a)]
332-
readAssociatedObjects ident fs = firstExceptT T.pack . newExceptT . fmap sequence . fmap (fmap sequence) $
332+
readAssociatedObjects ident fs = firstExceptT T.pack . newExceptT . fmap (mapM sequence) $
333333
flip mapConcurrently fs $
334334
\jf@(JsonLogfile f) -> do
335335
x <- eitherDecode @a <$> LBS.readFile (replaceExtension f $ ident <> ".json")

bench/locli/src/Cardano/Analysis/BlockProp.hs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{-# LANGUAGE DeriveAnyClass #-}
22
{-# LANGUAGE StrictData #-}
3+
34
{-# OPTIONS_GHC -Wno-incomplete-patterns -Wno-name-shadowing #-}
45
{-# OPTIONS_GHC -Wno-unused-imports -Wno-partial-fields -Wno-unused-matches -Wno-deprecations -Wno-unused-local-binds -Wno-incomplete-record-updates #-}
5-
{- HLINT ignore "Use head" -}
6+
67
{- HLINT ignore "Avoid lambda" -}
8+
{- HLINT ignore "Eta reduce" -}
9+
{- HLINT ignore "Use head" -}
10+
711
module Cardano.Analysis.BlockProp
812
( summariseMultiBlockProp
913
, MachView

bench/locli/src/Cardano/Analysis/MachPerf.hs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{-# LANGUAGE StrictData #-}
2+
23
{-# OPTIONS_GHC -Wno-incomplete-patterns -Wno-name-shadowing -Wno-orphans #-}
4+
35
{- HLINT ignore "Use head" -}
6+
{- HLINT ignore "Evaluate" -}
7+
48
module Cardano.Analysis.MachPerf (module Cardano.Analysis.MachPerf) where
59

610
import Cardano.Prelude hiding (head)

bench/locli/src/Cardano/Analysis/Summary.hs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{-# LANGUAGE UndecidableInstances #-}
2+
23
{-# OPTIONS_GHC -Wno-name-shadowing -Wno-orphans #-}
4+
5+
{- HLINT ignore "Use mapMaybe" -}
6+
37
module Cardano.Analysis.Summary (module Cardano.Analysis.Summary) where
48

59
import Prelude (head, last)

bench/locli/src/Cardano/Render.hs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
{-# LANGUAGE TypeInType #-}
21
{-# LANGUAGE ScopedTypeVariables #-}
2+
{-# LANGUAGE TypeInType #-}
3+
4+
{- HLINT ignore "Use concatMap" -}
5+
{- HLINT ignore "Use fromMaybe" -}
6+
37
module Cardano.Render (module Cardano.Render) where
48

59
import Prelude (id, show)

bench/locli/src/Cardano/Unlog/LogObject.hs

+5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
{-# LANGUAGE ScopedTypeVariables #-}
66
{-# LANGUAGE StandaloneDeriving #-}
77
{-# LANGUAGE ViewPatterns #-}
8+
89
{-# OPTIONS_GHC -Wno-partial-fields -Wno-orphans #-}
910

11+
{- HLINT ignore "Redundant <$>" -}
12+
{- HLINT ignore "Redundant if" -}
13+
{- HLINT ignore "Use infix" -}
14+
1015
module Cardano.Unlog.LogObject (module Cardano.Unlog.LogObject) where
1116

1217
import Cardano.Prelude hiding (Text, head, show)

bench/locli/src/Data/CDF.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{-# LANGUAGE DeriveAnyClass #-}
22
{-# LANGUAGE DeriveFunctor #-}
33
{-# LANGUAGE DeriveGeneric #-}
4-
{-# LANGUAGE GADTs #-}
5-
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
64
{-# LANGUAGE FlexibleContexts #-}
75
{-# LANGUAGE FlexibleInstances #-}
8-
{-# LANGUAGE ImportQualifiedPost #-}
6+
{-# LANGUAGE GADTs #-}
7+
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
98
{-# LANGUAGE LambdaCase #-}
109
{-# LANGUAGE MultiParamTypeClasses #-}
1110
{-# LANGUAGE ScopedTypeVariables #-}
@@ -14,6 +13,8 @@
1413
{-# LANGUAGE ViewPatterns #-}
1514
{-# OPTIONS_GHC -Wwarn #-}
1615

16+
{- HLINT ignore "Use infix" -}
17+
1718
module Data.CDF
1819
( Centile(..)
1920
, renderCentile

bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx.hs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
{-# OPTIONS_GHC -Wno-missed-specialisations #-}
99
{-# OPTIONS_GHC -Wno-orphans #-}
1010

11+
{- HLINT ignore "Redundant <$>" -}
12+
1113
module Cardano.Benchmarking.GeneratorTx
1214
( AsyncBenchmarkControl
1315
, walletBenchmark

bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/Submission.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
{-# LANGUAGE MultiParamTypeClasses #-}
99
{-# LANGUAGE NamedFieldPuns #-}
1010
{-# LANGUAGE NoMonomorphismRestriction #-}
11-
{-# LANGUAGE OverloadedStrings #-}
1211
{-# LANGUAGE RankNTypes #-}
1312
{-# LANGUAGE RecordWildCards #-}
1413
{-# LANGUAGE ScopedTypeVariables #-}
@@ -102,7 +101,7 @@ mkSubmissionSummary ::
102101
-> IO SubmissionSummary
103102
mkSubmissionSummary ssThreadName startTime reportsRefs
104103
= do
105-
results <- sequence (STM.atomically . STM.readTMVar <$> reportsRefs)
104+
results <- mapM (STM.atomically . STM.readTMVar) reportsRefs
106105
let (failures, reports) = partitionEithers results
107106
now <- Clock.getCurrentTime
108107
let ssElapsed = Clock.diffUTCTime now startTime

bench/tx-generator/src/Cardano/Benchmarking/Script.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ runScript script iom = runActionM execScript iom >>= \case
4545
shutDownLogging :: ActionM ()
4646
shutDownLogging = do
4747
traceError "QRT Last Message. LoggingLayer going to shutdown. 73 . . . ."
48-
liftIO $ threadDelay (200*1000)
48+
liftIO $ threadDelay (200 * 1_000)

bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ addFund era wallet txIn lovelace keyName = do
103103
fundKey <- getEnvKeys keyName
104104
let
105105
mkOutValue :: forall era. IsShelleyBasedEra era => AsType era -> ActionM (InAnyCardanoEra TxOutValue)
106-
mkOutValue = \_ -> return $ InAnyCardanoEra (cardanoEra @era) (lovelaceToTxOutValue lovelace)
106+
mkOutValue _ = return $ InAnyCardanoEra (cardanoEra @era) (lovelaceToTxOutValue lovelace)
107107
outValue <- withEra era mkOutValue
108108
addFundToWallet wallet txIn outValue fundKey
109109

@@ -123,7 +123,7 @@ getLocalSubmitTx :: ActionM LocalSubmitTx
123123
getLocalSubmitTx = submitTxToNodeLocal <$> getLocalConnectInfo
124124

125125
delay :: Double -> ActionM ()
126-
delay t = liftIO $ threadDelay $ floor $ 1000000 * t
126+
delay t = liftIO $ threadDelay $ floor $ 1_000_000 * t
127127

128128
waitBenchmarkCore :: AsyncBenchmarkControl -> ActionM ()
129129
waitBenchmarkCore ctl = do

bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
{-# LANGUAGE ScopedTypeVariables #-}
55
{-# LANGUAGE TypeApplications #-}
66

7+
{- HLINT ignore "Use map" -}
8+
79
-- | This module provides means to secure funds that are given in genesis.
810
-- To secure a fund, the key locking the transaction ouput in genesis has to be provided.
911
module Cardano.TxGenerator.Genesis

bench/tx-generator/test/ApiTest.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
88

9+
{- HLINT ignore "Use map" -}
10+
911
module Main (main) where
1012

1113
import Control.Monad
@@ -150,7 +152,7 @@ checkPlutusLoop (Just PlutusOn{..})
150152
putStrLn $ "--> Read plutus script: " ++ plutusScript
151153
protocolParameters <- readProtocolParametersOrDie
152154

153-
let count = 1792 -- arbitrary counter for a loop script; should respect mainnet limits
155+
let count = 1_792 -- arbitrary counter for a loop script; should respect mainnet limits
154156

155157
redeemerFile <- getRedeemerFile
156158
redeemer <- readScriptData redeemerFile >>= \case

cardano-api/src/Cardano/Api/Error.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ instance Error e => Error (FileError e) where
5959
path ++ ": " ++ displayError e
6060

6161
instance Error IOException where
62-
displayError ioEx = show ioEx
62+
displayError = show
6363

cardano-api/src/Cardano/Api/LedgerState.hs

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
{-# LANGUAGE ScopedTypeVariables #-}
1111
{-# LANGUAGE TypeApplications #-}
1212

13+
{- HLINT ignore "Redundant fmap" -}
14+
1315
module Cardano.Api.LedgerState
1416
( -- * Initialization / Accumulation
1517
Env(..)
@@ -761,8 +763,8 @@ data NodeConfig = NodeConfig
761763
}
762764

763765
instance FromJSON NodeConfig where
764-
parseJSON v =
765-
Aeson.withObject "NodeConfig" parse v
766+
parseJSON =
767+
Aeson.withObject "NodeConfig" parse
766768
where
767769
parse :: Object -> Parser NodeConfig
768770
parse o =
@@ -1076,9 +1078,8 @@ readShelleyGenesis (GenesisFile file) expectedGenesisHash = do
10761078
where
10771079
checkExpectedGenesisHash :: GenesisHashShelley -> ExceptT ShelleyGenesisError IO ()
10781080
checkExpectedGenesisHash actual =
1079-
if actual /= expectedGenesisHash
1080-
then left (ShelleyGenesisHashMismatch actual expectedGenesisHash)
1081-
else pure ()
1081+
when (actual /= expectedGenesisHash) $
1082+
left (ShelleyGenesisHashMismatch actual expectedGenesisHash)
10821083

10831084
data ShelleyGenesisError
10841085
= ShelleyGenesisReadError !FilePath !Text
@@ -1121,9 +1122,8 @@ readAlonzoGenesis (GenesisFile file) expectedGenesisHash = do
11211122
where
11221123
checkExpectedGenesisHash :: GenesisHashAlonzo -> ExceptT AlonzoGenesisError IO ()
11231124
checkExpectedGenesisHash actual =
1124-
if actual /= expectedGenesisHash
1125-
then left (AlonzoGenesisHashMismatch actual expectedGenesisHash)
1126-
else pure ()
1125+
when (actual /= expectedGenesisHash) $
1126+
left (AlonzoGenesisHashMismatch actual expectedGenesisHash)
11271127

11281128
data AlonzoGenesisError
11291129
= AlonzoGenesisReadError !FilePath !Text

cardano-api/src/Cardano/Api/ProtocolParameters.hs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
{-# LANGUAGE ScopedTypeVariables #-}
99
{-# LANGUAGE TypeFamilies #-}
1010

11+
{- HLINT ignore "Redundant ==" -}
12+
1113
-- | The various Cardano protocol parameters, including:
1214
--
1315
-- * the current values of updatable protocol parameters: 'ProtocolParameters'

cardano-cli/src/Cardano/CLI/Byron/Genesis.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@ mkGenesisSpec gp = do
118118

119119
where
120120
mkGenesisInitialiser :: Bool -> Genesis.GenesisInitializer
121-
mkGenesisInitialiser useHeavyDlg =
121+
mkGenesisInitialiser =
122122
Genesis.GenesisInitializer
123123
(gpTestnetBalance gp)
124124
(gpFakeAvvmOptions gp)
125125
(Common.lovelacePortionToRational (gpAvvmBalanceFactor gp))
126-
useHeavyDlg
127126

128127
-- | Generate a genesis, for given blockchain start time, protocol parameters,
129128
-- security parameter, protocol magic, testnet balance options, fake AVVM options,
@@ -169,7 +168,7 @@ dumpGenesis (NewDirectory outDir) genesisData gs = do
169168
else liftIO $ createDirectory outDir
170169
liftIO $ LB.writeFile genesisJSONFile (canonicalEncodePretty genesisData)
171170

172-
dlgCerts <- mapM findDelegateCert . map ByronSigningKey $ gsRichSecrets gs
171+
dlgCerts <- mapM (findDelegateCert . ByronSigningKey) $ gsRichSecrets gs
173172

174173
liftIO $ wOut "genesis-keys" "key"
175174
serialiseToRawBytes

cardano-cli/src/Cardano/CLI/Byron/Tx.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ nodeSubmitTx network gentx = do
245245
--TODO: remove these local definitions when the updated ledger lib is available
246246
fromCborTxAux :: LB.ByteString -> Either Binary.DecoderError (UTxO.ATxAux B.ByteString)
247247
fromCborTxAux lbs =
248-
fmap (annotationBytes lbs)
249-
$ Binary.decodeFullDecoder "Cardano.Chain.UTxO.TxAux.fromCborTxAux"
248+
annotationBytes lbs
249+
<$> Binary.decodeFullDecoder "Cardano.Chain.UTxO.TxAux.fromCborTxAux"
250250
Binary.fromCBOR lbs
251251
where
252252
annotationBytes :: Functor f => LB.ByteString -> f Binary.ByteSpan -> f B.ByteString

cardano-cli/src/Cardano/CLI/Helpers.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,23 @@ validateCBOR :: CBORObject -> LByteString -> Either HelpersError Text
104104
validateCBOR cborObject bs =
105105
case cborObject of
106106
CBORBlockByron epochSlots -> do
107-
() <$ decodeCBOR bs (fromCBORABlockOrBoundary epochSlots)
107+
void $ decodeCBOR bs (fromCBORABlockOrBoundary epochSlots)
108108
Right "Valid Byron block."
109109

110110
CBORDelegationCertificateByron -> do
111-
() <$ decodeCBOR bs (fromCBOR :: Decoder s Delegation.Certificate)
111+
void $ decodeCBOR bs (fromCBOR :: Decoder s Delegation.Certificate)
112112
Right "Valid Byron delegation certificate."
113113

114114
CBORTxByron -> do
115-
() <$ decodeCBOR bs (fromCBOR :: Decoder s UTxO.Tx)
115+
void $ decodeCBOR bs (fromCBOR :: Decoder s UTxO.Tx)
116116
Right "Valid Byron Tx."
117117

118118
CBORUpdateProposalByron -> do
119-
() <$ decodeCBOR bs (fromCBOR :: Decoder s Update.Proposal)
119+
void $ decodeCBOR bs (fromCBOR :: Decoder s Update.Proposal)
120120
Right "Valid Byron update proposal."
121121

122122
CBORVoteByron -> do
123-
() <$ decodeCBOR bs (fromCBOR :: Decoder s Update.Vote)
123+
void $ decodeCBOR bs (fromCBOR :: Decoder s Update.Vote)
124124
Right "Valid Byron vote."
125125

126126
-- | Convert an Either to a Maybe and execute the supplied handler

cardano-cli/src/Cardano/CLI/Parsers.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{-# LANGUAGE FlexibleContexts #-}
22
{-# LANGUAGE OverloadedStrings #-}
33

4+
{- HLINT ignore "Monoid law, left identity" -}
5+
46
module Cardano.CLI.Parsers
57
( opts
68
, pref
79
) where
810

9-
import Cardano.Prelude
1011
import Cardano.CLI.Byron.Parsers (backwardsCompatibilityCommands, parseByronCommands)
1112
import Cardano.CLI.Render (customRenderHelp)
1213
import Cardano.CLI.Run (ClientCommand (..))
1314
import Cardano.CLI.Shelley.Parsers (parseShelleyCommands)
15+
import Cardano.Prelude
1416
import Options.Applicative
1517
import Prelude (String)
1618

cardano-cli/src/Cardano/CLI/Render.hs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{- HLINT ignore "Redundant id" -}
2+
13
module Cardano.CLI.Render
24
( customRenderHelp
35
) where

cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1502,14 +1502,14 @@ pTxMetadataJsonSchema =
15021502
( Opt.long "json-metadata-no-schema"
15031503
<> Opt.help "Use the \"no schema\" conversion from JSON to tx metadata."
15041504
)
1505-
*> pure TxMetadataJsonNoSchema
1505+
$> TxMetadataJsonNoSchema
15061506
)
15071507
<|>
15081508
( Opt.flag' ()
15091509
( Opt.long "json-metadata-detailed-schema"
15101510
<> Opt.help "Use the \"detailed schema\" conversion from JSON to tx metadata."
15111511
)
1512-
*> pure TxMetadataJsonDetailedSchema
1512+
$> TxMetadataJsonDetailedSchema
15131513
)
15141514
<|>
15151515
-- Default to the no-schema conversion.

0 commit comments

Comments
 (0)