unused 0.6.1.1 → 0.7.0.0
raw patch · 4 files changed
+12/−35 lines, 4 filesdep ~cassavadep ~inflectionsdep ~megaparsecPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: cassava, inflections, megaparsec
API changes (from Hackage documentation)
- Unused.CLI.Views.SearchResult.ColumnFormatter: [cfPrintNumber] :: ColumnFormat -> Int -> String
- Unused.CLI.Views.SearchResult.Types: [cfPrintNumber] :: ColumnFormat -> Int -> String
- Unused.CLI.Views.SearchResult.ColumnFormatter: ColumnFormat :: (String -> String) -> (String -> String) -> (Int -> String) -> ColumnFormat
+ Unused.CLI.Views.SearchResult.ColumnFormatter: ColumnFormat :: (String -> String) -> (String -> String) -> ColumnFormat
- Unused.CLI.Views.SearchResult.Types: ColumnFormat :: (String -> String) -> (String -> String) -> (Int -> String) -> ColumnFormat
+ Unused.CLI.Views.SearchResult.Types: ColumnFormat :: (String -> String) -> (String -> String) -> ColumnFormat
Files
- src/Unused/CLI/Views/SearchResult/ColumnFormatter.hs +2/−17
- src/Unused/CLI/Views/SearchResult/TableResult.hs +1/−7
- src/Unused/Projection/Transform.hs +5/−7
- unused.cabal +4/−4
src/Unused/CLI/Views/SearchResult/ColumnFormatter.hs view
@@ -4,17 +4,16 @@ ) where import Text.Printf (printf)-import Unused.Types (TermResults(..), TermMatch(..), totalFileCount, totalOccurrenceCount)+import Unused.Types (TermResults(..), TermMatch(..)) data ColumnFormat = ColumnFormat { cfPrintTerm :: String -> String , cfPrintPath :: String -> String- , cfPrintNumber :: Int -> String } buildColumnFormatter :: [TermResults] -> ColumnFormat buildColumnFormatter r =- ColumnFormat (printf $ termFormat r) (printf $ pathFormat r) (printf $ numberFormat r)+ ColumnFormat (printf $ termFormat r) (printf $ pathFormat r) termFormat :: [TermResults] -> String termFormat rs =@@ -29,17 +28,3 @@ where pathWidth = maximum $ pathLength =<< trMatches =<< rs pathLength = return . length . tmPath--numberFormat :: [TermResults] -> String-numberFormat rs =- "%" ++ show numberWidth ++ "d"- where- numberWidth = maximum [fileWidth, occurrenceWidth]- fileWidth = maximum $ fileLength =<< rs- occurrenceWidth = maximum $ occurrenceLength =<< rs- fileLength = return . numberLength . totalFileCount- occurrenceLength = return . numberLength . totalOccurrenceCount--numberLength :: Int -> Int-numberLength i =- 1 + floor (logBase 10 $ fromIntegral i :: Double)
src/Unused/CLI/Views/SearchResult/TableResult.hs view
@@ -6,24 +6,18 @@ import Unused.CLI.Util import qualified Unused.CLI.Views.SearchResult.Internal as SR import qualified Unused.CLI.Views.SearchResult.Types as SR-import Unused.Types (TermResults, TermMatch(..), tmDisplayTerm, totalFileCount, totalOccurrenceCount)+import Unused.Types (TermResults, TermMatch(..), tmDisplayTerm) printTable :: TermResults -> [TermMatch] -> SR.ResultsPrinter () printTable r ms = do cf <- SR.columnFormat let printTerm = SR.cfPrintTerm cf let printPath = SR.cfPrintPath cf- let printNumber = SR.cfPrintNumber cf SR.liftIO $ forM_ ms $ \m -> do setSGR [SetColor Foreground Dull (SR.termColor r)] setSGR [SetConsoleIntensity NormalIntensity] putStr $ " " ++ printTerm (tmDisplayTerm m)- setSGR [Reset]-- setSGR [SetColor Foreground Vivid Cyan]- setSGR [SetConsoleIntensity NormalIntensity]- putStr $ " " ++ printNumber (totalFileCount r) ++ ", " ++ printNumber (totalOccurrenceCount r) setSGR [Reset] setSGR [SetColor Foreground Dull Cyan]
src/Unused/Projection/Transform.hs view
@@ -5,9 +5,7 @@ import Data.Either (rights) import Data.Text (Text)-import qualified Data.Text as T import qualified Text.Inflections as I-import qualified Text.Inflections.Parse.Types as I import qualified Unused.Util as U data Transform@@ -24,14 +22,14 @@ runTransformation Noop = id toCamelcase :: Text -> Text-toCamelcase t = maybe t (T.pack . I.camelize) $ toMaybeWords t+toCamelcase t = maybe t I.camelize $ toMaybeWords t toSnakecase :: Text -> Text-toSnakecase t = maybe t (T.pack . I.underscore) $ toMaybeWords t+toSnakecase t = maybe t I.underscore $ toMaybeWords t -toMaybeWords :: Text -> Maybe [I.Word]+toMaybeWords :: Text -> Maybe [I.SomeWord] toMaybeWords t = U.safeHead $ rights [asCamel, asSnake] where- asCamel = I.parseCamelCase [] $ T.unpack t- asSnake = I.parseSnakeCase [] $ T.unpack t+ asCamel = I.parseCamelCase [] t+ asSnake = I.parseSnakeCase [] t
unused.cabal view
@@ -1,5 +1,5 @@ name: unused-version: 0.6.1.1+version: 0.7.0.0 synopsis: A command line tool to identify unused code. description: Please see README.md homepage: https://github.com/joshuaclayton/unused#readme@@ -75,12 +75,12 @@ , bytestring , text , unordered-containers- , cassava+ , cassava >= 0.4.5.0 && < 0.5 , vector , mtl , transformers- , megaparsec- , inflections+ , megaparsec >= 5.1.2 && < 6+ , inflections >= 0.3.0.0 && < 0.4 , file-embed ghc-options: -Wall default-language: Haskell2010