Show the GAV being searched for in DependencyInsight's instance name - #200
Merged
Merged
Conversation
DependencyInsight has two required options, so Recipe.getInstanceName()'s single-required-option rule never fires and every run renders as the bare display name. Override getInstanceNameSuffix() to always carry the group and artifact patterns, plus the version when one is set. The suffix is empty when the patterns are null, which is the case when the descriptor of an unconfigured recipe is rendered in a catalog; an unguarded format string shows `null:null` there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
DependencyInsightrenders in recipe lists as a bare "Dependency insight for Gradle and Maven", with no indication of what it is actually searching for. Two runs looking for completely different dependencies are indistinguishable.That isn't an accident of the UI — it falls out of
Recipe.getInstanceName(), which only appends a value when a recipe has exactly one required option:DependencyInsighthas two required options,groupIdPatternandartifactIdPattern, so it falls through to the plain display name every time, however it was configured.The change
Override
getInstanceNameSuffix()so the GAV being searched for is always part of the name:com.fasterxml.jackson*/jackson-*`com.fasterxml.jackson*:jackson-*`2.x`com.fasterxml.jackson*:jackson-*:2.x`versionis included only when set, since it defaults to searching all versions.scopeis deliberately left out — it narrows the search rather than identifying what is being searched for.On the null guard
The suffix returns
""when either pattern is null, which is worth calling out because the obvious implementation gets this wrong.Both patterns are required options, so they are non-null in any valid configuration. But
getInstanceName()is also called on the descriptor of an unconfigured recipe, where every option is null — that is what gets rendered in a recipe catalog or marketplace listing. An unguardedString.format("%s:%s", groupIdPattern, artifactIdPattern)produces "Dependency insight for Gradle and Mavennull:null" there.moderneinc/moderne-saas#1841was diagnosed, where an unguarded suffix on another recipe rendered as`null:null:null`. Returning""keeps the blank-suffix path ingetInstanceName(), which falls back to the display name.ChangeDependency.getInstanceNameSuffix()in this repo has the same unguarded shape and will render`null:null`for an unconfigured descriptor. I have left it alone to keep this PR to one recipe — happy to fix it here or in a follow-up, whichever you prefer.Tests
Three cases in
DependencyInsightTest: the GAV suffix, the version-included variant, and the unconfigured descriptor falling back to the display name.