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)
- "Text" rather than "Plain Text"? HOT 2
- Suggested primary branch name HOT 1
- Could you please release a new version? HOT 3
- Multiple directories do not sum correctly HOT 7
- Error in 'm'ain.ts' File Prevents Installation in Go HOT 1
- Recommended install method fails due to malformed file name HOT 5
- Flag --not-match/-M not working, got ignored entirely HOT 2
- Feature: Add custom languages.json support
- Feature: Add option to count files not supported by scc
- BUG: Multicharacter support HOT 4
- Docker: aquasec/trivy reports CRITICAL and HIGH vulnerabilities HOT 1
- Malware Alerts in SCC x86 Windows Release HOT 3
- REGRESSION: Performance HOT 2
- Consider disabling comoco and size by default HOT 1
- Github action removed HOT 1
- Feature - support language Clipper HOT 10
- Migrated previous GitLab CI code to a GitLab CI/CD Component HOT 1
- Proposal: Upgrade to Go 1.22 HOT 2
- Feature: add support for shebang for R HOT 2
- ULOC missing in JSON output format HOT 5
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.