Fix SonarQube high severity issues: string duplication and cognitive complexity #20
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.


Fix SonarQube High Severity Issues: String Duplication and Cognitive Complexity
This PR addresses high severity SonarQube issues in the GitHub MCP Server codebase, specifically targeting:
Changes Made
String Duplication Fixes
Created
pkg/github/constants.gowith shared error message constants:ErrFailedToGetGitHubClient = "failed to get GitHub client: %w"ErrFailedToMarshalResponse = "failed to marshal response: %w"ErrFailedToReadResponseBody = "failed to read response body: %w"Replaced duplicated strings across 10 files in
pkg/github/:actions.go(24+ occurrences)discussions.go(4 occurrences)issues.go,pullrequests.go,repositories.go,search.gocode_scanning.go,secret_scanning.go,repository_resource.goCognitive Complexity Fixes
ListNotificationsfunction by extracting helper functions:validateListNotificationsParams()- parameter validation logicfetchNotifications()- API call logicCritical Review Areas
%wstill works correctly across all usage contextsdiscussions.go, changed fromfmt.Sprintf()tofmt.Errorf().Error()pattern - ensure this doesn't break error chains%wdirective but are used in bothfmt.Errorf()andfmt.Sprintf()contextsTesting
./script/test)./script/lint)Tradeoffs
Link to Devin run: https://app.devin.ai/sessions/6096906a8fca4aac8ca7b5b0b5bbc01b
Requested by: @eashansinha
Closes: N/A (SonarQube code quality improvements)