Skip to content

Remove reconfigure-hlint.sh script #4838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ logs

# Ignore files generated by scripts
/example
/.hlint.yaml
/testnet

.vscode/
15 changes: 7 additions & 8 deletions .hlint.template.yaml → .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# placed as .hlint.yaml in the root of your project


# Warnings currently triggered by your code
- ignore: {name: "Move brackets to avoid $"}

# Specify additional command line arguments
#
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
Expand Down Expand Up @@ -37,6 +34,12 @@
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}

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

# Turn on hints that are off by default
#
Expand All @@ -53,15 +56,11 @@
# Ignore some builtin hints
# - ignore: {name: Use let}
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
# - ignore: {name: "Use lambda-case"}


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


# To generate a suitable file for HLint do:
# $ hlint --default > .hlint.yaml

# The following is generated by scripts/reconfigure-hlint.sh
# BEGIN-GENERATED
# END-GENERATED
9 changes: 0 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ GHCID

run *ghcid* with: ``ghcid -c "cabal repl exe:cardano-node --reorder-goals"``

Haskell Language Server
----

When using Haskell Language Server with Visual Studio Code, you may find that
`HLINT annotations are ignored <https://github.com/haskell/haskell-language-server/issues/638>`_.

To work around this, you may run the script ``./scripts/reconfigure-hlint.sh`` to generate a ``.hlint.yaml``
file with HLINT ignore rules derived from the source code.

Testing
====

Expand Down
9 changes: 0 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,6 @@ Note: When developing locally, for any package you are working on, in **cabal.pr

Otherwise GHC might complain about unused packages.

Haskell Language Server
-----------------------

When using Haskell Langague Server with Visual Studio Code, you may find that
`HLINT annotations are ignored<https://github.com/haskell/haskell-language-server/issues/638>`.

To work around this, you may run the script `./scripts/reconfigure-hlint.sh` to generate a `.hlint.yaml`
file with HLINT ignore rules derived from the source code.

****
Native Tokens
****
Expand Down
3 changes: 3 additions & 0 deletions bench/cardano-topology/cardano-topology.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -Wno-partial-fields -Wno-name-shadowing #-}

{- HLINT ignore "Redundant id" -}
{- HLINT ignore "Use concatMap" -}

import Prelude hiding (id)

import Data.Aeson
Expand Down
3 changes: 3 additions & 0 deletions bench/locli/src/Cardano/Analysis/API/Dictionary.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE DeriveAnyClass #-}

{- HLINT ignore "Evaluate" -}

module Cardano.Analysis.API.Dictionary (module Cardano.Analysis.API.Dictionary) where

import Cardano.Prelude
Expand Down
2 changes: 1 addition & 1 deletion bench/locli/src/Cardano/Analysis/API/Ground.hs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ dumpAssociatedObjects ident xs = liftIO $

readAssociatedObjects :: forall a.
FromJSON a => String -> [JsonLogfile] -> ExceptT Text IO [(JsonLogfile, a)]
readAssociatedObjects ident fs = firstExceptT T.pack . newExceptT . fmap sequence . fmap (fmap sequence) $
readAssociatedObjects ident fs = firstExceptT T.pack . newExceptT . fmap (mapM sequence) $
flip mapConcurrently fs $
\jf@(JsonLogfile f) -> do
x <- eitherDecode @a <$> LBS.readFile (replaceExtension f $ ident <> ".json")
Expand Down
6 changes: 5 additions & 1 deletion bench/locli/src/Cardano/Analysis/BlockProp.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StrictData #-}

