Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool gets stuck when defining glob filepattern on big repo #377

Open
kostyay opened this issue Aug 10, 2023 · 3 comments
Open

Tool gets stuck when defining glob filepattern on big repo #377

kostyay opened this issue Aug 10, 2023 · 3 comments

Comments

@kostyay
Copy link

kostyay commented Aug 10, 2023

Hey
This is my config:

aliases:
  - type: kebabcase
  - type: filepattern
    paths:
      - '**/manifest.yaml'
    patterns:
      - 'featureFlag: FLAG_KEY'
      - 'feature_flag: FLAG_KEY'

Running the tool like this:

ld-find-code-refs -t KEY -d ./ -p default -r REPO --debug -b master -T github -B master --dryRun -C 0 -l 1

Get the following output and the tool gets stuck:

INFO: 2023/08/10 20:15:58 coderefs.go:27: absolute directory path: XXXX
INFO: 2023/08/10 20:15:58 git.go:48: git branch: master
DEBUG: 2023/08/10 20:15:58 git.go:169: identified head sha: XXXXX

Could it be that I got rate limited because I was running it a bunch of times?
There are 317 files matching that pattern in the repo.

Sometimes it works then I get this output:
dry run found 1113 code references across 720 flags and 844 files

However its still not finding everything I'd expect to be found.
Is there a more verbose debugging mode?

@jazanne
Copy link
Contributor

jazanne commented Aug 10, 2023

@kostyay unfortunately, it is a known issue that the doublestar pattern does not perform very well for alias searching. We recommend using a more limited file pattern if possible. Given that you have 317 patterns to match in the repo, i understand that could be difficult.

There isn't more verbose debugging at this time for alias searching.

@kostyay
Copy link
Author

kostyay commented Aug 10, 2023

Ive tried using
xxx/*/*/manifest.yaml and it didnt help either

EDIT:
I realized that patterns must contain a regex group, otherwise they won't work anyway.
This is what its supposed to look like:

    patterns:
      - 'featureFlag: (FLAG_KEY)'
      - 'feature_flag: (FLAG_KEY)'

@kostyay
Copy link
Author

kostyay commented Aug 10, 2023

@jazanne
You can significantly speed up the initial parsing by caching the results returned by this function:

matches, err := doublestar.FilepathGlob(absGlob)

Example:

var filepathGlobCache = map[string][]string{}

func filepathGlob(absGlob string) ([]string, error) {
	cachedFilePaths, ok := filepathGlobCache[absGlob]
	if ok {
		return cachedFilePaths, nil
	}

	matches, err := doublestar.FilepathGlob(absGlob)
	filepathGlobCache[absGlob] = matches

	return matches, err
}

@jazanne jazanne linked a pull request Nov 3, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants