Skip to content

fix: add missing let/const declarations and strict mode to sync-leaderboard.js (#60)#125

Merged
jagdish-15 merged 1 commit into
codepvg:mainfrom
rishab11250:fix/missing-let-const-issue60
Jun 8, 2026
Merged

fix: add missing let/const declarations and strict mode to sync-leaderboard.js (#60)#125
jagdish-15 merged 1 commit into
codepvg:mainfrom
rishab11250:fix/missing-let-const-issue60

Conversation

@rishab11250
Copy link
Copy Markdown
Contributor

Description

Adds missing "use strict" directive and let declarations to variables in scripts/sync-leaderboard.js that were previously assigned without declaration, leaking to the global scope. Without strict mode, these implicit globals can cause silent data corruption (wrong scores, swapped rankings, duplicate entries) when the three parallel processing blocks (daily/weekly/monthly) share state — and no error is thrown.

Linked Issue

Fixes #60

Changes Made

  • Added "use strict"; at the top of the file — makes accidental global assignment an immediate runtime error instead of silent corruption
  • Added let to dailyData declaration (line 104)
  • Added let to previousData declaration (line 108)
  • Added let to weeklyData declaration (line 157)
  • Added let to monthlyData declaration (line 216)

Subsequent reassignments of previousData (lines 161, 220) remain as-is — let allows reassignment within the same function scope.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Verification performed:

  • node --check scripts/sync-leaderboard.js — Syntax OK
  • npx prettier --check "frontend/**/*.{html,css,js}" "scripts/**/*.js" "server.js" — All files pass

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally using Prettier
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

N/A — Backend-only change with no UI impact.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

A maintainer will review your submission shortly.

@jagdish-15 jagdish-15 added type:bug Something isn't working level:beginner Indicates the difficulty gssoc:approved quality:clean labels Jun 8, 2026
@jagdish-15 jagdish-15 merged commit 0a53e10 into codepvg:main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved level:beginner Indicates the difficulty quality:clean type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing let/const Declarations Create Implicit Globals Causing Silent Data Corruption

2 participants