cgag / loc

Count lines of code quickly.
MIT License
2.29k stars 126 forks source link

Weird filenames in list #79

Open mitsuhiko opened 6 years ago

mitsuhiko commented 6 years ago

loc currently produces for my project some weird filename output (./ vs / vs no prefix):

--------------------------------------------------------------------------------
 Language             Files        Lines        Blank      Comment         Code
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
 Markdown                 1           22            8            0           14
--------------------------------------------------------------------------------
|./README.md                         22            8            0           14
--------------------------------------------------------------------------------
 Toml                     8          224           30            0          194
--------------------------------------------------------------------------------
|./aorta/Cargo.toml                  37            4            0           33
|./server/Cargo.toml                 37            5            0           32
|./trove/Cargo.toml                  31            3            0           28
|./Cargo.toml                        35            7            0           28
|./config/Cargo.toml                 31            4            0           27
|./cabi/Cargo.toml                   26            4            0           22
|./common/Cargo.toml                 18            1            0           17
|./cabi/cbindgen.toml                 9            2            0            7
--------------------------------------------------------------------------------
 Python                   8          520          111            5          404
--------------------------------------------------------------------------------
|./py/setup.py                      112           20            2           90
|./py/smith/auth.py                 113           26            0           87
|./py/smith/utils.py                103           23            2           78
|./py/smith/exceptions.py            59           15            0           44
|pts/git-precommit-hook.py           49           10            1           38
|./py/smith/_compat.py               31            5            0           26
|./py/tests/test_auth.py             31            8            0           23
|./py/smith/__init__.py              22            4            0           18
--------------------------------------------------------------------------------
 Rust                    27         3723          450          446         2827
--------------------------------------------------------------------------------
|./aorta/src/auth.rs                549           77           68          404
|./trove/src/types.rs               413           45           74          294
|./cabi/src/core.rs                 305           29           35          241
|./common/src/dsn.rs                243           36           12          195
|aorta/src/projectstate.rs          313           28           94          191
|./config/src/types.rs              235           26           33          176
|./aorta/src/query.rs               205           24           13          168
|./aorta/src/upstream.rs            190           24           25          141
|./cabi/src/aorta.rs                181           22           19          140
|./common/src/auth.rs               156           15           13          128
|/common/src/project_id.rs          146           18           14          114
|./trove/src/auth.rs                114           15            7           92
|./cabi/src/utils.rs                 90           10            3           77
|./server/src/service.rs             87           19            0           68
|./trove/src/heartbeat.rs            75           10            2           63
|./aorta/src/config.rs               83            7           16           60
|./src/main.rs                       72           10            2           60
|./server/src/errors.rs              63           12            4           47
|./common/src/macros.rs              42            5            0           37
|./aorta/src/lib.rs                  34            2            1           31
|./trove/src/lib.rs                  27            2            4           21
|./server/src/lib.rs                 23            2            1           20
|./common/src/lib.rs                 22            2            1           19
|./config/src/lib.rs                 19            3            1           15
|./cabi/src/lib.rs                   15            3            0           12
|./aorta/src/api.rs                  14            3            3            8
|./common/src/utils.rs                7            1            1            5
--------------------------------------------------------------------------------
 YAML                     1           26            5            0           21
--------------------------------------------------------------------------------
|./appveyor.yml                      26            5            0           21
--------------------------------------------------------------------------------
 C/C++ Header             1          215           34          113           68
--------------------------------------------------------------------------------
|./cabi/include/smith.h             215           34          113           68
--------------------------------------------------------------------------------
 Makefile                 3           40           12            0           28
--------------------------------------------------------------------------------
|./Makefile                          23            8            0           15
|./py/Makefile                       13            3            0           10
|./cabi/Makefile                      4            1            0            3
mitsuhiko commented 6 years ago

Apparently this is caused by the code that attempts to trim the left column.

cgag commented 6 years ago

I should probably just always drop the ./. I'm not super happy with the way this looks as is but things look unbelievably broken if I don't trim. Definitely open to suggestions if you've got any ideas/preferences.

ycdtosa commented 6 years ago

my two cents: 1.- drop the | char ( now you have one more char ) 2.- replace the ./ with / or just drop it. 3.- when trimming use ~ or "..." ( i think there is a iso char for that ) for trimmed paths.

 Rust                    27         3723          450          446         2827
--------------------------------------------------------------------------------
/aorta/src/auth.rs                  549           77           68          404
/trove/src/types.rs                 413           45           74          294
/cabi/src/core.rs                   305           29           35          241
/common/src/dsn.rs                  243           36           12          195
/aorta/src/projectstate.rs          313           28           94          191 (now it fits)
/config/src/types.rs                235           26           33          176
/aorta/src/query.rs                 205           24           13          168
/cabi/src/aorta.rs                  181           22           19          140
/common/src/auth.rs                 156           15           13          128
/common/src/project_id.rs           146           18           14          114 (also fits)
/trove/src/auth.rs                  114           15            7           92
~ry/long/path/filename.rs           313           28           94          191 (trimmed)
/~somefile.rs                         1            1            1            1 (not trimmed, has a / at the start of filename)
ycdtosa commented 6 years ago

using the ellipsis character.

/trove/src/auth.rs                  114           15            7           92
…ry/long/path/filename.rs           313           28           94          191 (trimmed)
/~somefile.rs                         1            1            1            1 (not trimmed, has a / at the start of filename)