From 22db5c4a3f442cee619021b471646ed7763d6810 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Mon, 16 Aug 2021 15:15:45 +1000 Subject: [PATCH] cln: hlint: Remove warnings to use library list functions. --- .hlint.yaml | 3 --- hledger-lib/Hledger/Read.hs | 6 +----- hledger-lib/Hledger/Utils/Debug.hs | 8 +++----- hledger-lib/Text/Tabular/AsciiWide.hs | 4 ++-- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 8b692d4a4..a7f31d9f9 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -17,7 +17,6 @@ - ignore: {name: "Eta reduce"} - ignore: {name: "Use $>"} - ignore: {name: "Use unless"} -- ignore: {name: "Use any"} - ignore: {name: "Use =<<"} - ignore: {name: "Use fmap"} - ignore: {name: "Use <&>"} @@ -27,14 +26,12 @@ - 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: "Avoid lambda using `infix`"} - ignore: {name: "Functor law"} - ignore: {name: "Missing NOINLINE pragma"} - ignore: {name: "Use dropWhile"} -- ignore: {name: "Use &&"} - ignore: {name: "Use replicate"} - ignore: {name: "Use void"} - ignore: {name: "Use elemIndex"} diff --git a/hledger-lib/Hledger/Read.hs b/hledger-lib/Hledger/Read.hs index fa27f07e3..bda6c194e 100644 --- a/hledger-lib/Hledger/Read.hs +++ b/hledger-lib/Hledger/Read.hs @@ -216,11 +216,7 @@ ensureJournalFileExists f = do -- | Does any part of this path contain non-. characters and end with a . ? -- Such paths are not safe to use on Windows (cf #1056). isWindowsUnsafeDotPath :: FilePath -> Bool -isWindowsUnsafeDotPath = - not . null . - filter (not . all (=='.')) . - filter ((=='.').last) . - splitDirectories +isWindowsUnsafeDotPath = any (\x -> last x == '.' && any (/='.') x) . splitDirectories -- | Give the content for a new auto-created journal file. newJournalContent :: IO Text diff --git a/hledger-lib/Hledger/Utils/Debug.hs b/hledger-lib/Hledger/Utils/Debug.hs index d7bcaeea2..5250d61f6 100644 --- a/hledger-lib/Hledger/Utils/Debug.hs +++ b/hledger-lib/Hledger/Utils/Debug.hs @@ -200,11 +200,9 @@ useColorOnHandle h = unsafePerformIO $ do no_color <- isJust <$> lookupEnv "NO_COLOR" supports_color <- hSupportsANSIColor h let coloroption = colorOption - return $ and [ - not no_color - ,coloroption `notElem` ["never","no"] - ,coloroption `elem` ["always","yes"] || supports_color - ] + return $ not no_color + && coloroption `notElem` ["never","no"] + && (coloroption `elem` ["always","yes"] || supports_color) -- Keep synced with color/colour flag definition in hledger:CliOptions. -- Avoid using dbg*, pshow etc. in this function (infinite loop). diff --git a/hledger-lib/Text/Tabular/AsciiWide.hs b/hledger-lib/Text/Tabular/AsciiWide.hs index 37bcee54f..13fc0c2e5 100644 --- a/hledger-lib/Text/Tabular/AsciiWide.hs +++ b/hledger-lib/Text/Tabular/AsciiWide.hs @@ -27,7 +27,7 @@ module Text.Tabular.AsciiWide import Data.Bifunctor (bimap) import Data.Maybe (fromMaybe) import Data.Default (Default(..)) -import Data.List (intersperse, transpose) +import Data.List (intercalate, intersperse, transpose) import Data.Semigroup (stimesMonoid) import Data.Text (Text) import qualified Data.Text as T @@ -128,7 +128,7 @@ renderTableByRowsB topts@TableOpts{prettyTable=pretty, tableBorders=borders} fc -- maximum width for each column sizes = map (fromMaybe 0 . maximumMay . map cellWidth) $ transpose cells2 renderRs (Header s) = [s] - renderRs (Group p hs) = concat . intersperse sep $ map renderRs hs + renderRs (Group p hs) = intercalate sep $ map renderRs hs where sep = renderHLine VM borders pretty sizes ch2 p -- borders and bars