launchdarkly / ld-find-code-refs

Build tool for automatically sending feature flag code references to LaunchDarkly
https://launchdarkly.com
Other
46 stars 34 forks source link

Feature: support recursive globbing when finding aliases #151

Closed RookieRick closed 1 year ago

RookieRick commented 3 years ago

attn: @InTheCloudDan I'm working on integrating this as part of my "hackweek" project; I ran into an issue because in many cases we have "constants" defined like SOME_FLAG = 'some-flag-key' and there isn't a prescribed naming convention to put them all in a constants.py file or the like, so I need to be able to search an entire project to find these references. filepath doesn't support ** globstar natively but filepathx does. I forked and found that (so far at least) this approach seems to be working: https://github.com/RookieRick/ld-find-code-refs/pull/1 with caveat that it can take a looong time. In my test this morning it took 8 minutes to run on one of our larger repos, but I can live with that (or try to optimize it later) if I'm plugging this in as a "post-build" task in Jenkins. If you think this would be more broadly useful, happy to do pull request back to the main upstream repo.

InTheCloudDan commented 3 years ago

@RookieRick thanks for raising this. I'll look to get a feature request created to track it. I think we may want to take a look at this as part of fixing ** for .ldignore also and I'd lean towards a library such as: https://github.com/bmatcuk/doublestar which looks like it has some performance tests run.

RookieRick commented 3 years ago

Sounds good, thanks! Time permitting I may try out some performance tests as well; if so will be sure to share here!

RookieRick commented 3 years ago

EDIT: OK, I spoke too soon. Tripped myself up by doing hacky messy code things ;) It wasn't actually finding any files to search for aliases, hence the amazing speed-up.. Re-running now (AND VERIFYING THAT IT ACTUALLY FINDS MY ALIASES ;) )... Did run slightly faster (Just under 7 minutes) when actually searching for and detecting aliases 😂

Good call on the library @InTheCloudDan - I updated to use doublestar and the repo that took 8 minutes previously now runs in ~70sec. My codebases are kind of diverging as I had to move to our Enterprise repo and add some extra Docker/Jenkins stuff to plug in to our CI, but I went ahead and patched my public fork https://github.com/RookieRick/ld-find-code-refs. Note also had to bump version of Golang as doublestar didn't seem to be compatible with 1.13 or 1.14