fix: resolve 40 SonarCloud critical issues#420
Merged
Conversation
S2871 — String sort without comparator (12 fixes): - Replace bare .sort() with .sort((a, b) => a.localeCompare(b)) in src/registry/checksum.ts, src/core/parsers/index.ts, src/cli/index.ts, and 9 test files S1186 — Empty methods (6 fixes): - Add intentional-no-op comments to SilentReporter methods in src/cli/reporter.ts S2004 — Nested functions too deep (1 fix): - Extract closeHttpServer() helper from src/api/server.ts S1192 — Duplicate string literals (10 fixes): - Extract constants in sdk/go/documents_test.go, sdk/go/search_test.go - Extract _PATH_DOCUMENTS/_PATH_TOPICS in sdk/python/src/pylibscope/client.py S3776 — Cognitive complexity reduction (11 fixes): - src/registry/git.ts: extract extractEntryName() - src/registry/search.ts: extract resolveRegistries(), readRegistryPacks() - src/cli/commands/registry.ts: extract syncSingleRegistry(), syncAllRegistriesAction() - src/core/spider.ts: extract scanPastTag(), processRobotsLine() - src/registry/publish.ts: extract removeEntirePack(), updateManifestAndIndex() - src/core/search.ts: extract addRankedList(), computeRrfScores() - src/api/middleware.ts: extract evictRateLimitEntries() - src/config.ts: extract validateProviderConfig(), validateDatabasePath() - src/core/packs.ts: flatten nested conditionals with early continue - src/cli/index.ts: extract onenoteDeviceAuth(), onenoteRefreshAuth() Closes #419 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
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.



Summary
Resolves 40 of 75 SonarCloud critical/blocker issues from the quality gate scan. Fixes span TypeScript source, Go SDK, and Python SDK.
Closes #419
S2871 — String sort without comparator (12 fixes)
Bare
.sort()on string arrays replaced with.sort((a, b) => a.localeCompare(b))for locale-aware sorting.src/registry/checksum.ts,src/core/parsers/index.ts,src/cli/index.tsS1186 — Empty methods in SilentReporter (6 fixes)
Added
// intentionally empty — silent reporterto each no-op method insrc/cli/reporter.ts.S2004 — Nested function depth (1 fix)
Extracted
closeHttpServer()helper fromsrc/api/server.tsto reduce nesting below 4 levels.S1192 — Duplicate string literals (10 fixes)
errUnexpectedPath,headerContentType,mimeJSON,errUnexpected,testGoDevDocURLconstants in test files_PATH_DOCUMENTS,_PATH_TOPICSmodule-level constants inclient.pyS3776 — Cognitive complexity reduction (11 fixes)
Functions barely over threshold (16-19) reduced via helper extraction and early returns:
src/registry/git.ts,src/registry/search.ts,src/registry/publish.tssrc/cli/commands/registry.ts,src/cli/index.tssrc/core/spider.ts,src/core/search.ts,src/core/packs.tssrc/api/middleware.ts,src/config.tsNot addressed (35 remaining S3776 issues)
Functions with complexity 20-306 require larger refactoring efforts (e.g.,
routes.tsat 306,slack.tsat 88). These are tracked but deferred to avoid an unreviewable PR.Test plan
go test ./...andgo vet ./...pass🤖 Generated with Claude Code