cargo count counts rust source files in the target/ directory
daboross opened this issue · 2 comments
daboross commented
On a project using piston with 5 source files and no unsafe code in src/
, I get this output:
$ cargo count --unsafe-statistics
Gathering information...
Language Files Lines Blanks Comments Code Unsafe (%)
-------- ----- ----- ------ -------- ---- ----------
Rust 10 28094 2972 517 24605 964 (3.92%)
TOML 1 23 3 0 20
-------- ----- ----- ------ -------- ---- ----------
Totals: 11 28117 2975 517 24625 964 (3.91%)
I believe that this is due to cargo count
taking into account files in the target/
directory, such as generated source files:
$ find . -iname '*.rs'
./target/debug/build/glutin-7fb876b2b34f427b/out/glx_bindings.rs
./target/debug/build/glutin-7fb876b2b34f427b/out/test_gl_bindings.rs
./target/debug/build/glutin-7fb876b2b34f427b/out/egl_bindings.rs
./target/debug/build/glutin-7fb876b2b34f427b/out/glx_extra_bindings.rs
./target/debug/build/gl-9653698dd50d604e/out/bindings.rs
./src/rust/level_serialization/mod.rs
./src/rust/map/mod.rs
./src/rust/player/mod.rs
./src/rust/lib.rs
./src/rust/main.rs
Perhaps cargo count
should either hardcode ignoring target/
, or read and ignore files ignored in .gitignore
like cargo does?
kbknapp commented
It's on the to-do list to follow what's already in .gitignore like cargo does, but I haven't done it this early in development yet. For now, you pass the -e target
(or --exclude target
)to tell it to ignore that dir.