Open Bug 2066962 Opened 2 months ago Updated 2 months ago

Remove duplicate widgets.stocks.size entry in PREFS_CONFIG

Categories

(Firefox :: New Tab Page, task)

task

Tracking

()

People

(Reporter: gharp, Unassigned, Mentored, NeedInfo)

References

Details

(Keywords: good-first-bug, Whiteboard: [hnt][hnt-wattle][lang=js])

PREFS_CONFIG in browser/extensions/newtab/lib/ActivityStream.sys.mjs contains the key "widgets.stocks.size" twice, at lines 1600 and 1614. The two entries are byte-identical (same title, same value: ""). One of them should be removed.

There is no behavior change: PREFS_CONFIG is a new Map([...]), so a duplicate key is deduplicated when the Map is constructed, and because both values are identical the result is the same either way. This is purely a tidiness fix.

Note that ESLint will not flag this and there is no lint failure to reproduce. The no-dupe-keys rule only applies to object literals, and these are array-of-array arguments to a Map constructor, which the rule does not inspect. That is why it went unnoticed.

Link to the code:
https://searchfox.org/mozilla-central/source/browser/extensions/newtab/lib/ActivityStream.sys.mjs#1600

Steps to fix:

  1. Open browser/extensions/newtab/lib/ActivityStream.sys.mjs
  2. Delete one of the two identical "widgets.stocks.size" entries. Removing the second one (lines 1613-1619) keeps the "widgets.stocks.size" and "widgets.pictureOfTheDay.size" entries adjacent, but either removal is correct.

To verify the fix:

grep -n '"widgets.stocks.size"' browser/extensions/newtab/lib/ActivityStream.sys.mjs

Exactly one occurrence should remain. Then run:

./mach lint browser/extensions/newtab/lib/ActivityStream.sys.mjs

This is a front-end-only change, so no compilation is required.

For background, the duplicate was introduced accidentally: bug 2049936 added the entry when scaffolding the Stocks widget, and bug 2050969 later re-added it while adding Picture of the Day boilerplate. A scan of every key in the PREFS_CONFIG map found this is the only duplicated key, so no other entries need changing.

Potential good first bug to learn workflows. Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html

Would love to work on this.

(In reply to Gabriel H [:gharp, :gabriel] from comment #0)

PREFS_CONFIG in browser/extensions/newtab/lib/ActivityStream.sys.mjs contains the key "widgets.stocks.size" twice, at lines 1600 and 1614. The two entries are byte-identical (same title, same value: ""). One of them should be removed.

There is no behavior change: PREFS_CONFIG is a new Map([...]), so a duplicate key is deduplicated when the Map is constructed, and because both values are identical the result is the same either way. This is purely a tidiness fix.

Note that ESLint will not flag this and there is no lint failure to reproduce. The no-dupe-keys rule only applies to object literals, and these are array-of-array arguments to a Map constructor, which the rule does not inspect. That is why it went unnoticed.

Link to the code:
https://searchfox.org/mozilla-central/source/browser/extensions/newtab/lib/ActivityStream.sys.mjs#1600

Steps to fix:

  1. Open browser/extensions/newtab/lib/ActivityStream.sys.mjs
  2. Delete one of the two identical "widgets.stocks.size" entries. Removing the second one (lines 1613-1619) keeps the "widgets.stocks.size" and "widgets.pictureOfTheDay.size" entries adjacent, but either removal is correct.

To verify the fix:

grep -n '"widgets.stocks.size"' browser/extensions/newtab/lib/ActivityStream.sys.mjs

Exactly one occurrence should remain. Then run:

./mach lint browser/extensions/newtab/lib/ActivityStream.sys.mjs

This is a front-end-only change, so no compilation is required.

For background, the duplicate was introduced accidentally: bug 2049936 added the entry when scaffolding the Stocks widget, and bug 2050969 later re-added it while adding Picture of the Day boilerplate. A scan of every key in the PREFS_CONFIG map found this is the only duplicated key, so no other entries need changing.

This got fixed with 16a6da2 it looks like.

Flags: needinfo?(gharp)
You need to log in before you can comment on or make changes to this bug.