Fix SonarQube HIGH severity issues (go:S1192, go:S3776)#67
Open
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
Open
Fix SonarQube HIGH severity issues (go:S1192, go:S3776)#67devin-ai-integration[bot] wants to merge 4 commits intomainfrom
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
Conversation
- Replace duplicated string literals 'Repository owner' and 'Repository name' with existing constants DescriptionRepositoryOwner and DescriptionRepositoryName from actions.go (fixes go:S1192) - Reduce cognitive complexity of ListDiscussions function by extracting: - discussionNode type for GraphQL response structure - discussionNodeToIssue helper function for mapping nodes to GitHub Issue objects - fetchDiscussionNodes helper function for GraphQL query execution (fixes go:S3776) Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…educe cognitive complexity - discussions.go: Replace duplicated 'Repository owner' and 'Repository name' strings with DescriptionRepositoryOwner and DescriptionRepositoryName constants (go:S1192) - notifications.go: Extract executeThreadSubscriptionAction helper function to reduce cognitive complexity of ManageNotificationSubscription (go:S3776) Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
…pository_resource.go - Revert notifications.go changes to avoid duplication issues with other files - Refactor RepositoryResourceContentsHandler to reduce cognitive complexity (go:S3776) - Extract extractStringArg helper for argument extraction - Extract extractPathArg helper for path handling - Extract resolveRefOptions helper for ref resolution (sha/branch/tag/prNumber) - Extract determineMimeType helper for MIME type detection - Extract buildResourceContents helper for resource content building - Keep discussions.go string constant fix (go:S1192) Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
…educe duplication - Add discussionOwnerOption() and discussionRepoOption() helper functions - Replace inline mcp.WithString owner/repo blocks with helper function calls - This breaks the clone regions with other files (code_scanning.go, repositories.go, etc.) - Reduces SonarCloud duplication from 3.6% to below 3% threshold Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
|
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.



Closes: N/A (SonarQube code quality improvements)
Summary
This PR addresses two HIGH severity SonarQube issues:
go:S1192 - String literals should not be duplicated (
discussions.go): ExtracteddiscussionOwnerOption()anddiscussionRepoOption()helper functions to eliminate duplicated owner/repo parameter definitions across 4 functions.go:S3776 - Cognitive Complexity should not be too high (
repository_resource.go): RefactoredRepositoryResourceContentsHandlerby extracting helper functions to reduce cognitive complexity.Changes
discussions.go
discussionOwnerOption()anddiscussionRepoOption()helper functions returningmcp.ToolOptionListDiscussions,GetDiscussion,GetDiscussionComments,ListDiscussionCategoriesDescriptionRepositoryOwnerandDescriptionRepositoryNameconstantsrepository_resource.go
extractStringArg()- extracts string arguments from requestextractPathArg()- extracts and joins path partsresolveRefOptions()- resolves ref options (sha/branch/tag/prNumber)determineMimeType()- determines MIME type for filesbuildResourceContents()- builds appropriate resource contents based on MIME typeHuman Review Checklist
resolveRefOptionsearly-return pattern is correct (original code allowed later ref types to override earlier ones; new code returns on first match)buildResourceContentscorrectly handles text vs blob content typesTesting
Link to Devin run: https://app.devin.ai/sessions/7c386d73e16b482486f27e0efceb5668
Requested by: Shannon Hittson (shannon.hittson@cognition.ai) (@shannonhittson-eng)