mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-27 04:13:11 +03:00
cln: hlint: Clean up Maybe related hlint warnings.
This commit is contained in:
parent
e13239386f
commit
330c21659f
@ -24,15 +24,12 @@
|
|||||||
- ignore: {name: "Use sortOn"}
|
- ignore: {name: "Use sortOn"}
|
||||||
- ignore: {name: "Use camelCase"}
|
- ignore: {name: "Use camelCase"}
|
||||||
- ignore: {name: "Use list comprehension"}
|
- ignore: {name: "Use list comprehension"}
|
||||||
- ignore: {name: "Use isNothing"}
|
|
||||||
- ignore: {name: "Redundant <$>"}
|
- ignore: {name: "Redundant <$>"}
|
||||||
- ignore: {name: "Use list literal pattern"}
|
- ignore: {name: "Use list literal pattern"}
|
||||||
- ignore: {name: "Use fewer imports"}
|
- ignore: {name: "Use fewer imports"}
|
||||||
- ignore: {name: "Use intercalate"}
|
- ignore: {name: "Use intercalate"}
|
||||||
- ignore: {name: "Use tuple-section"}
|
- ignore: {name: "Use tuple-section"}
|
||||||
- ignore: {name: "Use section"}
|
- ignore: {name: "Use section"}
|
||||||
- ignore: {name: "Use maybe"}
|
|
||||||
- ignore: {name: "Replace case with maybe"}
|
|
||||||
- ignore: {name: "Avoid lambda using `infix`"}
|
- ignore: {name: "Avoid lambda using `infix`"}
|
||||||
- ignore: {name: "Functor law"}
|
- ignore: {name: "Functor law"}
|
||||||
- ignore: {name: "Missing NOINLINE pragma"}
|
- ignore: {name: "Missing NOINLINE pragma"}
|
||||||
@ -42,7 +39,6 @@
|
|||||||
- ignore: {name: "Use void"}
|
- ignore: {name: "Use void"}
|
||||||
- ignore: {name: "Use elemIndex"}
|
- ignore: {name: "Use elemIndex"}
|
||||||
- ignore: {name: "Use lambda-case"}
|
- ignore: {name: "Use lambda-case"}
|
||||||
- ignore: {name: "Replace case with fromMaybe"}
|
|
||||||
|
|
||||||
|
|
||||||
# Specify additional command line arguments
|
# Specify additional command line arguments
|
||||||
|
@ -226,10 +226,9 @@ postingDate2 p = fromMaybe nulldate $ asum dates
|
|||||||
-- the ambiguity, unmarked can mean "posting and transaction are both
|
-- the ambiguity, unmarked can mean "posting and transaction are both
|
||||||
-- unmarked" or "posting is unmarked and don't know about the transaction".
|
-- unmarked" or "posting is unmarked and don't know about the transaction".
|
||||||
postingStatus :: Posting -> Status
|
postingStatus :: Posting -> Status
|
||||||
postingStatus Posting{pstatus=s, ptransaction=mt}
|
postingStatus Posting{pstatus=s, ptransaction=mt} = case s of
|
||||||
| s == Unmarked = case mt of Just t -> tstatus t
|
Unmarked -> maybe Unmarked tstatus mt
|
||||||
Nothing -> Unmarked
|
_ -> s
|
||||||
| otherwise = s
|
|
||||||
|
|
||||||
-- | Tags for this posting including any inherited from its parent transaction.
|
-- | Tags for this posting including any inherited from its parent transaction.
|
||||||
postingAllTags :: Posting -> [Tag]
|
postingAllTags :: Posting -> [Tag]
|
||||||
|
@ -46,7 +46,6 @@ import Hledger.Data.Types
|
|||||||
import Hledger.Data.Amount
|
import Hledger.Data.Amount
|
||||||
import Hledger.Data.Dates (nulldate)
|
import Hledger.Data.Dates (nulldate)
|
||||||
import Hledger.Data.Commodity (showCommoditySymbol)
|
import Hledger.Data.Commodity (showCommoditySymbol)
|
||||||
import Data.Maybe (fromMaybe)
|
|
||||||
import Text.Printf (printf)
|
import Text.Printf (printf)
|
||||||
|
|
||||||
|
|
||||||
@ -335,7 +334,7 @@ pricesShortestPath start end edges =
|
|||||||
extend (path,unusededges) =
|
extend (path,unusededges) =
|
||||||
let
|
let
|
||||||
pathnodes = start : map mpto path
|
pathnodes = start : map mpto path
|
||||||
pathend = fromMaybe start $ mpto <$> lastMay path
|
pathend = maybe start mpto $ lastMay path
|
||||||
(nextedges,remainingedges) = partition ((==pathend).mpfrom) unusededges
|
(nextedges,remainingedges) = partition ((==pathend).mpfrom) unusededges
|
||||||
in
|
in
|
||||||
[ (path', remainingedges')
|
[ (path', remainingedges')
|
||||||
|
@ -426,7 +426,7 @@ commoditydirectiveonelinep = do
|
|||||||
lift skipNonNewlineSpaces
|
lift skipNonNewlineSpaces
|
||||||
_ <- lift followingcommentp
|
_ <- lift followingcommentp
|
||||||
let comm = Commodity{csymbol=acommodity, cformat=Just $ dbg6 "style from commodity directive" astyle}
|
let comm = Commodity{csymbol=acommodity, cformat=Just $ dbg6 "style from commodity directive" astyle}
|
||||||
if asdecimalpoint astyle == Nothing
|
if isNothing $ asdecimalpoint astyle
|
||||||
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
||||||
else modify' (\j -> j{jcommodities=M.insert acommodity comm $ jcommodities j})
|
else modify' (\j -> j{jcommodities=M.insert acommodity comm $ jcommodities j})
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ formatdirectivep expectedsym = do
|
|||||||
_ <- lift followingcommentp
|
_ <- lift followingcommentp
|
||||||
if acommodity==expectedsym
|
if acommodity==expectedsym
|
||||||
then
|
then
|
||||||
if asdecimalpoint astyle == Nothing
|
if isNothing $ asdecimalpoint astyle
|
||||||
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
||||||
else return $ dbg6 "style from format subdirective" astyle
|
else return $ dbg6 "style from format subdirective" astyle
|
||||||
else customFailure $ parseErrorAt off $
|
else customFailure $ parseErrorAt off $
|
||||||
@ -544,7 +544,7 @@ defaultcommoditydirectivep = do
|
|||||||
off <- getOffset
|
off <- getOffset
|
||||||
Amount{acommodity,astyle} <- amountp
|
Amount{acommodity,astyle} <- amountp
|
||||||
lift restofline
|
lift restofline
|
||||||
if asdecimalpoint astyle == Nothing
|
if isNothing $ asdecimalpoint astyle
|
||||||
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
then customFailure $ parseErrorAt off pleaseincludedecimalpoint
|
||||||
else setDefaultCommodityAndStyle (acommodity, astyle)
|
else setDefaultCommodityAndStyle (acommodity, astyle)
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
module Hledger.Web.Settings where
|
module Hledger.Web.Settings where
|
||||||
|
|
||||||
import Data.Default (def)
|
import Data.Default (def)
|
||||||
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Data.Yaml
|
import Data.Yaml
|
||||||
import Language.Haskell.TH.Syntax (Q, Exp)
|
import Language.Haskell.TH.Syntax (Q, Exp)
|
||||||
@ -71,9 +72,7 @@ staticDir = "static"
|
|||||||
--
|
--
|
||||||
-- To see how this value is used, see urlRenderOverride in Foundation.hs
|
-- To see how this value is used, see urlRenderOverride in Foundation.hs
|
||||||
staticRoot :: AppConfig DefaultEnv Extra -> Text
|
staticRoot :: AppConfig DefaultEnv Extra -> Text
|
||||||
staticRoot conf = case extraStaticRoot $ appExtra conf of
|
staticRoot conf = fromMaybe [st|#{appRoot conf}/static|] . extraStaticRoot $ appExtra conf
|
||||||
Just root -> root
|
|
||||||
Nothing -> [st|#{appRoot conf}/static|]
|
|
||||||
|
|
||||||
-- | Settings for 'widgetFile', such as which template languages to support and
|
-- | Settings for 'widgetFile', such as which template languages to support and
|
||||||
-- default Hamlet settings.
|
-- default Hamlet settings.
|
||||||
|
@ -58,8 +58,8 @@ close CliOpts{rawopts_=rawopts, reportspec_=rspec} j = do
|
|||||||
(o, c) -> (o, c)
|
(o, c) -> (o, c)
|
||||||
|
|
||||||
-- descriptions to use for the closing/opening transactions
|
-- descriptions to use for the closing/opening transactions
|
||||||
closingdesc = fromMaybe (T.pack defclosingdesc) $ T.pack <$> maybestringopt "close-desc" rawopts
|
closingdesc = maybe (T.pack defclosingdesc) T.pack $ maybestringopt "close-desc" rawopts
|
||||||
openingdesc = fromMaybe (T.pack defopeningdesc) $ T.pack <$> maybestringopt "open-desc" rawopts
|
openingdesc = maybe (T.pack defopeningdesc) T.pack $ maybestringopt "open-desc" rawopts
|
||||||
|
|
||||||
-- accounts to close to and open from
|
-- accounts to close to and open from
|
||||||
-- if only one is specified, it is used for both
|
-- if only one is specified, it is used for both
|
||||||
|
@ -24,6 +24,7 @@ import Prelude ()
|
|||||||
import "base-compat-batteries" Prelude.Compat
|
import "base-compat-batteries" Prelude.Compat
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import qualified Data.ByteString.Char8 as BC
|
import qualified Data.ByteString.Char8 as BC
|
||||||
|
import Data.Maybe (fromMaybe, isNothing)
|
||||||
import Data.String
|
import Data.String
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.IO.Temp
|
import System.IO.Temp
|
||||||
@ -31,7 +32,6 @@ import System.Process
|
|||||||
|
|
||||||
import Hledger.Utils (first3, second3, third3, embedFileRelative)
|
import Hledger.Utils (first3, second3, third3, embedFileRelative)
|
||||||
import Text.Printf (printf)
|
import Text.Printf (printf)
|
||||||
import Data.Maybe (fromMaybe)
|
|
||||||
import System.Environment (lookupEnv)
|
import System.Environment (lookupEnv)
|
||||||
import Hledger.Utils.Debug
|
import Hledger.Utils.Debug
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ runPagerForTopic tool mtopic = do
|
|||||||
let defpager = "less -is"
|
let defpager = "less -is"
|
||||||
envpager <- fromMaybe defpager <$> lookupEnv "PAGER"
|
envpager <- fromMaybe defpager <$> lookupEnv "PAGER"
|
||||||
-- force the use of less if a topic is provided, since we know how to scroll it
|
-- force the use of less if a topic is provided, since we know how to scroll it
|
||||||
let pager = if mtopic==Nothing then envpager else defpager
|
let pager = if isNothing mtopic then envpager else defpager
|
||||||
callCommand $ dbg1 "pager command" $
|
callCommand $ dbg1 "pager command" $
|
||||||
pager ++ maybe "" (printf " +'/^( )?%s'") mtopic ++ " " ++ f
|
pager ++ maybe "" (printf " +'/^( )?%s'") mtopic ++ " " ++ f
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user