Fix SonarQube High severity issues in discussions.go #36
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.


Summary
This PR addresses two High severity SonarQube code quality issues in
pkg/github/discussions.go:ListDiscussionsfunction to reduce complexity from 27 to below 15Changes
String Literal Constants
Added package-level constants for duplicated strings:
errFailedToGetGQLClient- "failed to get GitHub GQL client: %v" (used 4x)descRepositoryOwner- "Repository owner" (used 4x)descRepositoryName- "Repository name" (used 4x)formatCategoryLabel- "category:%s" (used 3x)Cognitive Complexity Reduction
Refactored
ListDiscussionsby extracting helper functions:discussionNodetype: Represents GraphQL discussion node structureconvertDiscussionNodeToIssue(): Converts GraphQL node to GitHub Issue objectqueryDiscussions(): Handles GraphQL queries with/without category filterThe main handler now coordinates these helpers instead of containing all the logic inline.
Testing
./script/test)./script/lint)Review Focus Areas
Critical: Verify the refactored
ListDiscussionsmaintains identical behavior:queryDiscussions()correctly handles both categoryID pathsconvertDiscussionNodeToIssue()maps all fields correctlyLow risk: Constants replacement is straightforward - all usages were mechanically replaced.
Link to Devin run: https://app.devin.ai/sessions/2ac756d3cb7d43679481075e347ee576
Requested by: Shawn Azman (@ShawnAzman)