Skip to content

Commit

Permalink
Fixes HLint
Browse files Browse the repository at this point in the history
  • Loading branch information
sophie-h committed Apr 7, 2017
1 parent 0213491 commit 3792a69
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 13 deletions.
66 changes: 66 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint
##########################

# This file contains a template configuration file, which is typically
# placed as .hlint.yaml in the root of your project

- ignore:
name: Use camelCase
- ignore:
name: Use fromMaybe
- ignore:
name: Use newtype instead of data
- ignore:
name: Use module export list
- ignore:
name: Reduce duplication

# Specify additional command line arguments
#
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]


# Control which extensions/flags/modules/functions can be used
#
# - extensions:
# - default: false # all extension are banned by default
# - name: PatternGuards, ViewPatterns # only these listed extensions can be used
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
#
# - flags:
# - {name: -w, within: []} # -w is allowed nowhere
#
# - modules:
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
#
# - functions:
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules


# Add custom hints for this project
#
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
# - error: {lhs: wibbleMany [x], rhs: wibbleOne x}


# Turn on hints that are off by default
#
# Ban "module X(module X) where", to require a real export list
# - warn: {name: Use explicit module export list}
#
# Replace a $ b $ c with a . b $ c
# - group: {name: dollar, enabled: true}
#
# Generalise map to fmap, ++ to <>
# - group: {name: generalise, enabled: true}


# Ignore some builtin hints
# - ignore: {name: Use let}
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules


# Define some custom infix operators
# - fixity: infixr 3 ~^#^~
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ test:
format-code: $(HS)

$(HS):
@./.cabal-sandbox/bin/hlint $@
@./.cabal-sandbox/bin/hindent $@
3 changes: 2 additions & 1 deletion acme.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ test-suite acme-integration
x509,
pem,
-- dev
hindent
hindent,
hlint > 2
ghc-options:
-Wall
-Wcompat
Expand Down
4 changes: 2 additions & 2 deletions src/Network/ACME.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ acmeNewJwsBody
-> o -- ^ Request body
-> AcmeObjAccount -- ^ Account signing the request
-> AcmeObjDirectory -- ^ Directory of the server
-> ExceptT AcmeErr IO (AcmeJws)
-> ExceptT AcmeErr IO AcmeJws
acmeNewJwsBody req obj acc dir = do
nonce <- acmePerformNonce dir
AcmeErrJws `withExceptT`
(jwsSigned obj (acmeRequestUrl req) (acmeObjAccountKey acc) nonce)
jwsSigned obj (acmeRequestUrl req) (acmeObjAccountKey acc) nonce
12 changes: 6 additions & 6 deletions src/Network/ACME/HTTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ resHeaderAsURI x ys = do
case parseURI h of
Just u -> return u
Nothing ->
throwE $
AcmeErrDecodingHeader {acmeErrHeaderName = show x, acmeErrHeaderValue = h}
throwE
AcmeErrDecodingHeader
{acmeErrHeaderName = show x, acmeErrHeaderValue = h}

resBody
:: FromJSON a
Expand All @@ -44,8 +45,7 @@ resBody res =
case eitherDecode (acmeResponseBody res) of
Right x -> return x
Left msg ->
throwE $
AcmeErrDecodingBody {acmeErrMessage = msg, acmeErrBody = show res}
throwE AcmeErrDecodingBody {acmeErrMessage = msg, acmeErrBody = show res}

-- ** Perform ACME Server Request
-- | Perform POST query
Expand Down Expand Up @@ -106,8 +106,8 @@ parseResult req bod resIO =
case eitherDecode (getResponseBody res) of
Right e ->
AcmeErrDetail
{ acmeErrRequest = (show req)
, acmeErrHttpStatus = (getResponseStatus res)
{ acmeErrRequest = show req
, acmeErrHttpStatus = getResponseStatus res
, acmeErrProblemDetail = e
, acmeErrRequestBody = bod
}
Expand Down
8 changes: 4 additions & 4 deletions src/Network/ACME/JWS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ data AcmeJwsHeader a = AcmeJwsHeader
} deriving (Show)

acmeJwsHeader :: Lens' (AcmeJwsHeader p) (JWSHeader p)
acmeJwsHeader f s@(AcmeJwsHeader {_acmeJwsHeader = x}) =
acmeJwsHeader f s@AcmeJwsHeader {_acmeJwsHeader = x} =
fmap (\x' -> s {_acmeJwsHeader = x'}) (f x)

acmeJwsHeaderNonce :: Lens' (AcmeJwsHeader p) AcmeJwsNonce
acmeJwsHeaderNonce f s@(AcmeJwsHeader {_acmeJwsHeaderNonce = x}) =
acmeJwsHeaderNonce f s@AcmeJwsHeader {_acmeJwsHeaderNonce = x} =
fmap (\x' -> s {_acmeJwsHeaderNonce = x'}) (f x)

instance HasParams AcmeJwsHeader where
Expand Down Expand Up @@ -78,13 +78,13 @@ newAcmeJwsHeader jwk' nonce
jwk
(HeaderParam Unprotected <$> jwkPublic jwk')
(newJWSHeader (Unprotected, alg'))
return $ AcmeJwsHeader {_acmeJwsHeader = h, _acmeJwsHeaderNonce = nonce}
return AcmeJwsHeader {_acmeJwsHeader = h, _acmeJwsHeaderNonce = nonce}

-- | Removes private key
jwkPublic
:: AsPublicKey a
=> a -> Maybe a
jwkPublic jwk' = view asPublicKey jwk'
jwkPublic = view asPublicKey

jwsSigned
:: (ToJSON a)
Expand Down

0 comments on commit 3792a69

Please sign in to comment.