Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 75d8762

Browse files
committed
chore: report known lint issues
1 parent 5618062 commit 75d8762

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class _MyState extends State {
2+
void awaitEmptyFuture() async {
3+
await Future<void>.value();
4+
setState(() {}); // LINT
5+
}
6+
}
7+
8+
class State {}

test/src/analyzers/lint_analyzer/rules/rules_list/use_setstate_synchronously/use_setstate_synchronously_rule_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:test/test.dart';
55
import '../../../../../helpers/rule_test_helper.dart';
66

77
const _examplePath = 'use_setstate_synchronously/examples/example.dart';
8+
const _issuesPath = 'use_setstate_synchronously/examples/known_errors.dart';
89

910
void main() {
1011
group('UseSetStateSynchronouslyTest', () {
@@ -51,5 +52,20 @@ void main() {
5152
],
5253
);
5354
});
55+
56+
test('reports known issues', () async {
57+
final unit = await RuleTestHelper.resolveFromFile(_issuesPath);
58+
final issues = UseSetStateSynchronouslyRule().check(unit);
59+
60+
RuleTestHelper.verifyIssues(
61+
issues: issues,
62+
startLines: [4],
63+
startColumns: [5],
64+
locationTexts: ['setState'],
65+
messages: [
66+
"Avoid calling 'setState' past an await point without checking if the widget is mounted.",
67+
],
68+
);
69+
});
5470
});
5571
}

0 commit comments

Comments
 (0)