Skip to content

fix(security): remediate SonarQube vulnerabilities#79

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770237058-sonarqube-remediation
Open

fix(security): remediate SonarQube vulnerabilities#79
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770237058-sonarqube-remediation

Conversation

@devin-ai-integration
Copy link

Closes: N/A (SonarQube remediation task)

Summary

This PR addresses 3 high-severity SonarQube issues:

File Rule Issue Fix
cmd/github-mcp-server/main.go S1192 Duplicated "read-only" string (4 times) Extract readOnlyKey constant
pkg/errors/error.go S1192 Duplicated error message (4 times) Extract errContextMissingGitHubCtxErrors error variable
cmd/github-mcp-server/generate_docs.go S3776 Cognitive complexity 40 (max 15) Extract helper functions

Changes

main.go: Simple constant extraction for the "read-only" configuration key.

error.go: Replaced fmt.Errorf("...") with a package-level error variable using errors.New(). This is more idiomatic Go for static error messages and also satisfies staticcheck SA1006.

generate_docs.go: Refactored generateToolDoc by extracting 5 helper functions:

  • extractPropertyType / extractArrayType - type extraction logic
  • extractPropertyDescription - description extraction
  • formatParamLine - parameter line formatting
  • getSortedParamNames - sorted parameter name collection

Human Review Checklist

  • Verify generateToolDoc refactoring preserves exact output behavior (the nested type-checking logic was the main complexity source)
  • Confirm early-return pattern in generateToolDoc is equivalent to original if-else structure

Testing

  • All existing tests pass
  • Lint checks pass (0 issues)

Link to Devin run: https://app.devin.ai/sessions/379edd90ee8244c5b468b760d21cc62c
Requested by: @parkerduff

- S1192 in main.go: Extract constant 'readOnlyKey' for duplicated 'read-only' string
- S1192 in error.go: Extract error variable for duplicated context error message
- S3776 in generate_docs.go: Reduce cognitive complexity by extracting helper functions
  - extractPropertyType: handles type extraction from property map
  - extractArrayType: handles array item type extraction
  - extractPropertyDescription: handles description extraction
  - formatParamLine: formats parameter documentation line
  - getSortedParamNames: returns sorted parameter names

Co-Authored-By: parker.duff@codeium.com <pwjduff@gmail.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants