fix: resolve SonarCloud code quality issues across codebase#99
Open
fix: resolve SonarCloud code quality issues across codebase#99
Conversation
Address ~50 SonarCloud findings: reduce cognitive complexity by extracting helpers, replace deprecated APIs, fix unsafe patterns, and align with CHT coding guidelines (arrow functions, small functions, early returns). Bump tsconfig to ES2023 for toSorted.
SonarCloud flags bare imports like 'fs' and 'path' as non-conventional (typescript:S7772). Updated all source and test files to use 'node:fs' and 'node:path'. Updated proxyquire mock keys in tests to match.
research.ts and research-supervisor-example.ts shared ~90 lines of identical display functions. Extracted into cli/display-helpers.ts.
Moves remaining duplicated code (loadTicket, supervisor init, run loop) into display-helpers.ts. Entry points now only define their unique getTicketPath logic and help hints.
# Conflicts: # .eslintrc # src/agents/documentation-search-agent.ts # src/cli/research.ts # src/utils/context-loader.ts
… and improvement type
Ajay9704
added a commit
to Ajay9704/cht-agent
that referenced
this pull request
May 1, 2026
Revert files not related to ticket validation feature: - .eslintignore - .mocharc.json - test/helpers.ts - test/utils/context-loader.spec.ts - test/utils/ticket-parser.spec.ts These files were modified during SonarLint cleanup but are outside the scope of PR medic#53 (ticket validation). They will be addressed separately in PR medic#99. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 4, 2026
Hareet
previously approved these changes
May 6, 2026
Member
Hareet
left a comment
There was a problem hiding this comment.
LGTM
small node consistency if you want to grab it during this pass:
node 18 in conventional-commits.yml
node 22 in unit_tests.yml
and node >= 22 in engines.node
# Conflicts: # .github/workflows/conventional-commits.yml
Member
Author
|
@Hareet bumped |
Hareet
approved these changes
May 6, 2026
Member
Hareet
left a comment
There was a problem hiding this comment.
Verified:
- ✅ PR #98's script-injection mitigation preserved (env: PR_TITLE + <<< "$PR_TITLE").
- ✅ PR #98's --ignore-scripts hardening preserved.
- ✅ PR #98's action version bumps (@v6) preserved.
- ✅ Node 22 (PR #99's intent) preserved.
- ✅ Now consistent with unit_tests.yml and engines.node.
- ✅ cache: npm is a small bonus that's safe — package-lock.json exists at the branch root, so the cache key has something to hash and npm ci won't fail.
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
research.ts,research-supervisor-example.ts,research-supervisor.ts,context-analysis-agent.ts,domain-inference.ts,ticket-parser.ts,context-loader.tsmodelName→modelin LangChain ChatAnthropic,.match()→RegExp.exec()response.content.toString()→ safe type check,any→Record<string, unknown>, regex backtracking fixes,String.rawfor regex escapesfunctiondeclarations → arrow functions, inline unions → type aliases (IssueType,Priority,Complexity), early returnstoSorted(), addcoverage/to.eslintignore, addno-require-imports: offfor testsloadDomainIndicesindomain-inference.ts(was dead commented-out code, now wired up)