(編集:下部の適切な使用セクションを参照してください。 )
主な質問
そのオプションをどのようclocに使用し--exclude-list-file=<file>ますか?基本的に、私はそれに.clocignoreファイルを供給しようとしています。
予想される行動
clocドキュメントには次のように記載されています。
--exclude-list-file=<file> Ignore files and/or directories whose names
appear in <file>. <file> should have one entry
per line. Relative path names will be resolved
starting from the directory where cloc is
invoked. See also --list-file.
試み
次のコマンドは期待どおりに機能します。
cloc --exclude-dir=node_modules .
ただし、このコマンドは何も除外しません。
cloc --exclude-list-file=myignorefile .
の内容は次のmyignorefileとおりです。
node_modules
node_modules/
node_modules/*
node_modules/**
./node_modules
./node_modules/
./node_modules/*
./node_modules/**
/full/path/to/current/directory/node_modules
/full/path/to/current/directory/node_modules/
/full/path/to/current/directory/node_modules/*
/full/path/to/current/directory/node_modules/**
clocが存在しなくてもエラーにはならmyignorefileないので、それが何をしているかについてのフィードバックはありません。
(私は OS X を実行しておりcloc、Homebrew 経由で v1.60 をインストールしました。)
適切な使用
tl;dr -- @Raman の回答で指定されている方法は、指定する必要が少なく、.clocignoreかなり高速に実行されます。
@Ramanの回答に拍車をかけ、ソースコードを調査しました。実際には尊重しますcloc が、2つの重要な方法--exclude-list-fileとは異なる方法で処理します。--exclude-dir
正確なファイル名と「パスの一部」
まず、 while--exclude-dirは指定された文字列をパスに含むファイルを無視し、 で指定され--exclude-list-fileた正確なファイルまたはディレクトリのみを除外します.clocignore。
次のようなディレクトリ構造がある場合:
.clocignore
node_modules/foo/first.js
app/node_modules/bar/second.js
そしての内容.clocignoreはちょうど
node_modules
その後、cloc --exclude-list-file=.clocignore .正常に無視さfirst.jsれますが、カウントされますsecond.js。一方cloc --exclude-dir=node_modules .、両方を無視します。
これに対処する.clocignoreには、これを含める必要があります。
node_modules
app/node_modules
パフォーマンス
次に、 のソース コードは、cloc指定されたディレクトリを、ファイルをカウントする前に--exlude-dir調べられるリストに追加するように見えます。によって検出されたディレクトリのリストは、ファイルを数えた後に参照されます。--exclude-list-file
つまり--exclude-list-file、最終レポートで結果を無視する前に、低速になる可能性があるファイルを引き続き処理します。これは実験によって裏付けられています。コードベースの例では、 で実行するのに 0.5秒、同等の で実行するのに 11 秒かかりましclocた。--exclude-dir--exclude-list-file