Skip to content

Add three rules for connectivity events, memo inputs and reader guards - #5

Merged
long1dev merged 6 commits into
mainfrom
feat/more-rules
Nov 3, 2026
Merged

long1dev merged 6 commits into
mainfrom
feat/more-rules

Conversation

@long1dev

@long1dev long1dev commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Adds three warning rules for rules cb-mobile's CLAUDE.md states but nothing enforced.

  • connectivity_event_outside_app_epics: building OnConnectivityEvent (or ListenForConnectivity.event, a tear-off, or a subclass) outside app_epics.dart. A second writer of isConnected broke the offline banner before.
  • memo_input_is_collection_field: a Memo input that is a collection field of freezed state, which freezed wraps anew on every read so the memo never hits. Follows final locals, conditionals, !, as, and .keys/.values/.entries/.toList()/.toSet().
  • reader_call_after_ignore_no_connection: an operator or getter after a reader's .ignoreNoConnection(), which the guard does not cover. Only onNotFound and logBadResponses from the sync engine are allowed there.

Shared helpers move out of reader_without_ignore_no_connection, whose behaviour is unchanged. Both reader walkers now follow as casts and extension overrides.

Testing

  • ./check.sh passes: 122 tests in cb_lints, 62 in cb_checks, and the fixture draws every rule.
  • On cb-mobile main (ba2047460), from a root dart analyze with the plugin by path: 0 reports from each rule, and every case fires on a probe.
  • An independent review found no false positives or crashes. It found three ways a violation slipped past (a local alias of a memo input, a getter after the guard, a subclass of the event), all closed here.

Not included

memo_distinct_needs_identity_equality is on feat/memo-distinct-rule, held back: it reports three view models in cb-mobile that break CLAUDE.md's @Freezed(equal: false) rule (appointment_items.dart:37, invoice_payments_container.dart:36, selected_invoice_container.dart:48). It can follow once those are fixed.

ignoreNoConnection itself is still matched by name, as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2

long1dev and others added 6 commits November 4, 2026 00:26
connectivity_event_outside_app_epics reports a library under lib/ other than
lib/src/epics/app_epics.dart (and the action's own library) that builds
OnConnectivityEvent, through ListenForConnectivity.event, the class's own
constructor, a redirect to either, or a tear-off. AppEpics maps
ConnectivityService's stream to it, and a second writer of isConnected is what
once left the offline banner stuck after the first reconnect.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
memo_input_is_collection_field reports an element of a Memo call's input list
that reads a field off a @freezed object whose generated class computes it in a
getter, which freezed does only to wrap a collection in a new unmodifiable
view. Such an input is never identical to last time, so the memo never hits.
Stored fields (scalars, nested state, collections kept as is) and hand-written
getters do not report, and only the app's own Memo counts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
reader_call_after_ignore_no_connection reports, in a yield* of a SyncEngine
reader, the operator nearest the last ignoreNoConnection() that follows it,
unless it is the sync engine's onNotFound or logBadResponses. The guard cannot
see a connection error raised after it, so
`local.ignoreNoConnection().asyncMap((_) => api.get(id))` fails offline while
reader_without_ignore_no_connection is satisfied. It allows what is known to be
safe rather than looking for API calls, since a call can reach the network
without naming an API.

The reader and sync-engine checks move to shared helpers, unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
A subclass builds the event through its super constructor, and creating it
passed connectivity_event_outside_app_epics. The rule now also reports a
supertype that is OnConnectivityEvent or a subtype of it, in an extends,
implements, with or on clause or a class alias, under the same exemptions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
reader_call_after_ignore_no_connection walked past a getter chained after
ignoreNoConnection() without judging it; a getter runs code too, and none is
allowed, so it now reports. Both reader walkers now follow a chain through
`as` casts and extension overrides, so a cast guard is not mistaken for no
guard and `Ext(stream).ignoreNoConnection()` counts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
memo_input_is_collection_field saw only a field read written straight into
the input list. It now also follows an input through a final local initialized
with it, either branch of a conditional, a `!`, a cast, and `.keys`, `.values`,
`.entries`, `.toList()` or `.toSet()` on such a field, and an inputs list held
in a final local. A non-final local is not followed, as it could hold another
value by the call. The report sits on the input as written in the list.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UESkdYVqQ7NhmMmMfG7ov2
@long1dev
long1dev merged commit 57c4499 into main Nov 3, 2026
2 checks passed
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.

1 participant