diff --git a/.github/workflows/check-hlint.yml b/.github/workflows/check-hlint.yml index c8b6a8658c..e60e03ef88 100644 --- a/.github/workflows/check-hlint.yml +++ b/.github/workflows/check-hlint.yml @@ -5,7 +5,7 @@ on: pull_request: jobs: - build: + check-hlint: runs-on: ubuntu-latest defaults: diff --git a/.hlint.yaml b/.hlint.yaml index 2accfa8f19..f78ad87c8f 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -56,6 +56,7 @@ # Ignore some builtin hints # - ignore: {name: Use let} # - ignore: {name: Use const, within: SpecialModule} # Only within certain modules +# - ignore: {name: Use camelCase, within: Test} # Only within certain modules # Define some custom infix operators diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 9e7c72aa31..1f87eed9a8 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -181,8 +181,6 @@ import qualified Hedgehog.Gen as Gen import qualified Hedgehog.Gen.QuickCheck as Q import qualified Hedgehog.Range as Range -{- HLINT ignore "Reduce duplication" -} -{- HLINT ignore "Use let" -} genAddressByron :: Gen (Address ByronAddr) genAddressByron = makeByronAddress <$> genNetworkId @@ -933,7 +931,7 @@ genProtocolParameters era = do protocolParamPoolPledgeInfluence <- genRationalInt64 protocolParamMonetaryExpansion <- genRational protocolParamTreasuryCut <- genRational - protocolParamCostModels <- pure mempty + let protocolParamCostModels = mempty --TODO: Babbage figure out how to deal with -- asymmetric cost model JSON instances protocolParamPrices <- Gen.maybe genExecutionUnitPrices diff --git a/cardano-api/gen/Test/Hedgehog/Roundtrip/CBOR.hs b/cardano-api/gen/Test/Hedgehog/Roundtrip/CBOR.hs index 93e08b4656..8dcda8fcbd 100644 --- a/cardano-api/gen/Test/Hedgehog/Roundtrip/CBOR.hs +++ b/cardano-api/gen/Test/Hedgehog/Roundtrip/CBOR.hs @@ -13,8 +13,6 @@ import qualified GHC.Stack as GHC import qualified Hedgehog as H -{- HLINT ignore "Use camelCase" -} - -- | Assert that CBOR serialisation and deserialisation roundtrips. trippingCbor :: () => HasCallStack diff --git a/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Typed/Script.hs b/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Typed/Script.hs index 571f862eb4..235db430ae 100644 --- a/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Typed/Script.hs +++ b/cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Typed/Script.hs @@ -28,8 +28,6 @@ import Hedgehog.Extras.Aeson import Test.Tasty (TestTree) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - exampleSimpleScriptV1_All :: SimpleScript exampleSimpleScriptV1_All = RequireAllOf diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Json.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Json.hs index 740a5f19cc..4d44271997 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Json.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Json.hs @@ -18,8 +18,6 @@ import qualified Hedgehog as H import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - prop_json_roundtrip_alonzo_genesis :: Property prop_json_roundtrip_alonzo_genesis = H.property $ do genesis <- forAll genAlonzoGenesis diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/KeysByron.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/KeysByron.hs index b62323fa56..517c7b819c 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/KeysByron.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/KeysByron.hs @@ -15,8 +15,6 @@ import Test.Hedgehog.Roundtrip.CBOR (trippingCbor) import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - prop_roundtrip_byron_key_CBOR :: Property prop_roundtrip_byron_key_CBOR = H.property $ do seed <- H.forAll $ deterministicSigningKey AsByronKey <$> Gen.genSeedForKey AsByronKey diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Address.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Address.hs index ed4f261d57..55f270c15a 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Address.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Address.hs @@ -17,27 +17,25 @@ import qualified Hedgehog as H import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - -- Address CBOR round trips prop_roundtrip_shelley_address :: Property prop_roundtrip_shelley_address = - roundtrip_serialise_address AsShelleyAddress genAddressShelley + roundtripSerialiseAddress AsShelleyAddress genAddressShelley prop_roundtrip_byron_address :: Property prop_roundtrip_byron_address = - roundtrip_serialise_address AsByronAddress genAddressByron + roundtripSerialiseAddress AsByronAddress genAddressByron -- ----------------------------------------------------------------------------- -roundtrip_serialise_address +roundtripSerialiseAddress :: ( SerialiseAddress a , Eq a , Show a) => AsType a -> H.Gen a -> Property -roundtrip_serialise_address asType g = +roundtripSerialiseAddress asType g = H.property $ do v <- H.forAll g H.tripping v serialiseAddress (deserialiseAddress asType) diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/CBOR.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/CBOR.hs index 61ca2ddda5..f425b9209c 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/CBOR.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/CBOR.hs @@ -23,8 +23,6 @@ import Test.Hedgehog.Roundtrip.CBOR import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - -- TODO: Need to add PaymentExtendedKey roundtrip tests however -- we can't derive an Eq instance for Crypto.HD.XPrv prop_roundtrip_txbody_CBOR :: Property diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs index 3c977b5c26..5ba09acb84 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Envelope.hs @@ -16,81 +16,79 @@ import qualified Hedgehog as H import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - prop_roundtrip_ByronVerificationKey_envelope :: Property prop_roundtrip_ByronVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsByronKey + roundtripVerificationKeyEnvelope AsByronKey prop_roundtrip_ByronSigningKey_envelope :: Property prop_roundtrip_ByronSigningKey_envelope = - roundtrip_SigningKey_envelope AsByronKey + roundtripSigningKeyEnvelope AsByronKey prop_roundtrip_PaymentVerificationKey_envelope :: Property prop_roundtrip_PaymentVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsPaymentKey + roundtripVerificationKeyEnvelope AsPaymentKey prop_roundtrip_PaymentSigningKey_envelope :: Property prop_roundtrip_PaymentSigningKey_envelope = - roundtrip_SigningKey_envelope AsPaymentKey + roundtripSigningKeyEnvelope AsPaymentKey prop_roundtrip_StakeVerificationKey_envelope :: Property prop_roundtrip_StakeVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsStakeKey + roundtripVerificationKeyEnvelope AsStakeKey prop_roundtrip_StakeSigningKey_envelope :: Property prop_roundtrip_StakeSigningKey_envelope = - roundtrip_SigningKey_envelope AsStakeKey + roundtripSigningKeyEnvelope AsStakeKey prop_roundtrip_StakePoolVerificationKey_envelope :: Property prop_roundtrip_StakePoolVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsStakePoolKey + roundtripVerificationKeyEnvelope AsStakePoolKey prop_roundtrip_StakePoolSigningKey_envelope :: Property prop_roundtrip_StakePoolSigningKey_envelope = - roundtrip_SigningKey_envelope AsStakePoolKey + roundtripSigningKeyEnvelope AsStakePoolKey prop_roundtrip_GenesisVerificationKey_envelope :: Property prop_roundtrip_GenesisVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsGenesisKey + roundtripVerificationKeyEnvelope AsGenesisKey prop_roundtrip_GenesisSigningKey_envelope :: Property prop_roundtrip_GenesisSigningKey_envelope = - roundtrip_SigningKey_envelope AsGenesisKey + roundtripSigningKeyEnvelope AsGenesisKey prop_roundtrip_GenesisDelegateVerificationKey_envelope :: Property prop_roundtrip_GenesisDelegateVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsGenesisDelegateKey + roundtripVerificationKeyEnvelope AsGenesisDelegateKey prop_roundtrip_GenesisDelegateSigningKey_envelope :: Property prop_roundtrip_GenesisDelegateSigningKey_envelope = - roundtrip_SigningKey_envelope AsGenesisDelegateKey + roundtripSigningKeyEnvelope AsGenesisDelegateKey prop_roundtrip_KesVerificationKey_envelope :: Property prop_roundtrip_KesVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsKesKey + roundtripVerificationKeyEnvelope AsKesKey prop_roundtrip_KesSigningKey_envelope :: Property prop_roundtrip_KesSigningKey_envelope = - roundtrip_SigningKey_envelope AsKesKey + roundtripSigningKeyEnvelope AsKesKey prop_roundtrip_VrfVerificationKey_envelope :: Property prop_roundtrip_VrfVerificationKey_envelope = - roundtrip_VerificationKey_envelope AsVrfKey + roundtripVerificationKeyEnvelope AsVrfKey prop_roundtrip_VrfSigningKey_envelope :: Property prop_roundtrip_VrfSigningKey_envelope = - roundtrip_SigningKey_envelope AsVrfKey + roundtripSigningKeyEnvelope AsVrfKey -- ----------------------------------------------------------------------------- -roundtrip_VerificationKey_envelope :: () +roundtripVerificationKeyEnvelope :: () #if MIN_VERSION_base(4,17,0) -- GHC 8.10 considers the HasTypeProxy constraint redundant but ghc-9.2 and above complains if its -- not present. @@ -99,17 +97,17 @@ roundtrip_VerificationKey_envelope :: () => Key keyrole => AsType keyrole -> Property -roundtrip_VerificationKey_envelope roletoken = +roundtripVerificationKeyEnvelope roletoken = H.property $ do vkey <- H.forAll (genVerificationKey roletoken) H.tripping vkey (serialiseToTextEnvelope Nothing) (deserialiseFromTextEnvelope (AsVerificationKey roletoken)) -roundtrip_SigningKey_envelope :: (Key keyrole, +roundtripSigningKeyEnvelope :: (Key keyrole, Eq (SigningKey keyrole), Show (SigningKey keyrole)) => AsType keyrole -> Property -roundtrip_SigningKey_envelope roletoken = +roundtripSigningKeyEnvelope roletoken = H.property $ do vkey <- H.forAll (genSigningKey roletoken) H.tripping vkey (serialiseToTextEnvelope Nothing) diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/JSON.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/JSON.hs index b38635257e..ad01feedeb 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/JSON.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/JSON.hs @@ -22,8 +22,6 @@ import qualified Hedgehog.Gen as Gen import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - prop_roundtrip_praos_nonce_JSON :: Property prop_roundtrip_praos_nonce_JSON = H.property $ do pNonce <- forAll $ Gen.just genMaybePraosNonce diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Ord.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Ord.hs index 5a5bb95d8a..a06ca3d5f9 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Ord.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/Ord.hs @@ -14,11 +14,9 @@ import qualified Hedgehog as H import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - -ord_distributive :: (Show a, Ord a, Ord b) +ordDistributive :: (Show a, Ord a, Ord b) => H.Gen a -> (a -> b) -> Property -ord_distributive gen to = +ordDistributive gen to = H.property $ do x <- H.forAll gen y <- H.forAll gen @@ -27,30 +25,30 @@ ord_distributive gen to = prop_ord_distributive_TxId :: Property prop_ord_distributive_TxId = - ord_distributive genTxId toShelleyTxId + ordDistributive genTxId toShelleyTxId prop_ord_distributive_TxIn :: Property prop_ord_distributive_TxIn = - ord_distributive genTxIn toShelleyTxIn + ordDistributive genTxIn toShelleyTxIn prop_ord_distributive_Address :: Property prop_ord_distributive_Address = - ord_distributive genAddressShelley (toShelleyAddr . toAddressInAnyEra) + ordDistributive genAddressShelley (toShelleyAddr . toAddressInAnyEra) where toAddressInAnyEra :: Address ShelleyAddr -> AddressInEra ShelleyEra toAddressInAnyEra = anyAddressInShelleyBasedEra ShelleyBasedEraShelley . toAddressAny prop_ord_distributive_StakeAddress :: Property prop_ord_distributive_StakeAddress = - ord_distributive genStakeAddress toShelleyStakeAddr + ordDistributive genStakeAddress toShelleyStakeAddr prop_ord_distributive_TxMetadata :: Property prop_ord_distributive_TxMetadata = - ord_distributive genTxMetadataValue toShelleyMetadatum + ordDistributive genTxMetadataValue toShelleyMetadatum prop_ord_distributive_ScriptData :: Property prop_ord_distributive_ScriptData = - ord_distributive (getScriptData <$> genHashableScriptData) toPlutusData + ordDistributive (getScriptData <$> genHashableScriptData) toPlutusData -- ----------------------------------------------------------------------------- diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs index de1776b412..7169d343e8 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/RawBytes.hs @@ -16,75 +16,73 @@ import qualified Hedgehog as H import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - -- Address CBOR round trips prop_roundtrip_shelley_address_raw :: Property prop_roundtrip_shelley_address_raw = - roundtrip_raw_bytes AsShelleyAddress genAddressShelley + roundtripRawBytes AsShelleyAddress genAddressShelley prop_roundtrip_byron_address_raw :: Property prop_roundtrip_byron_address_raw = - roundtrip_raw_bytes AsByronAddress genAddressByron + roundtripRawBytes AsByronAddress genAddressByron prop_roundtrip_stake_address_raw :: Property prop_roundtrip_stake_address_raw = - roundtrip_raw_bytes AsStakeAddress genStakeAddress + roundtripRawBytes AsStakeAddress genStakeAddress prop_roundtrip_script_hash_raw :: Property prop_roundtrip_script_hash_raw = - roundtrip_raw_bytes AsScriptHash genScriptHash + roundtripRawBytes AsScriptHash genScriptHash prop_roundtrip_verification_ByronKey_hash_raw :: Property prop_roundtrip_verification_ByronKey_hash_raw = - roundtrip_verification_key_hash_raw AsByronKey + roundtripVerificationKeyHashRaw AsByronKey prop_roundtrip_verification_PaymentKey_hash_raw :: Property prop_roundtrip_verification_PaymentKey_hash_raw = - roundtrip_verification_key_hash_raw AsPaymentKey + roundtripVerificationKeyHashRaw AsPaymentKey prop_roundtrip_verification_StakeKey_hash_raw :: Property prop_roundtrip_verification_StakeKey_hash_raw = - roundtrip_verification_key_hash_raw AsStakeKey + roundtripVerificationKeyHashRaw AsStakeKey prop_roundtrip_verification_StakePoolKey_hash_raw :: Property prop_roundtrip_verification_StakePoolKey_hash_raw = - roundtrip_verification_key_hash_raw AsStakePoolKey + roundtripVerificationKeyHashRaw AsStakePoolKey prop_roundtrip_verification_GenesisKey_hash_raw :: Property prop_roundtrip_verification_GenesisKey_hash_raw = - roundtrip_verification_key_hash_raw AsGenesisKey + roundtripVerificationKeyHashRaw AsGenesisKey prop_roundtrip_verification_GenesisDelegateKey_hash_raw :: Property prop_roundtrip_verification_GenesisDelegateKey_hash_raw = - roundtrip_verification_key_hash_raw AsGenesisDelegateKey + roundtripVerificationKeyHashRaw AsGenesisDelegateKey prop_roundtrip_verification_KesKey_hash_raw :: Property prop_roundtrip_verification_KesKey_hash_raw = - roundtrip_verification_key_hash_raw AsKesKey + roundtripVerificationKeyHashRaw AsKesKey prop_roundtrip_verification_VrfKey_hash_raw :: Property prop_roundtrip_verification_VrfKey_hash_raw = - roundtrip_verification_key_hash_raw AsVrfKey + roundtripVerificationKeyHashRaw AsVrfKey prop_roundtrip_verification_GenesisUTxOKey_hash_raw :: Property prop_roundtrip_verification_GenesisUTxOKey_hash_raw = - roundtrip_verification_key_hash_raw AsGenesisUTxOKey + roundtripVerificationKeyHashRaw AsGenesisUTxOKey -- ----------------------------------------------------------------------------- -roundtrip_raw_bytes +roundtripRawBytes :: ( SerialiseAsRawBytes a , Eq a , Show a) => AsType a -> H.Gen a -> Property -roundtrip_raw_bytes asType g = +roundtripRawBytes asType g = H.property $ do v <- H.forAll g H.tripping v serialiseToRawBytes (deserialiseFromRawBytes asType) -roundtrip_verification_key_hash_raw :: () +roundtripVerificationKeyHashRaw :: () #if MIN_VERSION_base(4,17,0) -- GHC 9.2 and above needs an extra constraint. => HasTypeProxy keyrole @@ -94,7 +92,7 @@ roundtrip_verification_key_hash_raw :: () => Show (Hash keyrole) => AsType keyrole -> Property -roundtrip_verification_key_hash_raw roletoken = +roundtripVerificationKeyHashRaw roletoken = H.property $ do vKey <- H.forAll $ genVerificationKey roletoken let vKeyHash = verificationKeyHash vKey diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/TxBody.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/TxBody.hs index d0a0baee64..1949786ec8 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/TxBody.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Typed/TxBody.hs @@ -19,8 +19,6 @@ import qualified Hedgehog as H import Test.Tasty (TestTree, testGroup) import Test.Tasty.Hedgehog (testProperty) -{- HLINT ignore "Use camelCase" -} - -- | Check the txOuts in a TxBodyContent after a ledger roundtrip. prop_roundtrip_txbodycontent_txouts:: Property prop_roundtrip_txbodycontent_txouts =