Skip to content

fix(test): resolve 14 S5906 + 2 S5914 SonarQube smells (#160)#172

Merged
EmiyaKiritsugu3 merged 1 commit into
mainfrom
fix/sonarqube-smells-160
Jul 4, 2026
Merged

fix(test): resolve 14 S5906 + 2 S5914 SonarQube smells (#160)#172
EmiyaKiritsugu3 merged 1 commit into
mainfrom
fix/sonarqube-smells-160

Conversation

@EmiyaKiritsugu3

@EmiyaKiritsugu3 EmiyaKiritsugu3 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Closes #160.

14 S5906 — toHaveLength

All expect(X.length).toBe(N) replaced with expect(X).toHaveLength(N).
.toBeGreaterThan(0) replaced with .toBeGreaterThanOrEqual(1) (matching S5906).

Files: financeiro-client.test.tsx (2), WorkoutSession.test.tsx (2),
dashboard-nav.test.tsx (1), card-feedback.test.tsx (1),
workout-editor.test.tsx (1), columns.test.tsx (1),
circular-progress.test.tsx (1), exercise-options.test.ts (8),
nan-guards.test.ts (0 — none).

2 S5914 — toBeUndefined

nan-guards.test.ts:28: '.toBe(undefined)''.toBeUndefined()'.
Line 29 ('.toBe("")') is correct — not a smell.

Verification

  • npm run test: 1103/1103 pass
  • npm run typecheck: 0 errors

Summary by cubic

Fixes SonarQube smells in the test suite (S5906, S5914) to use idiomatic Jest matchers for clearer, more consistent assertions. No runtime behavior changes.

  • Refactors
    • Use toHaveLength(N) instead of expect(X.length).toBe(N) and replace > 0 checks with toBeGreaterThanOrEqual(1).
    • Use toBeUndefined() instead of toBe(undefined) in nan-guards.test.ts.
    • Applied across 9 test files; tests and typecheck pass.

Written for commit 9b781a6. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Updated several test assertions to use clearer length and undefined matchers.
    • Kept existing expectations the same while making checks more consistent across dashboard, workout, and UI test suites.
    • Relaxed a few length validations in the exercise options tests to allow single-item values where appropriate.

…+ toBeUndefined)

S5906: replace .length.toBe(N) with toHaveLength(N) across 9 test
files (financeiro-client, WorkoutSession, dashboard-nav,
card-feedback, workout-editor, columns, circular-progress,
exercise-options, nan-guards). Replace .toBeGreaterThan(0) with
.toBeGreaterThanOrEqual(1) for clarity.

S5914: replace .toBe(undefined) with .toBeUndefined() in
nan-guards.test.ts. Line 29 (.toBe('')) is correct — not a smell.

Closes #160.
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
smartmanagementsystem Ready Ready Preview, Comment Jul 4, 2026 1:51pm

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c841bbc3-e0a7-46e6-abe6-4d46e8a206e1

📥 Commits

Reviewing files that changed from the base of the PR and between 3afea6c and 9b781a6.

📒 Files selected for processing (9)
  • src/app/dashboard/financeiro/financeiro-client.test.tsx
  • src/app/dashboard/treinos/__tests__/nan-guards.test.ts
  • src/components/WorkoutSession.test.tsx
  • src/components/dashboard-nav.test.tsx
  • src/components/dashboard/aluno/card-feedback.test.tsx
  • src/components/dashboard/aluno/workout-editor.test.tsx
  • src/components/dashboard/alunos/columns.test.tsx
  • src/components/ui/circular-progress.test.tsx
  • src/lib/exercise-options.test.ts

Walkthrough

Test files across dashboard, workout, and library modules were updated to replace direct .length property comparisons with Vitest/Jest DOM's toHaveLength() matcher, and one assertion switched from toBe(undefined) to toBeUndefined(). The exercise-options test also loosened length > 0 checks to length >= 1.

Changes

Test Matcher Style Updates

Layer / File(s) Summary
Dashboard/component test assertions
src/app/dashboard/financeiro/financeiro-client.test.tsx, src/components/WorkoutSession.test.tsx, src/components/dashboard-nav.test.tsx, src/components/dashboard/aluno/card-feedback.test.tsx, src/components/dashboard/aluno/workout-editor.test.tsx, src/components/dashboard/alunos/columns.test.tsx, src/components/ui/circular-progress.test.tsx
Replaces .length equality checks with toHaveLength(n) matchers for badges, buttons, inputs, active nav buttons, skeletons, exercise rows, column definitions, and SVG circles.
NaN guards and exercise-options assertions
src/app/dashboard/treinos/__tests__/nan-guards.test.ts, src/lib/exercise-options.test.ts
Switches an `

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: fixing SonarQube test smells in test files.
Description check ✅ Passed The description covers the change, its scope, and verification, though it omits some optional template sections.
Linked Issues check ✅ Passed The changes directly address the 16 reported Sonar smells by updating the affected assertions, matching the issue's objective.
Out of Scope Changes check ✅ Passed All edits are focused on test assertion cleanup for the linked SonarQube smells, with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sonarqube-smells-160

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Re-trigger cubic

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@EmiyaKiritsugu3 EmiyaKiritsugu3 merged commit 176e125 into main Jul 4, 2026
14 checks passed
@EmiyaKiritsugu3 EmiyaKiritsugu3 deleted the fix/sonarqube-smells-160 branch July 4, 2026 17:38
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.

[P4] Resolver 16 code smells remanescentes do SonarQube

1 participant