Repository navigation
chore(quality): add Konsist rules for MVI UI conventions - #11952
Open
BenjaminGROISNE wants to merge 4 commits into
Open
BenjaminGROISNE wants to merge 4 commits into
BenjaminGROISNE wants to merge 4 commits into
Conversation
Enforce the MVI conventions from docs/architecture/ui-architecture.md and the ui package layout from docs/architecture/module-structure.md: - ViewModels extend BaseViewModel or BaseStateMachineViewModel - contracts with a nested ViewModel declare State, Event and Effect, nested or as the type arguments of a shared MVI type - ViewModels and *Screen composables reside in ui packages - only *Screen composables, or entry points that inject their ViewModel with koinViewModel(), take a ViewModel Base classes are matched by fully qualified name, so the catalog's own BaseViewModel copy is not mistaken for the shared one. The 35 existing violations are baselined by path and name; the rules fail on new violations and on baseline entries that no longer match. Closes thunderbird#11857
Move ChangelogContract, ChangelogScreen, ChangelogViewModel and RecentChangesViewModel to net.thunderbird.feature.changelog.internal.ui, as described in docs/architecture/module-structure.md, and remove their entries from the MVI baseline.
Move the debug settings screen, its sections and their ViewModels and contracts to net.thunderbird.feature.debug.settings.ui, as described in docs/architecture/module-structure.md, and remove their entries from the MVI baseline. Navigation and dependency injection stay where they are.
Add RecentChangesContract and expose the recent changes hint as MVI state instead of LiveData. The message list fragments collect the state with flowWithLifecycle, so the hint is still only shown while the view is started, and send OnRecentChangesHintDismissed instead of calling the ViewModel directly. Remove the last changelog entry from the MVI baseline.
Contributor
|
Missing report label. Set exactly one of: |
This branch was successfully deployed
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.
Contribution Summary
Linked Issue/Ticket: Closes #11857
Description
Adds Konsist rules (
quality/konsist/.../ui/ValidateMviConventions.kt) for the conventions inui-architecture.mdandmodule-structure.md:BaseViewModelorBaseStateMachineViewModel(matched by fully qualified name).State,EventandEffect, nested or as the type arguments of a shared MVI type.*Screencomposables reside inuipackages.*Screencomposables, or entry points with akoinViewModel()default, take a ViewModel. This covers the case detekt'sViewModelForwardingmisses.Existing violations are baselined in
MviBaseline.kt. The rules also fail on stale entries, so the baseline can only shrink: 35 onmain, 28 after this PR.Fixes, one commit each:
uipackage.uipackage.RecentChangesViewModelfromLiveDatatoBaseViewModel. The message list fragments collect it with the existingFlow.observehelper, which now returns itsJob.Testing
:quality:konsist:testpasses on each commit. A temporary file with one violation per rule made each rule fail.RecentChangesViewModelTest(5 cases). Both apps'DependencyInjectionTestpass../gradlew test lint detekt spotlessCheckpasses, exceptImapServerSettingsValidatorTest, which fails the same way on a cleanmainlocally.AI Disclosure
Contribution Checklist
gradlew spotlessCheckto check andgradlew spotlessApplyto format your source code; will be checked by CI).gradlew testDebugUnitTest; will be checked by CI).🤖 Generated with Claude Code