(編集:下部の適切な使用セクションを参照してください。 )
主な質問
そのオプションをどのよう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