Skip to content

Commit b882df5

Browse files
committed
refactor: Fix hlint violations
1 parent 0461b36 commit b882df5

File tree

14 files changed

+32
-31
lines changed

14 files changed

+32
-31
lines changed

.hlint.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,31 @@
2121
# - flags:
2222
# - {name: -w, within: []} # -w is allowed nowhere
2323
#
24-
# - modules:
25-
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
26-
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
27-
#
28-
# - functions:
29-
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
30-
3124

3225
- modules:
3326
# If Data.List is imported qualified, it must be as 'List'
3427
- {name: [Data.List], as: List}
3528
- {name: [Data.Map.Strict], as: Map}
3629
- {name: [Data.Set], as: Set}
3730
- {name: [Data.Text], as: Text}
38-
- {name: [Data.ByteString.Char8], as: BS}
39-
- {name: [Data.ByteString.Lazy.Char8], as: LBS}
4031
- {name: [Data.ByteString.Short], as: SBS}
4132

42-
# Banned functions
4333
- functions:
4434
- {name: coerce, within: []}
35+
- {name: unsafePerformIO, within: []}
4536

4637
# Add custom hints for this project
4738
#
4839
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
4940
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
5041

42+
# The hints are named by the string they display in warning messages.
43+
# For example, if you see a warning starting like
44+
#
45+
# Main.hs:116:51: Warning: Redundant ==
46+
#
47+
# You can refer to that hint with `{name: Redundant ==}` (see below).
48+
5149
# The monad of no return will be here one day
5250
- error: {lhs: "return x", rhs: pure x}
5351

@@ -62,12 +60,19 @@
6260
#
6361
# Generalise map to fmap, ++ to <>
6462
# - group: {name: generalise, enabled: true}
63+
#
64+
# Warn on use of partial functions
65+
# - group: {name: partial, enabled: true}
6566

6667

6768
# Ignore some builtin hints
6869
# - ignore: {name: Use let}
6970
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
7071

72+
# Fuse on/on conflicts with Esqueleto's `on`
73+
- ignore: { name: "Fuse on/on" }
74+
75+
7176

7277
# Define some custom infix operators
7378
# - fixity: infixr 3 ~^#^~

cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Conway/Scenarios.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ delegateAndSendBlocks n interpreter = do
5151
stakeCreds = createStakeCredentials n
5252
payCreds = createPaymentCredentials n
5353
addresses =
54-
map
55-
(\(payCred, stakeCred) -> Addr Testnet payCred (StakeRefBase stakeCred))
56-
(zip payCreds stakeCreds)
54+
zipWith
55+
(\payCred stakeCred -> Addr Testnet payCred (StakeRefBase stakeCred))
56+
payCreds
57+
stakeCreds
5758

5859
mkRegisterBlocks :: [StakeCredential] -> Interpreter -> IO [CardanoBlock]
5960
mkRegisterBlocks creds interpreter = forgeBlocksChunked interpreter creds $ \txCreds _ ->
@@ -65,7 +66,7 @@ mkRegisterBlocks creds interpreter = forgeBlocksChunked interpreter creds $ \txC
6566
mkDelegateBlocks :: [StakeCredential] -> Interpreter -> IO [CardanoBlock]
6667
mkDelegateBlocks creds interpreter = forgeBlocksChunked interpreter creds $ \txCreds state' ->
6768
Conway.mkDCertTx
68-
(map (mkDelegCert state') $ zip (cycle [0, 1, 2]) txCreds)
69+
(zipWith (curry (mkDelegCert state')) (cycle [0, 1, 2]) txCreds)
6970
(Withdrawals mempty)
7071
Nothing
7172
where

cardano-chain-gen/src/Cardano/Mock/Query.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ queryTreasuryDonations = do
176176
txs <- from $ table @Db.Tx
177177
pure $ sum_ (txs ^. Db.TxTreasuryDonation)
178178

179-
let total = join (unValue <$> res)
179+
let total = unValue =<< res
180180
pure $ maybe 0 Db.unDbLovelace total
181181

182182
queryVoteCounts ::

cardano-chain-gen/test/Test/Cardano/Db/Mock/UnifiedApi.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import qualified Cardano.Mock.Forging.Tx.Conway.Scenarios as Conway
3333
import Cardano.Mock.Forging.Types
3434
import Cardano.Slotting.Slot (SlotNo (..))
3535
import Control.Concurrent.Class.MonadSTM.Strict (atomically)
36-
import Control.Monad (forM, replicateM)
36+
import Control.Monad (replicateM)
3737
import Data.Word (Word64)
3838
import Ouroboros.Consensus.Cardano.Block (
3939
BabbageEra,
@@ -63,7 +63,7 @@ forgeNextSkipSlotsFindLeaderAndSubmit interpreter mockServer skipSlots txs' = do
6363

6464
forgeAndSubmitBlocks :: Interpreter -> ServerHandle IO CardanoBlock -> Int -> IO [CardanoBlock]
6565
forgeAndSubmitBlocks interpreter mockServer blocksToCreate =
66-
forM [1 .. blocksToCreate] $ \_ -> forgeNextFindLeaderAndSubmit interpreter mockServer []
66+
replicateM blocksToCreate (forgeNextFindLeaderAndSubmit interpreter mockServer [])
6767

6868
withAlonzoFindLeaderAndSubmit ::
6969
Interpreter ->

cardano-db-sync/src/Cardano/DbSync/Config/Node.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ readByteStringFromFile fp cfgType =
7878
-- -------------------------------------------------------------------------------------------------
7979

8080
instance FromJSON NodeConfig where
81-
parseJSON v =
82-
Aeson.withObject "NodeConfig" parse v
81+
parseJSON =
82+
Aeson.withObject "NodeConfig" parse
8383
where
8484
parse :: Object -> Parser NodeConfig
8585
parse o =

cardano-db-sync/src/Cardano/DbSync/DbAction.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ waitRestartState tc = do
5656
waitDoneInit :: ThreadChannels -> IO ()
5757
waitDoneInit tc = atomically $ do
5858
isDone <- readTVar (tcDoneInit tc)
59-
if isDone then pure () else retry
59+
unless isDone retry
6060

6161
runAndSetDone :: ThreadChannels -> IO Bool -> IO Bool
6262
runAndSetDone tc action = do

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Block.hs

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

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/ProtoParams.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE DataKinds #-}
2-
{-# LANGUAGE OverloadedStrings #-}
32
{-# LANGUAGE RankNTypes #-}
43
{-# LANGUAGE NoImplicitPrelude #-}
54

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/StakeDist.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{-# LANGUAGE DataKinds #-}
44
{-# LANGUAGE FlexibleContexts #-}
55
{-# LANGUAGE GADTs #-}
6-
{-# LANGUAGE OverloadedStrings #-}
76
{-# LANGUAGE ScopedTypeVariables #-}
87
{-# LANGUAGE TupleSections #-}
98
{-# LANGUAGE NoImplicitPrelude #-}

cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ listKnownSnapshots :: HasLedgerEnv -> IO [SnapshotPoint]
693693
listKnownSnapshots env = do
694694
inMem <- fmap InMemory <$> listMemorySnapshots env
695695
onDisk <- fmap OnDisk <$> listLedgerStateFilesOrdered (leDir env)
696-
pure $ reverse $ List.sortOn getSlotNoSnapshot $ inMem <> onDisk
696+
pure $ List.sortOn (Down . getSlotNoSnapshot) (inMem <> onDisk)
697697

698698
listMemorySnapshots :: HasLedgerEnv -> IO [CardanoPoint]
699699
listMemorySnapshots env = do

0 commit comments

Comments
 (0)