Skip to content

refactor: move date picker style helpers to module scope - #131

Open
paodb wants to merge 1 commit into
masterfrom
refactor/move-style-helpers-to-module-scope
Open

paodb wants to merge 1 commit into
masterfrom
refactor/move-style-helpers-to-module-scope

Conversation

@paodb

@paodb paodb commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Move clearStyles and setStyleForDay out of _updateMonthStyles to module scope in fc-date-picker.js, as reported by Sonar (javascript:S7721). They now receive the calendar as a parameter instead of being invoked with .call.

Close #102

Summary by CodeRabbit

  • Refactor
    • Updated internal calendar styling code. No changes to date picker behavior or appearance are expected.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The date picker moves style-clearing and day-style callbacks to module-level helpers. _updateMonthStyles calls the helpers with the calendar element. Its style-fetching and month-check conditions remain unchanged.

Changes

Date picker style updates

Layer / File(s) Summary
Extract and use style helpers
src/main/resources/META-INF/frontend/fc-date-picker/fc-date-picker.js
Style-clearing and day-style callbacks are module-level helpers that receive the calendar element. _updateMonthStyles uses these helpers and retains its existing style-fetching and month-check conditions.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Refactor

Suggested reviewers: javier-godoy

Merge Risk: Minimal · up to 0815f

This is a behavior-preserving refactor of date picker style helpers that satisfies the Sonar rule. No user-facing change or merge risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states a refactor that moves the date picker style helpers (clearStyles and setStyleForDay) to module scope. The raw summary confirms that _updateMonthStyles now calls these module-level hel…
Linked Issues check Passed Issue #102 asks that the date-picker helpers in fc-date-picker.js move to the outer scope, so Sonar rule javascript:S7721 no longer flags them. The diff moves both helpers to module scope: `clearStyle…
Out of Scope Changes check Passed Every changed hunk in fc-date-picker.js supports the S7721 refactor. The two helpers move to module scope. The .call invocations become direct calls with the calendar argument. The local const dec…
Full details: Title check

Explanation

The title states a refactor that moves the date picker style helpers (clearStyles and setStyleForDay) to module scope. The raw summary confirms that _updateMonthStyles now calls these module-level helpers with the calendar element instead of using local callbacks invoked with this bound to the element. The PR objectives match this change, which addresses Sonar rule javascript:S7721 for issue #102. The title is specific, concise, and describes the main change.

Full details: Linked Issues check

Explanation

Issue #102 asks that the date-picker helpers in fc-date-picker.js move to the outer scope, so Sonar rule javascript:S7721 no longer flags them. The diff moves both helpers to module scope: clearStyles(calendar) and setStyleForDay(calendar, i, className) are now top-level functions. Each one takes the calendar as a parameter and reads calendar.shadowRoot, so they no longer depend on this. _updateMonthStyles calls them directly (clearStyles(element), setStyleForDay(element, i, styles[i])) instead of using .call. The selectors, class handling, and the fetch and apply conditions are unchanged. The issue names the helpers _clearStyles and _setStyleForDay. The PR drops the leading underscore. This naming difference does not affect the Sonar objective or behavior. No automated test is part of the coding requirement, and the issue asks for none.

Full details: Out of Scope Changes check

Explanation

Every changed hunk in fc-date-picker.js supports the S7721 refactor. The two helpers move to module scope. The .call invocations become direct calls with the calendar argument. The local const declarations of the helpers are removed. One unrelated-looking change is the let to const conversion inside the helper bodies. It is part of the same moved code and does not change behavior. No other files or unrelated logic changed. The diff reports +17/-17 lines.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cba8bded-9e42-490a-a8eb-ed5524c5acd8
Commits

Reviewing files that changed from the base of the PR and between 8de8ee6 and 0815f5b.

Files selected for processing: 1

  • src/main/resources/META-INF/frontend/fc-date-picker/fc-date-picker.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@sonarqubecloud

Copy link
Copy Markdown

@paodb
paodb marked this pull request as ready for review November 16, 2026 20:59
@paodb
paodb requested a review from scardanzan November 16, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

Javascript functions should be moved to the highest possible scope

1 participant