fix(security): remediate SonarQube vulnerabilities#83
Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Open
fix(security): remediate SonarQube vulnerabilities#83devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Conversation
- S1192: Define constants for duplicated string literals - DescriptionPerPage for 'The number of results per page (max 100)' - DescriptionPage for 'The page number of the results to fetch' - DescriptionWorkflowRunID for 'The unique identifier of the workflow run' - ErrGetGitHubClient for 'failed to get GitHub client: %w' - ErrMarshalResponse for 'failed to marshal response: %w' - S3776: Reduce cognitive complexity by extracting helper functions - GetJobLogs: Extract parseJobLogsParams and validateJobLogsParams - ListWorkflowRuns: Extract workflowRunsParams and parseWorkflowRunsParams - RunWorkflow: Extract runWorkflowParams, parseRunWorkflowParams, dispatchWorkflow - ListWorkflowJobs: Extract workflowJobsParams and parseWorkflowJobsParams - ListWorkflowRunArtifacts: Extract artifactsParams and parseArtifactsParams Co-Authored-By: parker.duff@codeium.com <pwjduff@gmail.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:
|
Co-Authored-By: parker.duff@codeium.com <pwjduff@gmail.com>
- Add parseOwnerRepo helper for extracting owner/repo parameters - Add parsePaginationParams helper for extracting per_page/page parameters - Update all parameter parsing functions to use these helpers - Reduces code duplication to address SonarCloud quality gate Co-Authored-By: parker.duff@codeium.com <pwjduff@gmail.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 remediation task)
Summary
This PR addresses 10 SonarQube issues in
pkg/github/actions.go:S1192 - Duplicated String Literals (5 issues): Defined package-level constants for repeated strings:
DescriptionPerPage,DescriptionPage,DescriptionWorkflowRunIDfor parameter descriptionsErrGetGitHubClient,ErrMarshalResponsefor error message formatsS3776 - Cognitive Complexity (5 issues): Extracted parameter parsing into dedicated structs and helper functions for
ListWorkflowRuns,RunWorkflow,ListWorkflowJobs,GetJobLogs, andListWorkflowRunArtifacts.Updates Since Last Revision
parseOwnerRepo()andparsePaginationParams()common helper functions to reduce code duplication across parameter parsing functionsTradeoffs
Complexity vs. Duplication: Reducing cognitive complexity by extracting helper functions introduced some code duplication (parameter parsing patterns). The shared
parseOwnerRepo()andparsePaginationParams()helpers mitigate this, but SonarCloud still reports ~5.7% duplication on new code (threshold is 3%). This check is not required and the PR is mergeable. Further reducing duplication would require more invasive changes (e.g., generics) that may reduce readability.Human Review Checklist
validateJobLogsParams(). Verify the logic correctly enforces:run_idrequired whenfailed_only=true,job_idrequired whenfailed_only=false(nil, err)instead of inlinemcp.NewToolResultError(). Verify callers handle this correctly by wrapping inmcp.NewToolResultError(err.Error())parseOwnerRepo()andparsePaginationParams()are used across 5 functions. Verify they correctly extract parameters in all contexts.Testing
./script/test)./script/lint)Link to Devin run: https://app.devin.ai/sessions/16ba25ad3f3845348ba565399332fe26
Requested by: parker.duff@codeium.com (@parkerduff)