Closed Bug 2065302 Opened 1 month ago Closed 27 days ago

Remove the unused _discarded field in UrlbarParentController.sys.mjs

Categories

(Firefox :: Address Bar, task, P3)

task

Tracking

()

RESOLVED FIXED
157 Branch
Tracking Status
firefox157 --- fixed

People

(Reporter: dao, Assigned: blessedonekobo, Mentored)

Details

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

Attachments

(1 file)

TelemetryEvent._discarded in browser/components/urlbar/UrlbarParentController.sys.mjs is written but never read, and should be removed.

There are exactly two references, both assignments:

  • in record(), inside the finally block: this._discarded = false;
  • in discard(): this._discarded = true;

Nothing reads the field, and it has no declaration either -- those two assignments are the only places it exists. Its last reader was removed in bug 1888905 (April 2024), which dropped the if (this._discarded && this._category && ...) check that used it.

The fix is to delete both assignment lines. Two things to leave alone: keep the if (this._startEventInfo) check that discard() wraps around its assignment, and don't touch _startEventInfo itself -- that one is very much in use. No other restructuring of either method is wanted.

Link to the code:
https://searchfox.org/firefox-main/source/browser/components/urlbar/UrlbarParentController.sys.mjs

Both references, which this search should stop returning once the patch is done:
https://searchfox.org/firefox-main/search?q=_discarded&path=browser%2Fcomponents%2Furlbar

To verify the fix:

./mach lint -l eslint browser/components/urlbar/UrlbarParentController.sys.mjs
./mach mochitest browser/components/urlbar/tests/browser-engagementTelemetry/

That mochitest directory is the engagement-telemetry suite, which exercises both record() and discard(). It should stay green: removing a field that nothing reads cannot change behavior.

Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html

Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.

Severity: -- → N/A
Priority: -- → P3

New contributor working on a patch for this bug

TelemetryEvent._discarded in browser/components/urlbar/UrlbarParentController.sys.mjs is written but never read

Assignee: nobody → blessedonekobo
Status: NEW → ASSIGNED
Pushed by dgottwald@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/60ff83ebc15d https://hg.mozilla.org/integration/autoland/rev/51928672ff32 Remove unused TelemetryEvent._discarded in UrlbarParentController.sys.mjs. r=urlbar-reviewers,dao
Status: ASSIGNED → RESOLVED
Closed: 27 days ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
QA Whiteboard: [search][qa-triage-done-c157/b156]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: