Skip to content

Fix SonarQube High severity issues: string duplication and cognitive complexity#72

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

Fix SonarQube High severity issues: string duplication and cognitive complexity#72
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1767835865-sonarqube-fixes

Conversation

@devin-ai-integration
Copy link

Closes: N/A (SonarQube code quality improvements)

Summary

This PR addresses two High severity SonarQube issues:

  1. go:S1192 - String literals should not be duplicated (pkg/github/repositories.go)

    • Added refsHeadsPrefix constant for the duplicated "refs/heads/" string
    • Replaced 4 occurrences in DeleteFile, CreateBranch, and PushFiles functions
  2. go:S3776 - Cognitive Complexity of functions should not be too high (cmd/mcpcurl/main.go)

    • Extracted nested conditional logic from main() into new loadToolsFromServer() function
    • Reduces cognitive complexity from 18 to below the allowed threshold of 15

Review Checklist

  • Verify the loadToolsFromServer function maintains the same silent error handling behavior as the original nested conditionals
  • Confirm the description string on line 474 containing "refs/heads/" was intentionally NOT changed (it's documentation text)
  • Verify all 4 code occurrences of the string literal were replaced with the constant

Tradeoffs

The new loadToolsFromServer function silently returns on errors, matching the original behavior. This is intentional as the tool loading is best-effort during CLI initialization.


Link to Devin run: https://app.devin.ai/sessions/9ab56167a1a043a38e59a8728df84b80
Requested by: Shannon Hittson (@shannonhittson-eng)

…complexity

- Add refsHeadsPrefix constant to replace duplicated 'refs/heads/' string literals
  in repositories.go (fixes go:S1192)
- Extract loadToolsFromServer function from main() in cmd/mcpcurl/main.go to
  reduce cognitive complexity from 18 to below 15 (fixes go:S3776)

Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
@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 Jan 8, 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