mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
hlint suggestions
This commit is contained in:
parent
e34f6951f1
commit
4175effffb
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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 '.']
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user