Closed Bug 2091869 Opened 15 days ago Closed 13 days ago

Fix more code that Kotlin 2.5 warns about

Categories

(Firefox for Android :: General, task)

All
Android
task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: RyanVM, Assigned: RyanVM)

Details

Attachments

(5 external files)

Found while testing Kotlin 2.5.0-RC: its return value checker flags ignored results of Kotlin standard library calls, which fails our -Werror Android builds. All of the affected code is valid on the current Kotlin 2.4.21, so it can be fixed ahead of the Kotlin update.

Several of the flagged calls were checks that never took effect. SearchEngineWriterTest and MarsSpocsEndpointRawTest computed contains() results without asserting them, and the SearchEngineWriterTest expectation turns out to be wrong. BundleTest called Array.plus(), which returns a new array, so its "expected and unexpected elements" cases never contained an unexpected element. The Fenix BrowserToolbarMiddlewareTest helper called asReversed() without using the result, so it never modeled the reversed tab counter menu of the bottom toolbar.

The Bugbug bot thinks this bug should belong to the 'Firefox for Android::Toolbar' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Toolbar
Component: Toolbar → General

Kotlin 2.5 warns when a call relies on a default parameter value whose type is missing from the classpath:
createTab in the feature-listentopage tests, and the dataprotect and firefox-relay samples.

Discarded results of collection transforms and nullable-Unit lambdas become forEach calls or plain Unit types,
test checks whose result was dropped become assertions, and Mockito stubbing/verification calls suppress
RETURN_VALUE_NOT_USED. SearchEngineWriterTest now matches the result URLs the writer actually emits.

The toolbar test helper now reverses the tab counter menu for the bottom toolbar like production does. The
onboarding spacers are now emitted only on non-small layouts, as their ignored takeIf intended; nothing
changes visually, since the small-layout pager already fills the column.

Pushed by rvandermeulen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b0255bea113d https://hg.mozilla.org/integration/autoland/rev/8a381f5bbb71 Avoid unused return values flagged by Kotlin 2.5 in GeckoView tests. r=android-reviewers,mcarare https://github.com/mozilla-firefox/firefox/commit/0dda077b856c https://hg.mozilla.org/integration/autoland/rev/1d835d97f41d Add missing dependencies that Kotlin 2.5 needs for default parameter types in android-components. r=android-build-system-reviewers,ahochheiden,android-reviewers,mcarare https://github.com/mozilla-firefox/firefox/commit/a3e3bc6e2a03 https://hg.mozilla.org/integration/autoland/rev/9a4b1d7d8490 Avoid unused return values flagged by Kotlin 2.5 in android-components. r=android-reviewers,mcarare https://github.com/mozilla-firefox/firefox/commit/72019fc86151 https://hg.mozilla.org/integration/autoland/rev/07b40d30d922 Avoid unused return values flagged by Kotlin 2.5 in Fenix. r=android-reviewers,mobiletest-reviewers,aaronmt,mcarare https://github.com/mozilla-firefox/firefox/commit/98e526109ac5 https://hg.mozilla.org/integration/autoland/rev/6f36b1092e49 Avoid unused return values flagged by Kotlin 2.5 in Focus. r=android-reviewers,mobiletest-reviewers,aaronmt,mcarare
Pushed by rvandermeulen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/81ab73f807b9 https://hg.mozilla.org/integration/autoland/rev/8e9281852055 Suppress the new CognitiveComplexMethod detekt warning incidentally triggered by this patch. r=mcarare
Pushed by rvandermeulen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/48bcce5ab5ab https://hg.mozilla.org/integration/autoland/rev/09c47e7480de Move the onboarding spacer conditions into a helper to satisfy CognitiveComplexMethod. r=mcarare
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: