Fix hlint warnings for hlint v2.1.20 (#1320)

* Apply some hlint suggestions.

* Simplify config parser (to avoid hlint error)

* Reorganize for clarity (and fix hlint error)

* Remove redundant language extension

* Reformat slice more conventionally to avoid hlint bug

* Refactor for clarity (and to avoid hlint error)

* Simplify (and avoid hlint error)

* Fix hlint complaint
This commit is contained in:
Robert
2019-06-08 20:52:48 -05:00
committed by Steve Chávez
parent 78e5677fbe
commit 33532cfbb6
9 changed files with 58 additions and 41 deletions
+16 -10
View File
@@ -146,18 +146,18 @@ readOptions = do
AppConfig
<$> reqString "db-uri"
<*> reqString "db-anon-role"
<*> (mfilter (/= "") <$> optString "server-proxy-uri")
<*> optString "server-proxy-uri"
<*> reqString "db-schema"
<*> (fromMaybe "!4" . mfilter (/= "") <$> optString "server-host")
<*> (fromMaybe 3000 . join . fmap coerceInt <$> optValue "server-port")
<*> (fromMaybe "!4" <$> optString "server-host")
<*> (fromMaybe 3000 <$> optInt "server-port")
<*> optString "server-unix-socket"
<*> (fmap encodeUtf8 . mfilter (/= "") <$> optString "jwt-secret")
<*> (fromMaybe False . join . fmap coerceBool <$> optValue "secret-is-base64")
<*> (fmap encodeUtf8 <$> optString "jwt-secret")
<*> (fromMaybe False <$> optBool "secret-is-base64")
<*> parseJwtAudience "jwt-aud"
<*> (fromMaybe 10 . join . fmap coerceInt <$> optValue "db-pool")
<*> (fromMaybe 10 . join . fmap coerceInt <$> optValue "db-pool-timeout")
<*> (join . fmap coerceInt <$> optValue "max-rows")
<*> (mfilter (/= "") <$> optString "pre-request")
<*> (fromMaybe 10 <$> optInt "db-pool")
<*> (fromMaybe 10 <$> optInt "db-pool-timeout")
<*> optInt "max-rows"
<*> optString "pre-request"
<*> pure False
<*> (fmap (fmap coerceText) <$> C.subassocs "app.settings" C.value)
<*> (maybe (Right [JSPKey "role"]) parseRoleClaimKey <$> optValue "role-claim-key")
@@ -176,11 +176,17 @@ readOptions = do
reqString k = C.required k C.string
optString :: C.Key -> C.Parser C.Config (Maybe Text)
optString k = C.optional k C.string
optString k = mfilter (/= "") <$> C.optional k C.string
optValue :: C.Key -> C.Parser C.Config (Maybe C.Value)
optValue k = C.optional k C.value
optInt :: (Read i, Integral i) => C.Key -> C.Parser C.Config (Maybe i)
optInt k = join <$> C.optional k (coerceInt <$> C.value)
optBool :: C.Key -> C.Parser C.Config (Maybe Bool)
optBool k = join <$> C.optional k (coerceBool <$> C.value)
coerceText :: C.Value -> Text
coerceText (C.String s) = s
coerceText v = show v