mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
cln: hlint: Clean up list related hlint warnings.
This commit is contained in:
parent
22db5c4a3f
commit
beecb3c9ac
@ -7,8 +7,6 @@
|
||||
|
||||
|
||||
# Warnings currently triggered by your code
|
||||
- ignore: {name: "Use ++"}
|
||||
- ignore: {name: "Use list literal"}
|
||||
- ignore: {name: "Move brackets to avoid $"}
|
||||
- ignore: {name: "Redundant $"}
|
||||
- ignore: {name: "Use <$>"}
|
||||
@ -24,17 +22,13 @@
|
||||
- ignore: {name: "Use camelCase"}
|
||||
- ignore: {name: "Use list comprehension"}
|
||||
- ignore: {name: "Redundant <$>"}
|
||||
- ignore: {name: "Use list literal pattern"}
|
||||
- ignore: {name: "Use fewer imports"}
|
||||
- ignore: {name: "Use tuple-section"}
|
||||
- ignore: {name: "Use section"}
|
||||
- ignore: {name: "Avoid lambda using `infix`"}
|
||||
- ignore: {name: "Functor law"}
|
||||
- ignore: {name: "Missing NOINLINE pragma"}
|
||||
- ignore: {name: "Use dropWhile"}
|
||||
- ignore: {name: "Use replicate"}
|
||||
- ignore: {name: "Use void"}
|
||||
- ignore: {name: "Use elemIndex"}
|
||||
- ignore: {name: "Use lambda-case"}
|
||||
|
||||
|
||||
|
8
Shake.hs
8
Shake.hs
@ -299,10 +299,8 @@ main = do
|
||||
Nothing -> return ()
|
||||
|
||||
-- update "source" files depending on .version in the specified packages
|
||||
let dependents = concat [
|
||||
map (</> ".version.m4") specifiedpkgs
|
||||
,map (</> "package.yaml") specifiedpkgs
|
||||
]
|
||||
let dependents = map (</> ".version.m4") specifiedpkgs
|
||||
++ map (</> "package.yaml") specifiedpkgs
|
||||
need dependents
|
||||
|
||||
-- and maybe commit them
|
||||
@ -333,7 +331,7 @@ main = do
|
||||
need [versionfile]
|
||||
version <- ((head . words) <$>) $ liftIO $ readFile versionfile
|
||||
let ma:jor:_ = splitOn "." version
|
||||
nextmajorversion = intercalate "." $ ma : (show $ read jor+1) : []
|
||||
nextmajorversion = intercalate "." [ma, show $ read jor+1]
|
||||
|
||||
-- One simple task: update some strings in a small text file.
|
||||
-- Several ugly solutions:
|
||||
|
@ -50,7 +50,7 @@ setboolopt :: String -> RawOpts -> RawOpts
|
||||
setboolopt name = overRawOpts (++ [(name,"")])
|
||||
|
||||
appendopts :: [(String,String)] -> RawOpts -> RawOpts
|
||||
appendopts new = overRawOpts $ \old -> concat [old,new]
|
||||
appendopts new = overRawOpts (++new)
|
||||
|
||||
-- | Is the named option present ?
|
||||
inRawOpts :: String -> RawOpts -> Bool
|
||||
|
@ -154,8 +154,8 @@ traceWith f a = trace (f a) a
|
||||
-- {-# NOINLINE debugLevel #-}
|
||||
-- Avoid using dbg* in this function (infinite loop).
|
||||
debugLevel :: Int
|
||||
debugLevel = case snd $ break (=="--debug") args of
|
||||
"--debug":[] -> 1
|
||||
debugLevel = case dropWhile (/="--debug") args of
|
||||
["--debug"] -> 1
|
||||
"--debug":n:_ -> readDef 1 n
|
||||
_ ->
|
||||
case take 1 $ filter ("--debug" `isPrefixOf`) args of
|
||||
@ -215,7 +215,7 @@ colorOption :: String
|
||||
colorOption =
|
||||
-- similar to debugLevel
|
||||
let args = unsafePerformIO getArgs in
|
||||
case snd $ break (=="--color") args of
|
||||
case dropWhile (/="--color") args of
|
||||
-- --color ARG
|
||||
"--color":v:_ -> v
|
||||
_ ->
|
||||
@ -223,7 +223,7 @@ colorOption =
|
||||
-- --color=ARG
|
||||
['-':'-':'c':'o':'l':'o':'r':'=':v] -> v
|
||||
_ ->
|
||||
case snd $ break (=="--colour") args of
|
||||
case dropWhile (/="--colour") args of
|
||||
-- --colour ARG
|
||||
"--colour":v:_ -> v
|
||||
_ ->
|
||||
@ -250,13 +250,13 @@ hasOutputFile = outputFileOption `notElem` [Nothing, Just "-"]
|
||||
outputFileOption :: Maybe String
|
||||
outputFileOption =
|
||||
let args = unsafePerformIO getArgs in
|
||||
case snd $ break ("-o" `isPrefixOf`) args of
|
||||
case dropWhile (not . ("-o" `isPrefixOf`)) args of
|
||||
-- -oARG
|
||||
('-':'o':v@(_:_)):_ -> Just v
|
||||
-- -o ARG
|
||||
"-o":v:_ -> Just v
|
||||
_ ->
|
||||
case snd $ break (=="--output-file") args of
|
||||
case dropWhile (/="--output-file") args of
|
||||
-- --output-file ARG
|
||||
"--output-file":v:_ -> Just v
|
||||
_ ->
|
||||
@ -288,8 +288,8 @@ ptraceAt level
|
||||
| otherwise = \s a -> let p = pshow a
|
||||
ls = lines p
|
||||
nlorspace | length ls > 1 = "\n"
|
||||
| otherwise = " " ++ take (10 - length s) (repeat ' ')
|
||||
ls' | length ls > 1 = map (" "++) ls
|
||||
| otherwise = replicate (11 - length s) ' '
|
||||
ls' | length ls > 1 = map (' ':) ls
|
||||
| otherwise = ls
|
||||
in trace (s++":"++nlorspace++intercalate "\n" ls') a
|
||||
|
||||
|
@ -69,7 +69,7 @@ asInit d reset ui@UIState{
|
||||
(_, Nothing) -> 0
|
||||
(_, Just (_,AccountsScreenItem{asItemAccountName=a})) ->
|
||||
headDef 0 $ catMaybes [
|
||||
findIndex (a ==) as
|
||||
elemIndex a as
|
||||
,findIndex (a `isAccountNamePrefixOf`) as
|
||||
,Just $ max 0 (length (filter (< a) as) - 1)
|
||||
]
|
||||
|
@ -397,7 +397,7 @@ balance opts@CliOpts{reportspec_=rspec} j = case balancecalc_ of
|
||||
-- | Render a single-column balance report as CSV.
|
||||
balanceReportAsCsv :: ReportOpts -> BalanceReport -> CSV
|
||||
balanceReportAsCsv opts (items, total) =
|
||||
("account" : ((if commodity_column_ opts then (:) "commodity" else id) $ "balance" : []))
|
||||
("account" : ((if commodity_column_ opts then (:) "commodity" else id) $ ["balance"]))
|
||||
: (concatMap (\(a, _, _, b) -> rows a b) items)
|
||||
++ if no_total_ opts then [] else rows "total" total
|
||||
where
|
||||
|
@ -229,7 +229,7 @@ moveFlagsAfterCommand args = moveArgs $ ensureDebugHasArg args
|
||||
ensureDebugHasArg as =
|
||||
case break (=="--debug") as of
|
||||
(bs,"--debug":c:cs) | null c || not (all isDigit c) -> bs++"--debug=1":c:cs
|
||||
(bs,"--debug":[]) -> bs++"--debug=1":[]
|
||||
(bs,["--debug"]) -> bs++["--debug=1"]
|
||||
_ -> as
|
||||
|
||||
moveArgs args = insertFlagsAfterCommand $ moveArgs' (args, [])
|
||||
|
@ -41,16 +41,16 @@ patchlevel = ""
|
||||
buildversion :: String
|
||||
buildversion = prettify . splitAtElement '.' $ packageversion ++ patchlevel
|
||||
where
|
||||
prettify (major:minor:bugfix:patches:[]) =
|
||||
prettify [major,minor,bugfix,patches] =
|
||||
major ++ "." ++ minor ++ bugfix' ++ patches'
|
||||
where
|
||||
bugfix' = if bugfix == "0" then "" else '.' : bugfix
|
||||
patches' = if patches == "0" then "" else '+' : patches
|
||||
prettify (major:minor:bugfix:[]) = prettify [major,minor,bugfix,"0"]
|
||||
prettify (major:minor:[]) = prettify [major,minor,"0","0"]
|
||||
prettify (major:[]) = prettify [major,"0","0","0"]
|
||||
prettify [] = error' "VERSION is empty, please fix" -- PARTIAL:
|
||||
prettify _ = error' "VERSION has too many components, please fix"
|
||||
prettify [major,minor,bugfix] = prettify [major,minor,bugfix,"0"]
|
||||
prettify [major,minor] = prettify [major,minor,"0","0"]
|
||||
prettify [major] = prettify [major,"0","0","0"]
|
||||
prettify [] = error' "VERSION is empty, please fix" -- PARTIAL:
|
||||
prettify _ = error' "VERSION has too many components, please fix"
|
||||
|
||||
-- | The name of this package's main executable.
|
||||
progname :: String
|
||||
|
@ -30,4 +30,4 @@ getfields s = name:rest
|
||||
|
||||
showheading fmt = format fmt ["cost centre","entries","%time","%alloc","%time-inh","%alloc-inh"]
|
||||
|
||||
format fmt (s1:s2:s3:s4:s5:s6:[]) = printf fmt s1 s2 s3 s4 s5 s6
|
||||
format fmt [s1,s2,s3,s4,s5,s6] = printf fmt s1 s2 s3 s4 s5 s6
|
||||
|
Loading…
Reference in New Issue
Block a user