Skip to content

Conversation

@asifrazadev
Copy link

@asifrazadev asifrazadev commented Jan 29, 2026

Proposed change

Resolves #3557

Summary
Fixed multiple SonarQube code quality issues to improve accessibility, code maintainability, and testing practices.
Changes Made

Accessibility improvement: Replaced role="status" with role="output" to ensure better accessibility across all devices
Array initialization: Updated array creation to use the new Array() constructor instead of array literal syntax where applicable
React key prop: Removed usage of array index as React keys to prevent potential rendering issues
Test updates: Updated tests to reflect the above changes and ensure proper coverage

Checklist

  • [x ] Required: I followed the contributing workflow
  • [x ] Required: I verified that my code works as intended and resolves the issue as described
  • [x ] Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

This PR addresses a Sonar accessibility issue by replacing <div> elements with <output> semantic HTML elements in skeleton components and updating corresponding test selectors from data-testid to role-based queries. Additionally, key generation for list items is improved from numeric indices to string-based keys.

Changes

Cohort / File(s) Summary
Skeleton Components
frontend/src/components/skeletons/Card.tsx, frontend/src/components/skeletons/UserCard.tsx
Replaced outer <div> wrappers with <output> elements; added ARIA attributes (aria-live="polite", aria-busy="true", aria-label="Loading"). In Card.tsx, key generation updated from numeric indices to string-based keys for icon and contributor sections.
Test Selectors
frontend/__tests__/unit/pages/Chapters.test.tsx, frontend/__tests__/unit/pages/Projects.test.tsx, frontend/__tests__/unit/pages/Users.test.tsx
Updated test selectors to use role-based queries (queryByRole('status'), getByRole('status')) instead of data-testid-based selectors (queryByTestId('status'), getByTestId('status')) for loading state assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: replacing the 'status' role with and addressing array key issues in React components.
Linked Issues check ✅ Passed The PR successfully addresses the linked issue #3557 by replacing role='status' with elements in Card.tsx and UserCard.tsx, and updating related tests to use role-based selectors.
Out of Scope Changes check ✅ Passed All changes are within scope: component restructuring uses , test selectors updated to match, and React key generation improved—all directly addressing the Sonar issues in #3557.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly articulates the changes made to address SonarQube code quality issues, including accessibility improvements, array initialization updates, React key prop fixes, and test updates. The description is directly related to the changeset and provides adequate context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@frontend/src/components/skeletons/Card.tsx`:
- Around line 19-21: In the Card skeleton component, the JSX currently uses an
<output> element to wrap block-level children (the element with className "flex
w-full justify-center" that contains the inner div with className "border-border
bg-card ..."); replace that outer <output> with a semantic <div> to ensure the
wrapper accepts block-level children and keeps the same className and behavior,
leaving the inner card div and its className unchanged.
- Around line 36-38: The render uses new
Array(numIcons).fill(...).map(...).map(...) which can throw RangeError for
negative or non-integer props; update the Card component to first sanitize
numIcons (e.g., coerce via Math.max(0, Math.floor(Number(numIcons) || 0)) or
default to 0) then emit the icons in a single pass using a safe array factory
(e.g., Array.from({ length: sanitizedNum }, (_, i) => <Skeleton
key={`icon-${i}`} .../>)); leave the local constant NUM_CONTRIBUTORS (always 8)
alone and apply the same single-pass pattern there if desired. Ensure keys use
the index-based `icon-${i}` and that Skeleton receives the same className.

In `@frontend/src/components/skeletons/UserCard.tsx`:
- Around line 11-13: The component is using an <output> element as the main
container (see UserCard component and the opening <output> at the top and its
closing tag near line 31); replace that outer <output> with a semantic block
container such as <div> to allow block-level children and valid HTML, and if you
still need an <output> for status/aria updates add a visually-hidden <output>
inside the container (or use an aria-live region) rather than using <output> as
the wrapper so markup and accessibility are correct.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 29, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 29, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
frontend/__tests__/unit/pages/Chapters.test.tsx (1)

106-118: Inconsistent test ID in the no-skeleton assertion.

queryByTestId('status') at Line 117 checks for a test ID that never existed—the original code used role="status", not data-testid="status". This assertion passes trivially and doesn't verify skeletons are gone. Update it to match the pattern used in Committees.test.tsx:

Proposed fix
-    expect(screen.queryByTestId('status')).not.toBeInTheDocument()
+    expect(screen.queryByTestId('card-skeleton')).not.toBeInTheDocument()
frontend/__tests__/unit/pages/Users.test.tsx (1)

59-74: Inconsistent test ID in the no-skeleton assertion.

Line 73 uses queryByTestId('status') which never existed as a test ID. Update to verify user card skeletons are removed after data loads:

Proposed fix
-    expect(screen.queryByTestId('status')).not.toBeInTheDocument()
+    expect(screen.queryByTestId('user-card-skeleton')).not.toBeInTheDocument()
frontend/__tests__/unit/pages/Projects.test.tsx (1)

72-84: Inconsistent test ID in the no-skeleton assertion.

Line 83 uses queryByTestId('status') which never existed as a test ID. Update to verify skeletons are removed:

Proposed fix
-    expect(screen.queryByTestId('status')).not.toBeInTheDocument()
+    expect(screen.queryByTestId('card-skeleton')).not.toBeInTheDocument()

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 29, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 29, 2026
@asifrazadev
Copy link
Author

@kasya @arkid15r can you run test i ran test but e2e test are failing all (if possible)

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@asifrazadev hi! Left some comments. ⬇️
Please resolve conflicts and run make check-test . It is required as it says on the PR template.

Image

{showLevel && <Skeleton className="h-10 w-10 rounded-full" />}
<div className="flex flex-col gap-1">
{showProjectName && <Skeleton className="h-8 w-[180px] sm:w-[250px]" />}
<div data-testid="card-skeleton" className="flex w-full justify-center">
Copy link
Collaborator

Choose a reason for hiding this comment

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

@asifrazadev do not add data-testid to actual code - this needs to be in the test.

aria-live="polite"
aria-busy="true"
aria-label="Loading"
data-testid="user-card-skeleton"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@asifrazadev same for this, but also - I'm pretty sure the issue was about something else (switch from div to output) and that is not addressed here.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 7 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="frontend/src/components/skeletons/Card.tsx">

<violation number="1" location="frontend/src/components/skeletons/Card.tsx:20">
P2: <output> elements can only contain phrasing content, but this output wraps block-level `<div>` content. This makes the HTML invalid and can confuse assistive tech. Use a `<div>` (or another flow container) for the status region instead of `<output>`.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 3, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 3, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Copy link
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 7 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="frontend/src/components/skeletons/UserCard.tsx">

<violation number="1" location="frontend/src/components/skeletons/UserCard.tsx:12">
P2: The <output> element only permits phrasing content, but it now wraps block-level <div> layout. This results in invalid HTML and can interfere with accessibility semantics for the live region. Consider moving the live-region <output> to a phrasing-only element (e.g., a visually hidden status text) and keep the layout container as a <div>.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@asifrazadev asifrazadev requested a review from kasya February 3, 2026 11:42
@asifrazadev asifrazadev marked this pull request as draft February 3, 2026 12:52
@asifrazadev asifrazadev closed this Feb 3, 2026
@asifrazadev asifrazadev deleted the Fix-sonar-Issues branch February 3, 2026 12:53
@asifrazadev
Copy link
Author

asifrazadev commented Feb 3, 2026

@kasya i am sorry i am working on this but i dont know where i am making mistake i am stuck between 2 issue if

@coderabbitai
coderabbitai bot
5 days ago

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain
cannot wrap block-level children

The element's content model is limited to phrasing content per the HTML specification, so wrapping block-level

elements violates the standard. The current structure at lines 19–85 uses as a layout wrapper, which produces invalid HTML.

Consider replacing the wrapper with a

for layout:

and

and current sonar issue

if nayone else wan you can re assign

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix sonar Issue : Use <output> instead of the "status" role to ensure accessibility across all devices.

2 participants