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

✨ add dependency location resolver and get code locations for XML, JSON files #412

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

pranavgaikwad
Copy link
Contributor

@pranavgaikwad pranavgaikwad commented Nov 9, 2023

Fixes #410
Fixes #254

There were two choices to do this:

  1. Add a new optional field lineNumber to Dep type, and let the providers populate it at the time of dependency discovery. This is straight-forward and probably preferred, but requires a change in the output API.
  2. Add a new interface like Snipper, that providers can implement for deps to get locations for a certain dependency.

I chose No. 2 because output API change not needed. But I am not fan of it as its complicated & perf penalty. Asking for your inputs on the approach. If we do go with 2, I think we should we should still remove it in later versions in favor of a new optional field on Dep. Even if we did add it now, it would be non-intrusive.

@pranavgaikwad
Copy link
Contributor Author

@shawn-hurley @fabianvf @djzager Let me know what you guys think of this approach

@pranavgaikwad pranavgaikwad force-pushed the main branch 2 times, most recently from 429f946 to c41efdb Compare November 9, 2023 15:37
Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, did have a couple of concerns but overall I like the cache implementation

provider/provider.go Outdated Show resolved Hide resolved
provider/internal/java/dependency.go Outdated Show resolved Hide resolved
provider/internal/java/dependency.go Outdated Show resolved Hide resolved
@pranavgaikwad pranavgaikwad force-pushed the main branch 4 times, most recently from 0be9c98 to bcb3843 Compare November 13, 2023 13:41
@pranavgaikwad pranavgaikwad marked this pull request as ready for review November 13, 2023 13:41
@pranavgaikwad pranavgaikwad changed the title ✨ add dependency location resolver ✨ add dependency location resolver and get code locations for XML, JSON files Nov 13, 2023
Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the one question around float64 and int

@@ -128,6 +128,8 @@ func (p *builtinProvider) Init(ctx context.Context, log logr.Logger, config prov
config: config,
tags: p.tags,
UnimplementedDependenciesComponent: provider.UnimplementedDependenciesComponent{},
locationCache: make(map[string]float64),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why float and not int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, in provider API, the value is float

@fabianvf
Copy link
Contributor

Looks good!

@pranavgaikwad pranavgaikwad force-pushed the main branch 2 times, most recently from 2400be0 to 667ff88 Compare November 14, 2023 18:48
Signed-off-by: Pranav Gaikwad <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants