Use lint unreachable_from_main to avoid dead code (#4244)
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 29602e0..eb52b1d 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -46,4 +46,5 @@
- unnecessary_library_directive
- unnecessary_parenthesis
- unnecessary_statements
+ - unreachable_from_main
- use_enums
diff --git a/test/ascii_tree_test.dart b/test/ascii_tree_test.dart
index 018875b..c5c186f 100644
--- a/test/ascii_tree_test.dart
+++ b/test/ascii_tree_test.dart
@@ -12,11 +12,6 @@
import 'golden_file.dart';
import 'test_pub.dart';
-/// Removes ansi color codes from [s].
-String stripColors(String s) {
- return s.replaceAll(RegExp('\u001b\\[.*?m'), '');
-}
-
void main() {
setUp(() {
forceColors = ForceColorOption.always;
diff --git a/test/golden_file.dart b/test/golden_file.dart
index 82024cb..21d126c 100644
--- a/test/golden_file.dart
+++ b/test/golden_file.dart
@@ -11,7 +11,6 @@
import 'package:stack_trace/stack_trace.dart' show Trace;
import 'package:test/test.dart';
-import 'ascii_tree_test.dart';
import 'descriptor.dart' as d;
import 'test_pub.dart';
@@ -176,6 +175,11 @@
_expectSection(sectionIndex, s.toString());
}
+ /// Removes ansi color codes from [s].
+ String _stripColors(String s) {
+ return s.replaceAll(RegExp('\u001b\\[.*?m'), '');
+ }
+
/// Log directory tree structure under [directory] to golden file.
Future<void> tree([String? directory]) async {
// Create new section index number (before doing anything async)
@@ -194,7 +198,7 @@
baseDir: target,
showFileSizes: false,
);
- s.writeln(colors ? tree : stripColors(tree));
+ s.writeln(colors ? tree : _stripColors(tree));
_expectSection(sectionIndex, s.toString());
}
diff --git a/test/validator/file_case_test.dart b/test/validator/file_case_test.dart
index fd43eb3..cc98a32 100644
--- a/test/validator/file_case_test.dart
+++ b/test/validator/file_case_test.dart
@@ -24,8 +24,6 @@
);
}
-late d.DirectoryDescriptor fakeFlutterRoot;
-
void main() {
test('Recognizes files that only differ in capitalization.', () async {
await d.validPackage().create();
diff --git a/tool/test-bin/pub_command_runner.dart b/tool/test-bin/pub_command_runner.dart
index 186d905..47dffd5 100644
--- a/tool/test-bin/pub_command_runner.dart
+++ b/tool/test-bin/pub_command_runner.dart
@@ -23,8 +23,6 @@
@override
String get description => 'Throws an exception';
- bool get hide => true;
-
@override
Future<int> runProtected() async {
throw StateError('Pub has crashed');