unused

A command line tool to identify unused code.

MEMO

  • ag というものが必要

  • ctags を使う

  • Haskell 製だけどどんなプロジェクトでも利用可能

  • Ruby や Elixir などの動的言語で使うと良いって書いてある。Haskell のプロジェクトでは正直使わないと思う。GHC が警告を出してくれるので

インストール

λ brew install the_silver_searcher

λ cabal install unused

λ unused --help
Unused: Analyze potentially unused code

Usage: unused [-P|--no-progress] [-s|--single-occurrence] [-l|--likelihood ARG]
              [-a|--all-likelihoods] [--ignore PATH] [-g|--group-by ARG]
              [-C|--no-cache] [--stdin] [--commits ARG] [--search ARG]
  Unused allows a developer to leverage an existing tags file (located at
  .git/tags, tags, or tmp/tags) to identify tokens in a codebase that are
  unused.

Available options:
  -h,--help                Show this help text
  -P,--no-progress         Don't display progress during analysis
  -s,--single-occurrence   Display only single occurrences
  -l,--likelihood ARG      [Allows multiple] [Allowed: high, medium, low]
                           Display results based on likelihood
  -a,--all-likelihoods     Display all likelihoods
  --ignore PATH            [Allows multiple] Ignore paths that contain PATH
  -g,--group-by ARG        [Allowed: directory, term, file, none] Group results
  -C,--no-cache            Ignore cache when performing calculations
  --stdin                  Read tags from STDIN
  --commits ARG            Number of recent commit SHAs to display per token
  --search ARG             [Allowed: ag, rg] Select searching backend

CLI USAGE: $ unused

使い方

λ git ls-files | xargs ctags
λ unused

参考リソース

Last updated