-
Notifications
You must be signed in to change notification settings - Fork 53
🐛 addressing feedback - using const instead of map for location code values #1028
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
Conversation
WalkthroughReplaced the static Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
external-providers/java-external-provider/pkg/java_external_provider/provider.go (1)
72-107: Add documentation for the public function.The new
GetLocationTypeFromStringfunction is public but lacks godoc documentation. Consider adding a comment describing its purpose, parameters, and behavior.Apply this diff to add documentation:
+// GetLocationTypeFromString converts a location string to its corresponding LocationType. +// The input string is normalized to lowercase before matching. +// Returns LocationTypeDefault for empty strings or unknown location values. func GetLocationTypeFromString(location string) LocationType { switch strings.ToLower(location) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
external-providers/java-external-provider/pkg/java_external_provider/provider.go(1 hunks)external-providers/java-external-provider/pkg/java_external_provider/service_client.go(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-02T02:57:09.802Z
Learnt from: tsanders-rh
Repo: konveyor/analyzer-lsp PR: 1004
File: external-providers/java-external-provider/go.mod:49-50
Timestamp: 2025-12-02T02:57:09.802Z
Learning: In the konveyor/analyzer-lsp monorepo, all external providers (java-external-provider, dotnet-external-provider, generic-external-provider) include a `replace github.com/konveyor/analyzer-lsp => ../../` (or `../..`) directive in their go.mod files. This replace directive is the established pattern for local development within the monorepo and allows providers to reference the local analyzer-lsp module. When providers are built outside the repository, the versioned dependency declared in the require block is used instead.
Applied to files:
external-providers/java-external-provider/pkg/java_external_provider/service_client.go
📚 Learning: 2025-07-30T12:11:45.673Z
Learnt from: pranavgaikwad
Repo: konveyor/analyzer-lsp PR: 859
File: external-providers/java-external-provider/pkg/java_external_provider/dependency.go:694-694
Timestamp: 2025-07-30T12:11:45.673Z
Learning: In the Java external provider dependency walker (external-providers/java-external-provider/pkg/java_external_provider/dependency.go), errors from toDependency function calls should be ignored as they are not considered important by the maintainers.
Applied to files:
external-providers/java-external-provider/pkg/java_external_provider/provider.go
🧬 Code graph analysis (1)
external-providers/java-external-provider/pkg/java_external_provider/service_client.go (2)
external-providers/java-external-provider/pkg/java_external_provider/provider.go (1)
GetLocationTypeFromString(72-107)provider/provider.go (1)
Location(353-356)
🔇 Additional comments (3)
external-providers/java-external-provider/pkg/java_external_provider/provider.go (1)
72-107: LGTM! Clean refactoring to const-based approach.The switch-based implementation is more maintainable and performant than the previous map approach. The normalization via
strings.ToLower()ensures case-insensitive matching, and explicit handling of the empty string case makes the default behavior clear.external-providers/java-external-provider/pkg/java_external_provider/service_client.go (2)
78-78: LGTM! Proper usage of the new helper function.The call site correctly uses
GetLocationTypeFromStringto resolve the location type, and the returnedLocationTypeis appropriately used in the switch statement below.
123-123: LGTM! Correct usage with explicit int cast.The explicit
intcast is appropriate here since the value is being formatted as a string to pass to the language server. This maintains the same behavior as the previous map-based implementation.
…lues Signed-off-by: Savitha Raghunathan <[email protected]>
73ca9db to
4d08f03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
external-providers/java-external-provider/pkg/java_external_provider/provider.go (1)
72-108: LGTM! Clean refactoring from map to switch-based approach.The function correctly implements the requested refactoring from issue #1023. The switch statement is more performant and type-safe than the previous map approach, and it covers all 15 location types properly.
Consider these optional enhancements for robustness:
- Add a godoc comment to document the function's behavior, especially the default return value for unknown inputs:
+// GetLocationTypeFromString converts a location string to its corresponding LocationType constant. +// The comparison is case-insensitive. Returns LocationTypeDefault for empty or unknown location strings. func GetLocationTypeFromString(location string) LocationType {
- Trim whitespace before processing to handle inputs with leading/trailing spaces:
func GetLocationTypeFromString(location string) LocationType { - switch strings.ToLower(location) { + switch strings.ToLower(strings.TrimSpace(location)) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
external-providers/java-external-provider/pkg/java_external_provider/provider.go(1 hunks)external-providers/java-external-provider/pkg/java_external_provider/service_client.go(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- external-providers/java-external-provider/pkg/java_external_provider/service_client.go
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-30T12:11:45.673Z
Learnt from: pranavgaikwad
Repo: konveyor/analyzer-lsp PR: 859
File: external-providers/java-external-provider/pkg/java_external_provider/dependency.go:694-694
Timestamp: 2025-07-30T12:11:45.673Z
Learning: In the Java external provider dependency walker (external-providers/java-external-provider/pkg/java_external_provider/dependency.go), errors from toDependency function calls should be ignored as they are not considered important by the maintainers.
Applied to files:
external-providers/java-external-provider/pkg/java_external_provider/provider.go
📚 Learning: 2025-12-02T02:57:09.802Z
Learnt from: tsanders-rh
Repo: konveyor/analyzer-lsp PR: 1004
File: external-providers/java-external-provider/go.mod:49-50
Timestamp: 2025-12-02T02:57:09.802Z
Learning: In the konveyor/analyzer-lsp monorepo, all external providers (java-external-provider, dotnet-external-provider, generic-external-provider) include a `replace github.com/konveyor/analyzer-lsp => ../../` (or `../..`) directive in their go.mod files. This replace directive is the established pattern for local development within the monorepo and allows providers to reference the local analyzer-lsp module. When providers are built outside the repository, the versioned dependency declared in the require block is used instead.
Applied to files:
external-providers/java-external-provider/pkg/java_external_provider/provider.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build-all-providers (java, java-provider, external-providers/java-external-provider/Dockerfile, J...
- GitHub Check: build-all-providers (c-sharp, c-sharp-provider, Dockerfile, konveyor/c-sharp-analyzer-provider, f...
- GitHub Check: build-all-providers (generic, generic-provider, external-providers/generic-external-provider/Dock...
- GitHub Check: test (windows-latest, windows, amd64)
- GitHub Check: test (ubuntu-latest, linux, arm64)
- GitHub Check: test (macos-latest, darwin, arm64)
- GitHub Check: test (macos-latest, darwin, amd64)
- GitHub Check: test (ubuntu-latest, linux, amd64)
- GitHub Check: benchmark (windows-latest, windows)
- GitHub Check: benchmark (macos-latest, mac)
fixes #1023
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.