Skip to content

Commit

Permalink
fix remainder of hlint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-martin committed Oct 20, 2023
1 parent dd4a8df commit 1cab919
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 64 deletions.
117 changes: 59 additions & 58 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
- 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
- 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}
- 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
- -XBangPatterns
- -XDataKinds
- -XDeriveAnyClass
- -XDeriveFoldable
- -XDeriveFunctor
- -XDeriveGeneric
- -XDeriveLift
- -XDeriveTraversable
- -XDerivingStrategies
- -XFlexibleContexts
- -XFlexibleInstances
- -XGADTs
- -XGeneralizedNewtypeDeriving
- -XLambdaCase
- -XMultiParamTypeClasses
- -XNoImplicitPrelude
- -XNoMonomorphismRestriction
- -XOverloadedRecordDot
- -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}
- { 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 }
12 changes: 6 additions & 6 deletions cabal-file-inspector/lib/CabalFile/CabalFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import CabalFile.Package
import CabalFile.PackageName
import Control.Exception (Exception)
import Control.Monad.Validate
import Data.ByteString qualified as ByteString.Strict
import Data.ByteString qualified as BS
import Data.Either qualified as Either
import Data.List.NonEmpty (NonEmpty, nonEmpty)
import Data.String (IsString)
import Data.String qualified as IsString (IsString (..))
import Data.Text qualified as T.Strict
import Data.Text.Encoding qualified as T.Strict
import Data.Text qualified as T
import Data.Text.Encoding qualified as T
import Essentials
import GHC.Stack (HasCallStack, callStack, prettyCallStack)
import Map (Map)
Expand Down Expand Up @@ -104,15 +104,15 @@ instance Show e => Show (CabalReadException e) where
-- | Parses like the contents of a .cabal file. Ignores warnings. Bottom if parsing fails.
instance IsString CabalFile where
fromString =
T.Strict.pack
>>> T.Strict.encodeUtf8
T.pack
>>> T.encodeUtf8
>>> parseCabalFile
>>> (.result)
>>> either (error . show) id

-- | Interpret a byte string as a .cabal file, hopefully generating a 'CabalFile',
-- possibly generating warnings and errors
parseCabalFile :: ByteString.Strict.ByteString -> CabalRead CabalFile
parseCabalFile :: BS.ByteString -> CabalRead CabalFile
parseCabalFile =
Cabal.Parsec.parseGenericPackageDescription
>>> Cabal.Parsec.runParseResult
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
nixpkgs-unstable.haskell-language-server
nixpkgs-unstable.haskellPackages.weeder
freckle.fourmolu-0-13-x
nixpkgs-stable.hlint
];
};
}
Expand Down

0 comments on commit 1cab919

Please sign in to comment.