fix: address SonarQube high-severity issues (S1192, S3776)#74
Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Open
fix: address SonarQube high-severity issues (S1192, S3776)#74devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
- S1192: Extract duplicated string literals in discussions.go
- Added constants for 'Repository owner', 'Repository name',
'failed to get GitHub GQL client', and 'category:%s'
- Replaced all occurrences with the new constants
- S1192: Extract duplicated string literals in search.go
- Added constants for 'failed to read response body' and
'failed to marshal response' error messages
- Replaced all occurrences with the new constants
- S3776: Reduce cognitive complexity in discussions.go
- Extracted discussionNode type and mapDiscussionNodeToIssue helper
- Extracted fetchDiscussionNodes helper function
- Reduced ListDiscussions function complexity from 27 to under 15
- S3776: Reduce cognitive complexity in mcpcurl/main.go
- Extracted loadToolsFromServer helper function
- Reduced main function complexity from 18 to under 15
Co-Authored-By: Abhay Aggarwal <abhay.aggarwal@codeium.com>
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:
|
- Extract gqlDiscussionNode type to share GraphQL node structure - Add toDiscussionNode method for consistent conversion - Add mapGQLNodesToDiscussionNodes helper function - Split fetchDiscussionNodes into fetchDiscussionsWithCategory and fetchDiscussionsWithoutCategory for cleaner separation This addresses SonarCloud's code duplication check (18.4% -> reduced). Co-Authored-By: Abhay Aggarwal <abhay.aggarwal@codeium.com>
|
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 4 high-severity SonarQube issues in the codebase:
S1192 - String literals should not be duplicated:
pkg/github/discussions.go: Extracted constants for "Repository owner", "Repository name", error messages, and category label formatpkg/github/search.go: Extracted constants for error messages used in response handlingS3776 - Cognitive Complexity should not be too high:
pkg/github/discussions.go: ReducedListDiscussionscomplexity from 27 to under 15 by extracting helper types and functionscmd/mcpcurl/main.go: Reducedmaincomplexity from 18 to under 15 by extractingloadToolsFromServerhelper functionHuman Review Checklist
fetchDiscussionsWithCategoryandfetchDiscussionsWithoutCategoryreturn the same data structure as the original inline queriesgqlDiscussionNodestruct tags work correctly with the githubv4 library (thegraphql:"category"andgraphql:"url"tags)loadToolsFromServermatches original behavior (silent failure on errors is intentional)Tradeoffs
The
fetchDiscussionsWithCategoryandfetchDiscussionsWithoutCategoryfunctions still have similar structure because the GraphQL library requires different struct tags for queries with and without thecategoryIdparameter. The refactoring extracts a sharedgqlDiscussionNodetype and mapping functions to minimize duplication while working within this library constraint.Link to Devin run: https://app.devin.ai/sessions/85d47417ad75420d9de1c7f194f23da2
Requested by: Abhay Aggarwal (@abhay-codeium)