fix(security): remediate SonarQube vulnerabilities (S1192, S3776)#81
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
fix(security): remediate SonarQube vulnerabilities (S1192, S3776)#81devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
- S1192: Extract duplicated 'Sort order' string to sortOrderDescription constant - S3776 search.go: Reduce cognitive complexity of userOrOrgHandler by extracting: - userSearchParams struct for parameter grouping - extractUserSearchParams for parameter extraction - convertToMinimalUser for user conversion - buildMinimalSearchResult for result building - S3776 repository_resource.go: Reduce cognitive complexity of RepositoryResourceContentsHandler by extracting: - resourceRequestParams struct for parameter grouping - extractRequiredStringArg/extractOptionalStringArg for argument extraction - extractResourceParams for parameter extraction - setRefOptions for ref option setting - handlePRRef for PR reference handling - determineMimeType for MIME type detection - buildResourceContents for content building - handleRawContentResponse for response handling 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:
|
|
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 3 high-severity SonarQube issues by refactoring code to reduce cognitive complexity and eliminate duplicated string literals.
Changes
S1192 - Duplicated string literal (search.go)
sortOrderDescriptionS3776 - Cognitive complexity (search.go:171)
userOrOrgHandlerby extracting helper functions:extractUserSearchParams- parameter extraction and validationconvertToMinimalUser- GitHub User to MinimalUser conversionbuildMinimalSearchResult- result building from search resultsS3776 - Cognitive complexity (repository_resource.go:68)
RepositoryResourceContentsHandlerby extracting helper functions:extractRequiredStringArg/extractOptionalStringArg- argument extractionextractResourceParams- owner/repo/path extractionsetRefOptions- ref option configurationhandlePRRef- PR reference handlingdetermineMimeType- MIME type detectionbuildResourceContents- resource content buildinghandleRawContentResponse- response processingHuman Review Checklist
buildMinimalSearchResultis behaviorally equivalent (removed redundant nil checks that were already handled by getter methods)RepositoryResourceContentsHandler(directory check moved earlier) is acceptabledefer resp.Body.Close()placement after error check is correct (prevents potential nil pointer if GetRawContent fails)Testing
Link to Devin run: https://app.devin.ai/sessions/a538bd03d56241b5af15d0c04d9c0a24
Requested by: @parkerduff