pipe/test/fixtures/stuck_loading/lib/provider_setup.dart
trvon 88ed85b43a
Some checks failed
Tests / Static Analysis (push) Has been cancelled
Tests / Tests (push) Has been cancelled
feat: add notifier-field-unread and provider-created-in-build, bound the brief header
Completes the provider/ChangeNotifier rule set:

- notifier-field-unread: a public getter on a notifier the UI consumes that
  nothing reads, so the state it exposes cannot reach the user. Once per
  notifier. nuwayze: 3 (UserProvider.isInitializing,
  AppLocaleProvider.preferredLocale, and _AgentHubController with 8 members).

- provider-created-in-build: a provider constructed in build without .value, so
  create reruns on every rebuild. Reported once per build method, not once per
  provider: nuwayze's AppProviders.build constructs 45 of them and that is one
  decision, not 45 bugs. Deliberately info, not warning, because a root
  StatelessWidget rarely rebuilds and static analysis cannot tell rebuild
  frequency apart.

Also fixes a real defect the budget test caught: the brief's 'by rule:' line
grew with the rule count and crowded out the findings it summarises. It is now
capped at the top 6 with a '+N more' suffix, the omission note is reserved for
up front so the artifact stays inside its budget, and the overflow message is
shorter.

75 tests. Verified the fixture with pipe's own resolver (0 errors) and validated
that check by injecting a type error into a copy (errors=1).
2026-09-20 17:59:54 -06:00

37 lines
943 B
Dart

import 'notifier.dart';
/// Minimal stand-ins for the `provider` package, so the fixture needs no
/// dependency.
class BuildContext {}
extension BuildContextX on BuildContext {
T read<T>() => throw UnimplementedError();
T watch<T>() => throw UnimplementedError();
}
class Provider<T> {
const Provider() : value = null;
const Provider.value({this.value});
final T? value;
static T of<T>(BuildContext context, {bool listen = true}) =>
throw UnimplementedError();
}
class ChangeNotifierProvider<T extends ChangeNotifier> {
const ChangeNotifierProvider({required this.create}) : value = null;
const ChangeNotifierProvider.value({required this.value}) : create = null;
final T Function(BuildContext context)? create;
final T? value;
}
/// An immutable service. Reading it without subscribing is correct, so a rule
/// that flags every `context.read` in build is wrong.
class AppConfig {
const AppConfig();
}