Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

cargo count counts rust source files in the target/ directory #8

Closed
daboross opened this issue Aug 22, 2015 · 2 comments
Closed

cargo count counts rust source files in the target/ directory #8

daboross opened this issue Aug 22, 2015 · 2 comments
Labels

Comments

@daboross
Copy link

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
Copy link
Owner

kbknapp commented Aug 22, 2015

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.

@kbknapp
Copy link
Owner

kbknapp commented Aug 22, 2015

Also the unsafe counter isnt 100% accurate right now. It's actually what I'm working on right now in #5 , so v0.1.1 should be better in that regard ;)

@kbknapp kbknapp added the C: cli label Aug 23, 2015
homu added a commit that referenced this issue Dec 24, 2015
imp: Ignore files in accordance with .gitignore

I noticed discussion of this in issues #8 and #9.  Here's the approach I took:

  * By default `.gitignore`d paths are ignored.
  * A `-a` / `--all` flag returns the old behavior.
  * A single `.gitignore` file is looked for in the directory in which cargo count is called. No attempt is made to find additional `.gitignore` files in sub-directories.

I have a pull request open with the `gitignore` crate to reclassify `tempdir` as a dev dependency. If that patch gets merged, this patch should be able to be amended to not bring in any additional dependencies except `gitignore` itself.
@kbknapp kbknapp closed this as completed Dec 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants