launchdarkly / ld-find-code-refs

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

The entry `.*` in the gitignore breaks the analysis of the whole repository #359

Open stefanmeschke opened 1 year ago

stefanmeschke commented 1 year ago

When having the entry .* (to ignore all dot files) in the .gitignore file the cli does not find any flag usage.

Please let me know when you need more information. Thanks in advance!

jazanne commented 1 year ago

@stefanmeschke thank you for reporting this issue. Can you share which version you're using and any output that you get when you running the tool?

stefanmeschke commented 1 year ago

Thanks for the quick response! 🙏

Version: 2.10.0 Output:

INFO: 2023/06/07 21:22:31 coderefs.go:27: absolute directory path: /development/repository
DEBUG: 2023/06/07 21:22:31 git.go:105: identified branch name: <BRANCH>
INFO: 2023/06/07 21:22:31 git.go:48: git branch: <BRANCH>
DEBUG: 2023/06/07 21:22:31 git.go:169: identified head sha: b63fc56382eb52b419cd8e2b62269be8886491a1
     FLAG     | # REFERENCES
--------------+---------------
  Other flags |            0
INFO: 2023/06/07 21:22:40 coderefs.go:139: dry run found 0 code references across 217 flags and 0 files
INFO: 2023/06/07 21:22:40 coderefs.go:182: checking if 217 flags without references were removed in the last 10 commits for project: default
DEBUG: 2023/06/07 21:22:40 git.go:259: Examining commit: b63fc56382eb52b419cd8e2b62269be8886491a1
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: FROM_PATH and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: FROM_PATH and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: FROM_PATH and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:259: Examining commit: 8b41cb5963a12e30be306ff3ecc341e89099ab67
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: FROM_PATH and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:259: Examining commit: 91b0dd4939e18f0821cfbbe36c462c1b7967b7ce
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:40 git.go:259: Examining commit: 60bd249aacac85fec623698b453ecbeb7f4c77ec
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: FROM_PATH and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:259: Examining commit: 7cbf4b3744a13369a48e2dd0c4dd6a3479fcaffc
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:259: Examining commit: fec39e8868452754b723d12124d95378ca49a8cb
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:259: Examining commit: 6384c35d2fd5e48f57f2c0cb4a3ae3c793884a46
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:259: Examining commit: 951f8e953a0fba9877eeffea84e1e73e9a12de9d
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:259: Examining commit: caf1b1278cb821bf0ad942de6e6472192a153d00
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:259: Examining commit: f296ff2d90b0333c1cf33510856e38d9ad60c2b4
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
DEBUG: 2023/06/07 21:22:41 git.go:358: Scanning from file: <FILE> and to file: <FILE>
INFO: 2023/06/07 21:22:41 coderefs.go:187: found 0 removed flags

As far as I can see there is nothing special in the output. I've replaced all files with <FILE>.

jazanne commented 1 year ago

@stefanmeschke Thank you for sharing!

just to clarify - when you run this without .* in the gitignore, how many flags are found in how many files?

stefanmeschke commented 1 year ago

When running this without the ignore then all flags in all files which are referencing flags are found.

jazanne commented 1 year ago

@stefanmeschke thank you for your patience as we looked into this issues.

The behavior you see is a result of underlying differences between gitignore and unix glob matching

Can you try updating your .gitignore file to remove .* and use the following pattern instead?

.[!.]*
jmgawecki commented 9 months ago

Hey there, facing similar issue but when using .ldignore:

# Ignore all files
[!.]*
# But exclude the desired file
!/Modules/Dir/FeatureFlags.swift

This simply disregards everything and scans all the files

jazanne commented 9 months ago

@jmgawecki I think there are two things probably happening here

  1. You are seeing Scanning logs (similar to those above) that are actually happening during extinction search. There is a known issue where ignores are not respected during that phase of the pipeline (See: https://github.com/launchdarkly/ld-find-code-refs/issues/319)

  2. The file you want to be scanned !/Modules/Dir/FeatureFlags.swift isn't being scanned because the whole directory is being skipped by pattern [!.]*. This does seems to be a bug and I'll report it to team.

In the meantime, are you able to share more info about why you only want to scan one file for code references? This isn't something we've encountered before and I'd love to know more about your use case.