Skip to content

Commit

Permalink
Add HLint, tweak Spec.hs (#5)
Browse files Browse the repository at this point in the history
* Commit forgotten cabal file update

* Add conventional .hlint.yaml

This is the one from megarepo, but with the following tweaks:

- Adjust "within" on the restricted-qualification ignore
- Add an ignore for "Use Just"

* Standardize test executable

For a typical project (library), we use Spec.hs, not Main.hs. We use
Main.hs with a Spec.hs when we need to customize the runner.

Remove --module-name=Main.hs, as that's the default.

* Try newer HLint for glob support

* Move to haskell/actions implementation

haskell/actions#81

* Fixup
  • Loading branch information
pbrisbin authored Jun 13, 2022
1 parent f9db366 commit b78bc28
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rwe/actions-hlint-setup@v1
- uses: rwe/actions-hlint-run@v2
- uses: actions/checkout@v3
- uses: haskell/actions/hlint-setup@v2
- uses: haskell/actions/hlint-run@v2
with:
fail-on: warning
65 changes: 65 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
- ignore: {name: "Redundant do", within: spec}
- ignore: {name: "Eta reduce"}
- ignore: {name: "Use list comprehension"}
- ignore: {name: "Reduce duplication"}
- ignore: {name: "Use fmap"} # we use classy prelude so this would be in error
- ignore: {name: "Avoid restricted function", within: "**.Prelude"} # allow "as X"
- ignore: {name: "Use ."} # commonly broken or less readable
- ignore: {name: "Use &&"} # we like "and" at 3+ elements
- ignore: {name: "Use ||"} # we like "or" at 3+ elements
- ignore: {name: "Use join"} # this often leads to cryptic code when do notation is easier to read
- ignore: {name: "Use Just"} # makes code less readable
- ignore: {name: "Redundant ^."} # commonly broken by esqueleto

# Custom Warnings
- warn: {lhs: mapM, rhs: traverse}
- warn: {lhs: mapM_, rhs: traverse_}
- warn: {lhs: forM, rhs: for}
- warn: {lhs: forM_, rhs: for_}
- warn: {lhs: return, rhs: pure}

# Specify additional command line arguments
- arguments:
- -XBangPatterns
- -XDataKinds
- -XDeriveAnyClass
- -XDeriveFoldable
- -XDeriveFunctor
- -XDeriveGeneric
- -XDeriveLift
- -XDeriveTraversable
- -XDerivingStrategies
- -XFlexibleContexts
- -XFlexibleInstances
- -XGADTs
- -XGeneralizedNewtypeDeriving
- -XLambdaCase
- -XMultiParamTypeClasses
- -XNoImplicitPrelude
- -XNoMonomorphismRestriction
- -XOverloadedStrings
- -XQuasiQuotes
- -XRankNTypes
- -XRecordWildCards
- -XScopedTypeVariables
- -XStandaloneDeriving
- -XTypeApplications
- -XTypeFamilies

- modules:
- {name: [Data.Set], as: Set}
- {name: [Data.Map], as: Map}
- {name: [Data.HashSet], as: HashSet}
- {name: [Data.HashMap.Strict], as: HashMap}
- {name: [Data.Text], as: T}
- {name: [Data.Text.Encoding], as: T}
- {name: [Data.Text.IO], as: T}
- {name: [Data.Text.Lazy], as: TL}
- {name: [Data.Text.Lazy.Encoding], as: TL}
- {name: [Data.Text.IO.Lazy], as: TL}
- {name: [Data.ByteString], as: BS}
- {name: [Data.ByteString.Lazy], as: BSL}
- {name: [Data.ByteString.Char8], as: BS8}
- {name: [Data.ByteString.Lazy.Char8], as: BSL8}
- {name: [Data.List.NonEmpty], as: NE}
- {name: [Data.Sequence], as: Seq}
3 changes: 1 addition & 2 deletions haskell-library-template.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ library

test-suite spec
type: exitcode-stdio-1.0
main-is: Main.hs
main-is: Spec.hs
other-modules:
Paths_haskell_library_template
hs-source-dirs:
Expand Down Expand Up @@ -97,7 +97,6 @@ test-suite spec
ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-unsafe -Wno-safe -threaded -rtsopts "-with-rtsopts=-N"
build-depends:
base <5
, haskell-library-template
, hspec
if impl(ghc >= 8.10)
ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ library:

tests:
spec:
main: Main.hs
main: Spec.hs
source-dirs: tests
ghc-options: -threaded -rtsopts "-with-rtsopts=-N"
dependencies:
Expand Down
1 change: 0 additions & 1 deletion tests/Main.hs

This file was deleted.

1 change: 1 addition & 0 deletions tests/Spec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover -Wno-missing-export-lists #-}

0 comments on commit b78bc28

Please sign in to comment.