Skip to content

Conversation

newhoggy
Copy link
Collaborator

@newhoggy newhoggy commented Oct 2, 2025

Changelog

- description: |
    Consolidates hlint configuration by moving per-file snake_case exceptions
    into a centralized configuration rule, improving maintainability and
    reducing code duplication across test modules.
  type:
  - maintenance    # not directly related to the code
  projects:
  - cardano-api
  - cardano-api-gen

Context

This PR addresses code maintainability by consolidating duplicate hlint pragma comments that were scattered across 12 test files. Previously, each test file contained its own {- HLINT ignore "Use camelCase" -} pragma to allow snake_case naming conventions commonly used in Haskell test properties.

The change centralizes this configuration into the root .hlint.yaml file, applying the exception globally to all test modules matching the patterns Test.Cardano.Api.** and Test.Golden.Cardano.Api.**. This approach:

  • Reduces code duplication and maintenance burden
  • Ensures consistent linting rules across all test modules
  • Makes it easier to manage hlint exceptions in one place
  • Follows established Haskell testing conventions where snake_case is commonly used for property names

This allows #515 to be closed

How to trust this PR

This is a purely mechanical change that affects only hlint configuration and comments. The actual test code remains unchanged.

Verification steps:

  1. Run hlint . to verify no new warnings are introduced
  2. Confirm all tests still pass: cabal test all
  3. Review the diff to see that only hlint pragmas were removed from test files
  4. Check that the new .hlint.yaml rule correctly applies to the affected modules

Files changed:

  • .hlint.yaml: Added global rule to ignore "Use camelCase" warnings for test modules and "Use + directly" warning
  • 12 test files: Removed duplicate {- HLINT ignore "Use camelCase" -} pragmas from:
    • cardano-api/gen/Test/Hedgehog/Roundtrip/CBOR.hs
    • cardano-api/test/cardano-api-golden/Test/Golden/Cardano/Api/Script.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/Address.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/CBOR.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/Cip129.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/Envelope.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/Json.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/KeysByron.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/Ord.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/RawBytes.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Autobalance.hs
    • cardano-api/test/cardano-api-test/Test/Cardano/Api/TxBody.hs

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

Removes individual per-file hlint ignore pragmas for snake_case naming
and consolidates them into a single rule in the root .hlint.yaml
configuration file.

- Add global hlint rule to ignore "Use camelCase" warnings in test modules,
  that applies to Test.**, Gen.**, and Test.Hedgehog.** module patterns
- Remove 12 duplicate "{- HLINT ignore "Use camelCase" -}" pragmas from test files
@newhoggy newhoggy force-pushed the newhoggy/consolidate-hlint-rules branch from e472c5c to d2b700d Compare October 5, 2025 00:14
@carbolymer
Copy link
Contributor

Thanks. This only addresses HLINT ignore "Use camelCase" rule. Do you think we could also remove other ones as well?

@newhoggy
Copy link
Collaborator Author

newhoggy commented Oct 7, 2025

I wasn't sure with the other lint warnings if they occur frequently enough to warrant global suppression.

I'll get a list and the affected code and let you decide.

@newhoggy
Copy link
Collaborator Author

newhoggy commented Oct 7, 2025

Actually, I had a look at the pragmas and they seemed sensible to suppress so I did that.

@newhoggy newhoggy force-pushed the newhoggy/consolidate-hlint-rules branch from fcfc9a3 to 7984235 Compare October 7, 2025 10:51
@newhoggy newhoggy added this pull request to the merge queue Oct 8, 2025
Merged via the queue into master with commit 0f5c46b Oct 8, 2025
29 checks passed
@newhoggy newhoggy deleted the newhoggy/consolidate-hlint-rules branch October 8, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants