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