Fix DoNotMockDataClass lint error: replace ThemeWithEditContext mock with real instance#22835
Merged
Fix DoNotMockDataClass lint error: replace ThemeWithEditContext mock with real instance#22835
Conversation
…sRepositoryTest The DoNotMockDataClass lint check flags mocking uniffi-generated data classes. Construct a real instance via a buildTheme() factory matching the pattern already used in ThemeRepositoryTest.
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
oguzkocer
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes a lint failure on
trunkintroduced by #22785:EditorSettingsRepositoryTest.mockThemeResponse()mocksuniffi.wp_api.ThemeWithEditContext(a uniffi-generated data class), tripping theDoNotMockDataClasslint rule.The test only reads
theme.isBlockTheme, so a real instance is straightforward.Summary
mock<ThemeWithEditContext>()with a real instance constructed via abuildTheme(stylesheet, isBlockTheme)factory.ThemeRepositoryTest.buildTheme.Why CI didn't catch this on #22785 — root cause
Stale base branch. The chain:
.buildkite/commands/lint.sh.trunkcommit predating Parallelize CI lint jobs and switch to Debug variant #22637 (git merge-baseof the PR head and Parallelize CI lint jobs and switch to Debug variant #22637's merge commit is61bd1edd6242— before Parallelize CI lint jobs and switch to Debug variant #22637 landed). The branch was never rebased.lint.sh, which executed./gradlew lintWordpressRelease. Confirmed via build 26166 logs: the only WordPress lint tasks that ran were:WordPress:lintAnalyzeWordpressReleaseand:WordPress:lintReportWordpressRelease. NolintAnalyzeWordpressReleaseUnitTesttask ran, because AGP's release-variant lint skips the unit test source set by default.DoNotMockDataClassviolation lives in a unit test file → never analyzed → CI passed.lint.sh→lintWordpressDebug→ analyzes unit test sources → catches the inherited violation. PR Skip repeat editor capability fetches in MySiteViewModel #22833 was the first PR branched from post-merge trunk (created 18 minutes after Add site settings for third-party blocks and theme style gating #22785 merged).(My initial guess was a Gradle build cache reuse issue. Logs ruled that out — the actual run was on Release variant from the stale script.)
Preventing the class of bug — separate ask
The right structural fix is to enable GitHub branch protection's "Require branches to be up to date before merging" on
trunk. After enabling, any PR with a stale base must rebase (or merge trunk in) before merging, which forces CI to re-run with the currentlint.sh— closing the entire stale-CI-script failure mode.Cost is real (rebase churn on busy days) but bounded; if a merge queue is in use it's effectively implicit.
I considered also flipping
lint { checkTestSources = true }inbuild.gradleso that trunk-side Release-variant lint covers test sources too. Verified locally: it surfaces 27 pre-existing test-source violations (mostly deliberate test patterns: passingnullto non-nullableLiveData, hardcoded resource ints in fixtures, etc.) that would need baseline reconciliation across all four lint variants. That's a separate, larger PR — branch protection alone covers the actual reported bug pattern.Drive-by note (not in this PR)
Lint output reports 13 unmatched baseline entries (
DoNotMockDataClass×8,DoNotMockSealedClass×5) — a baseline cleanup is overdue but out of scope here.Test plan
./gradlew :WordPress:lintWordpressDebug— passes./gradlew :WordPress:testWordpressDebugUnitTest --tests "org.wordpress.android.repositories.EditorSettingsRepositoryTest"— passeslint-wordpressandlint-jetpackgreentrunk