Skip to content

Submit Assignment#6

Open
CHARITH GAYASHAN (charithgaya) wants to merge 12 commits into
codezelaca:mainfrom
charithgaya:main
Open

Submit Assignment#6
CHARITH GAYASHAN (charithgaya) wants to merge 12 commits into
codezelaca:mainfrom
charithgaya:main

Conversation

@charithgaya
Copy link
Copy Markdown

@charithgaya CHARITH GAYASHAN (charithgaya) commented May 11, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed form submission and checklist data persistence
    • Corrected validation logic for adding new items
    • Improved search and filtering accuracy for status and content matching
    • Fixed metrics calculations for completed items and due-soon thresholds
    • Resolved delete and status update functionality
    • Enhanced date calculations to eliminate timezone-related skew
    • Corrected CSV export functionality
    • Fixed demo reset to load correct reference data

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

@charithgaya has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 45 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eca39405-66d8-4646-b9cf-9f9e8a31522a

📥 Commits

Reviewing files that changed from the base of the PR and between ae59a92 and 21e699d.

📒 Files selected for processing (1)
  • js/app.js
📝 Walkthrough

Walkthrough

js/app.js corrects twelve bugs across data persistence, form validation, filtering, rendering, metrics calculation, event handling, and date math. Storage keys now align, form submission calls the correct handler, validation requires both fields, filtering matches correct properties, metrics use correct status values and date ranges, event handlers read proper dataset attributes, and utility functions normalize dates properly.

Changes

Checklist Application Corrections

Layer / File(s) Summary
Storage & Form Input
js/app.js
Storage key definition aligns load/save; form submit handler calls handleAddCheck; validation blocks submission if title or category is missing; loadChecks() reads from corrected localStorage key.
Display & Filtering
js/app.js
Status values generate slugified CSS classes for spaces (e.g., "In Progress" → in-progress); filter logic matches status against check.status and search term covers multiple fields.
Metrics & Event Handlers
js/app.js
Metrics count "Fixed" items using check.status === "Fixed" and "due soon" as items due within 7 days (inclusive); delete handler reads data-remove-id dataset attribute; status update handler persists, re-filters, and refreshes metrics.
Data Operations & Utilities
js/app.js
Demo reset fetches data/launch-checks.json; CSV export uses check.title instead of invalid property; daysUntil() normalizes both dates to midnight to prevent time-of-day skew.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A checklist app once lost its way,
With keys mismatched and checks astray,
But now the filters search just right,
The metrics glow, the dates take flight—
Our little app works day and night! 🐰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Submit Assignment' is vague and generic, providing no meaningful information about the actual changes (bug fixes in a checklist application). Consider using a more descriptive title that reflects the primary changes, such as 'Fix checklist app bugs: storage, validation, filtering, metrics, and exports' or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Copy Markdown

@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: 1

🧹 Nitpick comments (3)
js/app.js (3)

113-118: 💤 Low value

Optional: guard against non-array parsed values.

JSON.parse(saved) could legitimately return null, an object, or a primitive if storage was tampered with or written by an older schema. Subsequent checks.unshift(...)/.filter(...) would then throw. A quick Array.isArray check keeps the app resilient:

🛡️ Suggested guard
   try {
-    return JSON.parse(saved);
+    const parsed = JSON.parse(saved);
+    return Array.isArray(parsed) ? parsed : [...demoChecks];
   } catch (error) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/app.js` around lines 113 - 118, The JSON.parse(saved) return value can be
non-array (null/object/primitive) and later calls like checks.unshift(...) or
.filter(...) will throw; change the try block to parse into a variable (e.g.,
const parsed = JSON.parse(saved)) and return parsed only if
Array.isArray(parsed), otherwise return [...demoChecks]; reference the existing
JSON.parse(saved) call and demoChecks and ensure callers expecting an array
(e.g., checks.unshift/filter) always receive an array.

286-292: ⚡ Quick win

Redundant render/metric calls after applyFilters.

applyFilters() already invokes renderApp() which calls both renderRows(currentView) and updateMetrics(). The explicit renderRows(currentView) on Line 287 and updateMetrics() on Line 291 are duplicate work — renderRows runs twice per status change, briefly causing the row's <select> to re-render and lose focus before being replaced again.

♻️ Suggested cleanup
   check.status = statusSelect.value;
-  renderRows(currentView);
-  logActivity(`Changed "${check.title}" to ${check.status}.`);
   saveChecks();
   applyFilters();
-  updateMetrics();
-  // Fixed:Intentional bug: status changes should save, update filters, and refresh metrics.
+  logActivity(`Changed "${check.title}" to ${check.status}.`);

Note: once the row re-renders, if the new status no longer matches statusFilter, the row will disappear from the view. That's likely the desired behavior, but worth confirming with your UX expectation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/app.js` around lines 286 - 292, The change handler is calling
renderRows(currentView) and updateMetrics() redundantly because applyFilters()
already calls renderApp(), which in turn runs renderRows(...) and
updateMetrics(); remove the duplicate calls — delete the explicit
renderRows(currentView) and updateMetrics() lines in the status-change block
(leave check.status = ..., logActivity(...), saveChecks(), applyFilters()) so
the view and metrics are refreshed exactly once via applyFilters()/renderApp().

197-198: 💤 Low value

Minor: prefer replaceAll for slug generation.

String.prototype.replace with a string pattern only replaces the first occurrence. It works for the current status set (only "In Progress" has whitespace), but if a future status like "On Hold Pending" is added the class becomes status-on-hold pending. Aligning with the replaceAll usage already in escapeHtml makes this future-proof.

