Skip to content

fix(bloc_lint): reset the @override flag between class members - #4864

Open
mysCod3r wants to merge 1 commit into
felangel:masterfrom
mysCod3r:fix/bloc-lint-override-flag-reset
Open

fix(bloc_lint): reset the @override flag between class members#4864
mysCod3r wants to merge 1 commit into
felangel:masterfrom
mysCod3r:fix/bloc-lint-override-flag-reset

Conversation

@mysCod3r

Copy link
Copy Markdown

Status

READY

Breaking Changes

NO

Description

avoid_public_bloc_methods and prefer_void_public_cubit_methods each keep an _isOverride flag that was only ever written from beginMetadata, which fires only for declarations that have an annotation. The flag was therefore never cleared, so an @override on one member exempted every member after it, and a member annotated with @override plus anything else was reported despite the exemption.

beginMetadataStar fires for every member before its metadata is read, so it is the point at which the flag can be cleared. beginMember is not usable for this, since it runs after the metadata and clearing there would drop a legitimate @override.

Both rules now clear the flag on beginMetadataStar and accumulate in beginMetadata instead of assigning, which fixes the false negative and the false positive respectively.

Three regression tests are included, one per defect plus the avoid_public_bloc_methods case. Each fails without the change and passes with it. The suite goes from 151 to 154 tests, and bloc_lint stays at 100% coverage.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

`_isOverride` was only written from `beginMetadata`, which fires only for
annotated declarations, so the flag was never cleared. An `@override` on one
member exempted every member after it, and a member carrying `@override` plus
a second annotation was reported despite the exemption.

Clear the flag on `beginMetadataStar`, which fires for every member before its
metadata, and accumulate in `beginMetadata` rather than assigning.

Closes felangel#4863
@mysCod3r
mysCod3r requested a review from felangel as a code owner August 15, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: _isOverride is never reset, so lint rules skip every member after an @override

1 participant