diff --git a/src/Unused/CLI.hs b/src/Unused/CLI.hs index 0430744..4b6587b 100644 --- a/src/Unused/CLI.hs +++ b/src/Unused/CLI.hs @@ -1,11 +1,8 @@ module Unused.CLI - ( module Unused.CLI.Search - , module Unused.CLI.SearchError - , module Unused.CLI.SearchResult - , module Unused.CLI.Util + ( module X ) where -import Unused.CLI.Search -import Unused.CLI.SearchError -import Unused.CLI.SearchResult -import Unused.CLI.Util +import Unused.CLI.Search as X +import Unused.CLI.SearchError as X +import Unused.CLI.SearchResult as X +import Unused.CLI.Util as X diff --git a/src/Unused/CLI/SearchResult.hs b/src/Unused/CLI/SearchResult.hs index b39c630..2db8b2e 100644 --- a/src/Unused/CLI/SearchResult.hs +++ b/src/Unused/CLI/SearchResult.hs @@ -44,12 +44,12 @@ printMatches w r ms = forM_ ms $ \m -> do setSGR [SetColor Foreground Dull (likelihoodColor $ trRemovalLikelihood r)] setSGR [SetConsoleIntensity NormalIntensity] - putStr $ " " ++ (printf termFormat $ tmTerm m) + putStr $ " " ++ printf termFormat (tmTerm m) setSGR [Reset] setSGR [SetColor Foreground Vivid Cyan] setSGR [SetConsoleIntensity NormalIntensity] - putStr $ (printNumber $ trTotalFiles r) ++ "," ++ (printNumber $ trTotalOccurrences r) ++ " " + putStr $ printNumber (trTotalFiles r) ++ "," ++ printNumber (trTotalOccurrences r) ++ " " setSGR [Reset] setSGR [SetColor Foreground Dull Cyan] @@ -58,5 +58,5 @@ printMatches w r ms = setSGR [Reset] putStr "\n" where - termFormat = "%-" ++ (show w) ++ "s" + termFormat = "%-" ++ show w ++ "s" printNumber = printf "%2d" diff --git a/src/Unused/Parser.hs b/src/Unused/Parser.hs index 6e2426b..e858704 100644 --- a/src/Unused/Parser.hs +++ b/src/Unused/Parser.hs @@ -41,7 +41,7 @@ parseTermMatch = do return $ TermMatch term' path' $ toInt occurrences' where toInt i = read i :: Int - colonSep = do { void $ try $ char ':' } + colonSep = void $ try $ char ':' termChars :: Parser Char termChars = choice [alphaNum, char '_', char '!', char '?', char '=', char '>', char '<', char '[', char ']', char '.'] diff --git a/src/Unused/TermSearch.hs b/src/Unused/TermSearch.hs index 11c068b..187f11d 100644 --- a/src/Unused/TermSearch.hs +++ b/src/Unused/TermSearch.hs @@ -9,13 +9,13 @@ search t = do results <- ag t return $ linesMap prefixTerm results where - prefixTerm = ((++) t) + prefixTerm = (t ++) linesMap :: (String -> String) -> String -> [String] linesMap f = filter empty . map f . lines where - empty = (/= 0) . length + empty = not . null ag :: String -> IO String ag t = do diff --git a/src/Unused/Types.hs b/src/Unused/Types.hs index 0f7fbb1..b030365 100644 --- a/src/Unused/Types.hs +++ b/src/Unused/Types.hs @@ -43,7 +43,7 @@ newtype DirectoryPrefix = DirectoryPrefix String deriving (Eq, Show, Ord) resultsFromMatches :: [TermMatch] -> TermResults resultsFromMatches m = - calculateLikelihood $ TermResults + calculateLikelihood TermResults { trTerm = resultTerm terms , trMatches = m , trTotalFiles = totalFiles @@ -74,23 +74,23 @@ isClassOrModule = matchRegex "^[A-Z]" . trTerm railsSingleOkay :: TermResults -> Bool railsSingleOkay r = - foldl1 (&&) [isClassOrModule r, oneFile r, oneOccurence r, (controller || helper || migration)] + and [isClassOrModule r, oneFile r, oneOccurence r, controller || helper || migration] where - controller = (matchRegex "^app/controllers/" singlePath) && (matchRegex "Controller$" $ trTerm r) - helper = (matchRegex "^app/helpers/" singlePath) && (matchRegex "Helper$" $ trTerm r) + controller = matchRegex "^app/controllers/" singlePath && matchRegex "Controller$" (trTerm r) + helper = matchRegex "^app/helpers/" singlePath && matchRegex "Helper$" (trTerm r) migration = matchRegex "^db/migrate/" singlePath - singlePath = path $ fmap tmPath $ trMatches r + singlePath = path $ tmPath <$> trMatches r path (x:_) = x path [] = "" elixirSingleOkay :: TermResults -> Bool elixirSingleOkay r = - foldl1 (&&) [isClassOrModule r, oneFile r, oneOccurence r, (view || test || migration)] + and [isClassOrModule r, oneFile r, oneOccurence r, view || test || migration] where migration = matchRegex "^priv/repo/migrations/" singlePath - view = (matchRegex "^web/views/" singlePath) && (matchRegex "View$" $ trTerm r) - test = (matchRegex "^test/" singlePath) && (matchRegex "Test$" $ trTerm r) - singlePath = path $ fmap tmPath $ trMatches r + view = matchRegex "^web/views/" singlePath && matchRegex "View$" (trTerm r) + test = matchRegex "^test/" singlePath && matchRegex "Test$" (trTerm r) + singlePath = path $ tmPath <$> trMatches r path (x:_) = x path [] = "" @@ -100,7 +100,7 @@ listFromMatchSet = responsesGroupedByPath :: TermMatchSet -> [(DirectoryPrefix, TermMatchSet)] responsesGroupedByPath pr = - fmap (\p -> (p, responseForPath p pr)) $ directoriesForGrouping pr + (\p -> (p, responseForPath p pr)) <$> directoriesForGrouping pr responseForPath :: DirectoryPrefix -> TermMatchSet -> TermMatchSet responseForPath s = @@ -110,7 +110,7 @@ responseForPath s = filterKVByPath = Map.filterWithKey (const $ \a -> s `elem` allPaths a) allPaths = fmap (fileNameGrouping . tmPath) . trMatches updateMatchesWith f tr = tr { trMatches = f tr } - newMatches = (filter ((== s) . fileNameGrouping . tmPath) . trMatches) + newMatches = filter ((== s) . fileNameGrouping . tmPath) . trMatches fileNameGrouping :: String -> DirectoryPrefix fileNameGrouping =