Comments (16)
Sounds good. Ill add that in now. Thanks for sharing it.
from scc.
Sounds interesting. Would it not be acceptable in this case to have them combined into a single regex though?
scc --not-match ".*\.csv|specialDirectory/.*\.txt" .
The above is not tested BTW
from scc.
That's certainly an option; however, I propose this as an enhancement to improve readability and maintainability of the code invoking scc
.
Imagine a project that embeds scc
in a script (make, bash, etc). There will likely be a few variables, or an array variable, containing special cases to ignore. Please see a contrived example below.
SCC_REGEX_EXCLUDES := \
".*\.csv" \
"specialDirectory/.*\.txt" \
".*\build.*" \
"otherSpecialDirectoryPattern" \
".*\.hex" \
"more and more tedious regex.*"
SCC_EXCLUDES_REGEX_STR := $(addprefix --not-match=, $(SCC_REGEX_EXCLUDES))
...
target:
scc $(SCC_EXCLUDES_REGEX_STR) directoryToScan
In this way, it's easier to read and maintain the script. It also simple to add cases for developers who are not regex experts.
You could argue that the encapsulating script could assemble a regex in a way that's better for maintainability, but I would counter that it's prone to error.
from scc.
That's fair enough. I tend to do multiples when using grep in some situations as well. I am not that familiar with cobra which does the argument parsing but I suspect this should be possible.
from scc.
Assuming that you mean the command line arguments to scc
, my guess would be that you could re-use the solution for #61 or what is currently done for --exclude-dir
arguments. Multiple --exclude-dir
arguments appears to work in my local tests.
from scc.
Neat. I'm having a look at this now.
from scc.
So this works very differently to the way #61 does because that worked outside of Cobra. Not sure if https://github.com/spf13/cobra supports multiple of the same arguments to it. I didn't see anything on the main page anyway. Will have to look into that further.
from scc.
Cobra supports StringSlice
flags: https://godoc.org/github.com/spf13/pflag#StringSlice
from scc.
Oh nice. Well that answers that question then. I literally just stepped off a plane after 20 hours of flying and didn't feel like digging into the docs.
Ill have a look at implementing this then, unless you want to do it @dbaggerman ?
from scc.
I'm busy with other stuff right now, but I can pick it up later if you don't get to it.
from scc.
No worries. My plan is to look into the git ignore issue some more as the main thing for me to tinker with for the next chunk of time I block out for this.
from scc.
@andyfitzgerald This has been merged into master. If you want to try it out you can build from there and give it a go, and all credit to @dbaggerman for actually implementing.
from scc.
I tested this morning with scc version 2.4.0
and found the results identical between ...
- single
--not-match
argument: complex regex string where the different regex are joined with|
- multiple
--not-match
arguments: the same regex strings used above, except passed in as multiple arguments without the|
operator
Looks resolved to me. Thanks for the fast work @dbaggerman and @boyter! I'm sure everyone will appreciate the improved readability in their scc
wrapper scripts.
from scc.
@andyfitzgerald if you could let me know what test you used ill add it into the test suite. If not no worries ill just make one of my own, but happy to have yours in there.
from scc.
Thanks for asking. My test cases were ...
single
--not-match
argument: complex regex string where the different regex are joined with|
scc --not-match="(.*\.hex|.*\.d|.*\.o|.*\.csv|^(./)?[0-9]{8}_.*)" .
multiple
--not-match
arguments: the same regex strings used above, except passed in as multiple arguments without the|
operator
scc --not-match=".*\.hex" --not-match=".*\.d" --not-match=".*\.o" --not-match=".*\.csv" --not-match="^(./)?[0-9]{8}_.*" .
Then I simply verified that I got the same file type counts and COCOMO outputs for a directory containing both source files and unwanted files matching those patterns.
from scc.
Added in bfef56a and going to close this down now since all appears well. Thanks for responding with the test case you used.
from scc.
Related Issues (20)
- How can I include all _test.go files by regex. HOT 2
- Question: Use wildcards with excludes? HOT 1
- Unable to use multiple count-as flags HOT 5
- GNUmakefile is not recognized as Makefile HOT 1
- Recognize file type base on mime type HOT 8
- --exclude-dir doesn't exclude directories HOT 4
- Shields like style HOT 2
- Different Results on Windows and Linux HOT 5
- Cut new release? HOT 2
- Why CUDA files are not supported? HOT 2
- scc handle .gitignore are unexpected HOT 1
- error in Ubuntu 18.06: file or directory does not exist HOT 4
- sourcehut on sloc.xyz HOT 8
- Wrong language Complexity/Lines calculation when using -wide
- scc version 3.2.0 fails to compile with 32 bit golang toolchain in Windows HOT 3
- "Arvo" should be "Avro" HOT 1
- Add Templ Support
- Let badge exclude/include some folders HOT 4
- scc includes the .ignore file as part of the project counting HOT 4
- Feature Request Azure Bicep Support HOT 4
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 scc.