A project with ChangeNotifier classes but no provider declarations printed: provider rules examined 10 ChangeNotifier class(es) (0 consumed by a Consumer/Selector), and 36 observable mutator(s) were checked for a notify path. Provider declarations by type: . That trailing "Provider declarations by type: ." is a dangling colon and full stop. It reads as a truncated sentence rather than as "this app declares none", which is how it surfaced on word_alive. The clause is now omitted when the list is empty, and still lists kinds most-common-first when it is not. Found by reading an external auditor's raw tool output after its run died on an API rate limit before it could write a report - its observations were still worth salvaging even though it never reached a conclusion. The note is extracted into providerRuleNote() so both branches are directly testable; before this the empty case was only reachable through a real project.
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
import 'package:pipe/pipe.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
test('omits the by-type clause when the app declares no providers', () {
|
|
// Before this was fixed, a project with notifiers but no provider
|
|
// declarations rendered `... notify path. Provider declarations by type: .`
|
|
// - a dangling colon and full stop that reads as a truncated sentence
|
|
// rather than as "this app declares none". Observed on word_alive.
|
|
final note = providerRuleNote(
|
|
notifiers: 10,
|
|
consumed: 0,
|
|
mutators: 36,
|
|
byKind: const {},
|
|
);
|
|
|
|
expect(note, isNot(contains('by type')));
|
|
expect(note, isNot(contains(': .')));
|
|
expect(note, endsWith('notify path.'));
|
|
});
|
|
|
|
test('lists declaration kinds, most common first, when there are some', () {
|
|
final note = providerRuleNote(
|
|
notifiers: 8,
|
|
consumed: 6,
|
|
mutators: 30,
|
|
byKind: const {'ChangeNotifierProvider': 6, 'Provider': 107},
|
|
);
|
|
|
|
expect(
|
|
note,
|
|
endsWith(
|
|
'Provider declarations by type: Provider 107, '
|
|
'ChangeNotifierProvider 6.',
|
|
),
|
|
);
|
|
});
|
|
}
|