♻️ Suggested change
-    const statusClass = `status-${check.status.toLowerCase().replace(" ", "-")}`; // Fixed:Intentional bug: "In Progress" needs a slug class.
+    const statusClass = `status-${check.status.toLowerCase().replaceAll(" ", "-")}`; // Fixed:Intentional bug: "In Progress" needs a slug class.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/app.js` around lines 197 - 198, The status CSS class uses
String.prototype.replace which only replaces the first space; update the
statusClass assignment to use replaceAll to slugify all spaces from check.status
(for example: const statusClass =
`status-${check.status.toLowerCase().replaceAll(" ", "-")}`) so multi-word
statuses like "On Hold Pending" become a proper slug; modify the expression
where statusClass is defined to use replaceAll on check.status.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@js/app.js`:
- Around line 361-370: The daysUntil function currently does new Date(dateValue)
which interprets "YYYY-MM-DD" as UTC and then setHours(0,0,0,0) can shift the
day in negative UTC offsets; change daysUntil to parse the date string into
numeric year, month, day and construct a local-midnight Date via new Date(year,
month-1, day) (so you get local midnight of the intended day) and replace
Math.ceil(difference / 86400000) with Math.round(...) to avoid DST off-by-one;
apply the same explicit-parsing approach to formatDate to ensure consistency
when displaying dueDate.

---

Nitpick comments:
In `@js/app.js`:
- Around line 113-118: The JSON.parse(saved) return value can be non-array
(null/object/primitive) and later calls like checks.unshift(...) or .filter(...)
will throw; change the try block to parse into a variable (e.g., const parsed =
JSON.parse(saved)) and return parsed only if Array.isArray(parsed), otherwise
return [...demoChecks]; reference the existing JSON.parse(saved) call and
demoChecks and ensure callers expecting an array (e.g., checks.unshift/filter)
always receive an array.
- Around line 286-292: The change handler is calling renderRows(currentView) and
updateMetrics() redundantly because applyFilters() already calls renderApp(),
which in turn runs renderRows(...) and updateMetrics(); remove the duplicate
calls — delete the explicit renderRows(currentView) and updateMetrics() lines in
the status-change block (leave check.status = ..., logActivity(...),
saveChecks(), applyFilters()) so the view and metrics are refreshed exactly once
via applyFilters()/renderApp().
- Around line 197-198: The status CSS class uses String.prototype.replace which
only replaces the first space; update the statusClass assignment to use
replaceAll to slugify all spaces from check.status (for example: const
statusClass = `status-${check.status.toLowerCase().replaceAll(" ", "-")}`) so
multi-word statuses like "On Hold Pending" become a proper slug; modify the
expression where statusClass is defined to use replaceAll on check.status.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ccb83c85-e39d-45e9-8d57-c7dd1d529ce7

📥 Commits

Reviewing files that changed from the base of the PR and between ccb0d19 and ae59a92.

⛔ Files ignored due to path filters (2)
  • launchdesk-checks (1).csv is excluded by !**/*.csv
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • js/app.js

Comment thread js/app.js
Comment on lines 361 to 370
function daysUntil(dateValue) {
const today = new Date();
today.setHours(0, 0, 0, 0);

const target = new Date(dateValue);
target.setHours(0, 0, 0, 0);

const difference = target.getTime() - today.getTime();
return Math.ceil(difference / 86400000);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Timezone parsing can shift dueDate by one day in negative UTC offsets.

new Date("YYYY-MM-DD") parses the string as UTC midnight per the ECMAScript spec, then setHours(0,0,0,0) snaps it to local midnight of whatever local date that UTC instant falls in. For users west of UTC (e.g. Pacific/Honolulu, UTC−10), new Date("2026-05-04") becomes 2026-05-03 14:00 locally, and setHours(0,0,0,0) collapses it to 2026-05-03 — a day earlier than intended. daysUntil (and formatDate) will then be off by one.

Parsing the components explicitly avoids the UTC interpretation:

🛠️ Suggested fix
 function daysUntil(dateValue) {
   const today = new Date();
   today.setHours(0, 0, 0, 0);
 
-  const target = new Date(dateValue);
-  target.setHours(0, 0, 0, 0);
-  
+  const [y, m, d] = String(dateValue).split("-").map(Number);
+  const target = new Date(y, m - 1, d);
+
   const difference = target.getTime() - today.getTime();
   return Math.ceil(difference / 86400000);
 }

Consider the same treatment inside formatDate.

Also note: across DST transitions the millisecond delta is 23h or 25h, so Math.ceil can round up an extra day. Using Math.round is more forgiving here since both endpoints are already snapped to midnight.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function daysUntil(dateValue) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const target = new Date(dateValue);
target.setHours(0, 0, 0, 0);
const difference = target.getTime() - today.getTime();
return Math.ceil(difference / 86400000);
}
function daysUntil(dateValue) {
const today = new Date();
today.setHours(0, 0, 0, 0);
const [y, m, d] = String(dateValue).split("-").map(Number);
const target = new Date(y, m - 1, d);
const difference = target.getTime() - today.getTime();
return Math.ceil(difference / 86400000);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/app.js` around lines 361 - 370, The daysUntil function currently does new
Date(dateValue) which interprets "YYYY-MM-DD" as UTC and then setHours(0,0,0,0)
can shift the day in negative UTC offsets; change daysUntil to parse the date
string into numeric year, month, day and construct a local-midnight Date via new
Date(year, month-1, day) (so you get local midnight of the intended day) and
replace Math.ceil(difference / 86400000) with Math.round(...) to avoid DST
off-by-one; apply the same explicit-parsing approach to formatDate to ensure
consistency when displaying dueDate.

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.

1 participant