{-# OPTIONS_GHC -Wno-incomplete-patterns -Wno-name-shadowing #-}
{-# OPTIONS_GHC -Wno-unused-imports -Wno-partial-fields -Wno-unused-matches -Wno-deprecations -Wno-unused-local-binds -Wno-incomplete-record-updates #-}
{- HLINT ignore "Use head" -}

{- HLINT ignore "Avoid lambda" -}
{- HLINT ignore "Eta reduce" -}
{- HLINT ignore "Use head" -}

module Cardano.Analysis.BlockProp
( summariseMultiBlockProp
, MachView
Expand Down
4 changes: 4 additions & 0 deletions bench/locli/src/Cardano/Analysis/MachPerf.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{-# LANGUAGE StrictData #-}

{-# OPTIONS_GHC -Wno-incomplete-patterns -Wno-name-shadowing -Wno-orphans #-}

{- HLINT ignore "Use head" -}
{- HLINT ignore "Evaluate" -}

module Cardano.Analysis.MachPerf (module Cardano.Analysis.MachPerf) where

import Cardano.Prelude hiding (head)
Expand Down
4 changes: 4 additions & 0 deletions bench/locli/src/Cardano/Analysis/Summary.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-name-shadowing -Wno-orphans #-}

{- HLINT ignore "Use mapMaybe" -}

module Cardano.Analysis.Summary (module Cardano.Analysis.Summary) where

import Prelude (head, last)
Expand Down
6 changes: 5 additions & 1 deletion bench/locli/src/Cardano/Render.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}

{- HLINT ignore "Use concatMap" -}
{- HLINT ignore "Use fromMaybe" -}

module Cardano.Render (module Cardano.Render) where

import Prelude (id, show)
Expand Down
5 changes: 5 additions & 0 deletions bench/locli/src/Cardano/Unlog/LogObject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ViewPatterns #-}

{-# OPTIONS_GHC -Wno-partial-fields -Wno-orphans #-}

{- HLINT ignore "Redundant <$>" -}
{- HLINT ignore "Redundant if" -}
{- HLINT ignore "Use infix" -}

module Cardano.Unlog.LogObject (module Cardano.Unlog.LogObject) where

import Cardano.Prelude hiding (Text, head, show)
Expand Down
7 changes: 4 additions & 3 deletions bench/locli/src/Data/CDF.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand All @@ -14,6 +13,8 @@
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wwarn #-}

{- HLINT ignore "Use infix" -}

module Data.CDF
( Centile(..)
, renderCentile
Expand Down
2 changes: 2 additions & 0 deletions bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
{-# OPTIONS_GHC -Wno-missed-specialisations #-}
{-# OPTIONS_GHC -Wno-orphans #-}

{- HLINT ignore "Redundant <$>" -}

module Cardano.Benchmarking.GeneratorTx
( AsyncBenchmarkControl
, walletBenchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -102,7 +101,7 @@ mkSubmissionSummary ::
-> IO SubmissionSummary
mkSubmissionSummary ssThreadName startTime reportsRefs
= do
results <- sequence (STM.atomically . STM.readTMVar <$> reportsRefs)
results <- mapM (STM.atomically . STM.readTMVar) reportsRefs
let (failures, reports) = partitionEithers results
now <- Clock.getCurrentTime
let ssElapsed = Clock.diffUTCTime now startTime
Expand Down
2 changes: 1 addition & 1 deletion bench/tx-generator/src/Cardano/Benchmarking/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ runScript script iom = runActionM execScript iom >>= \case
shutDownLogging :: ActionM ()
shutDownLogging = do
traceError "QRT Last Message. LoggingLayer going to shutdown. 73 . . . ."
liftIO $ threadDelay (200*1000)
liftIO $ threadDelay (200 * 1_000)
4 changes: 2 additions & 2 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ addFund era wallet txIn lovelace keyName = do
fundKey <- getEnvKeys keyName
let
mkOutValue :: forall era. IsShelleyBasedEra era => AsType era -> ActionM (InAnyCardanoEra TxOutValue)
mkOutValue = \_ -> return $ InAnyCardanoEra (cardanoEra @era) (lovelaceToTxOutValue lovelace)
mkOutValue _ = return $ InAnyCardanoEra (cardanoEra @era) (lovelaceToTxOutValue lovelace)
outValue <- withEra era mkOutValue
addFundToWallet wallet txIn outValue fundKey

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

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

waitBenchmarkCore :: AsyncBenchmarkControl -> ActionM ()
waitBenchmarkCore ctl = do
Expand Down
2 changes: 2 additions & 0 deletions bench/tx-generator/src/Cardano/TxGenerator/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

{- HLINT ignore "Use map" -}

-- | This module provides means to secure funds that are given in genesis.
-- To secure a fund, the key locking the transaction ouput in genesis has to be provided.
module Cardano.TxGenerator.Genesis
Expand Down
4 changes: 3 additions & 1 deletion bench/tx-generator/test/ApiTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

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

{- HLINT ignore "Use map" -}

module Main (main) where

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

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

redeemerFile <- getRedeemerFile
redeemer <- readScriptData redeemerFile >>= \case
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ instance Error e => Error (FileError e) where
path ++ ": " ++ displayError e

instance Error IOException where
displayError ioEx = show ioEx
displayError = show

16 changes: 8 additions & 8 deletions cardano-api/src/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

{- HLINT ignore "Redundant fmap" -}

module Cardano.Api.LedgerState
( -- * Initialization / Accumulation
Env(..)
Expand Down Expand Up @@ -761,8 +763,8 @@ data NodeConfig = NodeConfig
}

instance FromJSON NodeConfig where
parseJSON v =
Aeson.withObject "NodeConfig" parse v
parseJSON =
Aeson.withObject "NodeConfig" parse
where
parse :: Object -> Parser NodeConfig
parse o =
Expand Down Expand Up @@ -1076,9 +1078,8 @@ readShelleyGenesis (GenesisFile file) expectedGenesisHash = do
where
checkExpectedGenesisHash :: GenesisHashShelley -> ExceptT ShelleyGenesisError IO ()
checkExpectedGenesisHash actual =
if actual /= expectedGenesisHash
then left (ShelleyGenesisHashMismatch actual expectedGenesisHash)
else pure ()
when (actual /= expectedGenesisHash) $
left (ShelleyGenesisHashMismatch actual expectedGenesisHash)

data ShelleyGenesisError
= ShelleyGenesisReadError !FilePath !Text
Expand Down Expand Up @@ -1121,9 +1122,8 @@ readAlonzoGenesis (GenesisFile file) expectedGenesisHash = do
where
checkExpectedGenesisHash :: GenesisHashAlonzo -> ExceptT AlonzoGenesisError IO ()
checkExpectedGenesisHash actual =
if actual /= expectedGenesisHash
then left (AlonzoGenesisHashMismatch actual expectedGenesisHash)
else pure ()
when (actual /= expectedGenesisHash) $
left (AlonzoGenesisHashMismatch actual expectedGenesisHash)

data AlonzoGenesisError
= AlonzoGenesisReadError !FilePath !Text
Expand Down
2 changes: 2 additions & 0 deletions cardano-api/src/Cardano/Api/ProtocolParameters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}

{- HLINT ignore "Redundant ==" -}

-- | The various Cardano protocol parameters, including:
--
-- * the current values of updatable protocol parameters: 'ProtocolParameters'
Expand Down
5 changes: 2 additions & 3 deletions cardano-cli/src/Cardano/CLI/Byron/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ mkGenesisSpec gp = do

where
mkGenesisInitialiser :: Bool -> Genesis.GenesisInitializer
mkGenesisInitialiser useHeavyDlg =
mkGenesisInitialiser =
Genesis.GenesisInitializer
(gpTestnetBalance gp)
(gpFakeAvvmOptions gp)
(Common.lovelacePortionToRational (gpAvvmBalanceFactor gp))
useHeavyDlg

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

dlgCerts <- mapM findDelegateCert . map ByronSigningKey $ gsRichSecrets gs
dlgCerts <- mapM (findDelegateCert . ByronSigningKey) $ gsRichSecrets gs

liftIO $ wOut "genesis-keys" "key"
serialiseToRawBytes
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ nodeSubmitTx network gentx = do
--TODO: remove these local definitions when the updated ledger lib is available
fromCborTxAux :: LB.ByteString -> Either Binary.DecoderError (UTxO.ATxAux B.ByteString)
fromCborTxAux lbs =
fmap (annotationBytes lbs)
$ Binary.decodeFullDecoder "Cardano.Chain.UTxO.TxAux.fromCborTxAux"
annotationBytes lbs
<$> Binary.decodeFullDecoder "Cardano.Chain.UTxO.TxAux.fromCborTxAux"
Binary.fromCBOR lbs
where
annotationBytes :: Functor f => LB.ByteString -> f Binary.ByteSpan -> f B.ByteString
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ validateCBOR :: CBORObject -> LByteString -> Either HelpersError Text
validateCBOR cborObject bs =
case cborObject of
CBORBlockByron epochSlots -> do
() <$ decodeCBOR bs (fromCBORABlockOrBoundary epochSlots)
void $ decodeCBOR bs (fromCBORABlockOrBoundary epochSlots)
Right "Valid Byron block."

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

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

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

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

-- | Convert an Either to a Maybe and execute the supplied handler
Expand Down
Loading