Comments (10)
cloc
should deny invocations with option --excludir-dir
containing separators like src/test
because the user might think the directory has been successfully filtered.
from cloc.
OK, so maybe the solution was easy after all. Internally, the problem came down to --not-match-d
only examining the last directory in the path, ie, for /usr/local/lib
, cloc would only test --not-match-d
's regex against lib
. Git commit 242c795 expands the --fullpath
switch so that it also updates --not-match-d
's behavior to consider the full path.
With the new code you should be able to achieve what you're after. Here's an example session:
mkdir -p test/foo/bar/lala test/bar/foo/momo echo "echo hi" > test/foo/bar/lala/tfbl.sh echo "echo hello" > test/bar/foo/momo/tbfm.sh # run 1: count everything cloc --by-file test 2 text files. 2 unique files. 0 files ignored. github.com/AlDanial/cloc v 1.67 T=0.01 s (140.6 files/s, 140.6 lines/s) --------------------------------------------------------------------------------------- File blank comment code --------------------------------------------------------------------------------------- test/bar/foo/momo/tbfm.sh 0 0 1 test/foo/bar/lala/tfbl.sh 0 0 1 --------------------------------------------------------------------------------------- SUM: 0 0 2 --------------------------------------------------------------------------------------- # run 2: only exclude test/bar/* but not test/foo/bar/ cloc --by-file --fullpath --not-match-d test/bar test 1 text file. 1 unique file. 1 file ignored. github.com/AlDanial/cloc v 1.67 T=0.01 s (89.8 files/s, 89.8 lines/s) --------------------------------------------------------------------------------------- File blank comment code --------------------------------------------------------------------------------------- test/foo/bar/lala/tfbl.sh 0 0 1 --------------------------------------------------------------------------------------- # run 3: only exclude test/foo/bar but not test/bar/ cloc --by-file --fullpath --not-match-d test/foo/bar test 1 text file. 1 unique file. 1 file ignored. github.com/AlDanial/cloc v 1.67 T=0.01 s (80.6 files/s, 80.6 lines/s) --------------------------------------------------------------------------------------- File blank comment code --------------------------------------------------------------------------------------- test/bar/foo/momo/tbfm.sh 0 0 1 ---------------------------------------------------------------------------------------
One last thing remains before I can close this out: give the same treatment to --exclude-dir
.
from cloc.
See the section "Filter Options" at https://github.com/AlDanial/cloc#options
from cloc.
@AlDanial works when used --exclude-dir=test
But if try --excludir-dir=src/test not works :\
another question, if exist another directory called 'test', exemple:
spec/test.
When I execute cloc with "--exclude-dir=test " both directory(src/test,spec/test) are excluded?
from cloc.
If you say --exclude-dir=test then both src/test and spec/test are excluded.
There isn't (yet) a way to prune directories based on anything except the last directory name in a path.
from cloc.
thanks for answer @AlDanial, and I think this would be a great feature.
indeed @jolkdarr
from cloc.
Good idea @jolkdarr. I'll add a warning if --exclude-dir and --not-match-d contain separators.
from cloc.
Any chance of getting exclude dir or another option for excluding a path. For instance if I have a dir name test/foo/bar/lala and test/bar/foo/momo I want to only exclude test/bar/* but NOT test/foo/bar/
I don't think there is a way to do that currently in cloc short of xargs/find magic feeding a file list into cloc.
from cloc.
Yes, this is definitely on my to-do plan.
I actually took a shot at implementing the solution--I figured it would be a piece of cake--but it was a bit more involved than I first thought. Until last week my focus was getting v1.66 checked out solidly enough to release. Now that it is out I will turn my attention back to the harder problems.
from cloc.
Actually, --exclude-dir
serves a slightly different purpose. I left its behavior alone and implemented @jolkdarr's suggestion to prohibit path separators in --exclude-dir
.
from cloc.
Related Issues (20)
- Extract comments from files (reverse of --strip-comments) HOT 2
- Ignore files auto-generated by specflow HOT 2
- Possible erroneous line termination HOT 2
- Option to display results for specific languages only HOT 1
- Report by language and by file in the same report HOT 1
- cloc counts ReasonML //-prefixed line comments as code HOT 1
- Diff counting not working as intended? HOT 4
- Add foreign key to t table to relate to the metadata table. HOT 7
- How to see the full file names as well as the language types HOT 7
- The result of diff is different from the result of git diff HOT 6
- Adding support for prisma
- cloc counts "#if 0" lines as code HOT 1
- Extraneous comma in JSON output after `n_lines` in header HOT 1
- C/C++ Header Segregation HOT 1
- Add PRQL
- Git repositories are not correctly detected HOT 2
- Include .mts and .mjs files for TS/JS HOT 1
- Incorrect diffs count between code and comment HOT 2
- Need to exclude .o.d file automatically, currently recognized .o.d as .d file HOT 1
- cloc returns different data on stdout when run with Node exec function on Ubuntu and on Mac HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloc.