Skip to content

Commit 6c56bb2

Browse files
authored
Update typedef syntax to use Function notation and turn on lint for old notation. (flutter#18362)
Now that Dart 1 is turned off, reapplying my change to turn on the prefer_generic_function_type_aliases analysis option, and fix all the typedefs to Dart 2 preferred syntax. Also eliminated the unused analysis_options_repo.yaml file and turned on public_member_api_docs in analysys_options.yaml. No logic changes, just changing the typedef syntax for all typedefs, and updating analysis options.
1 parent 3019ad9 commit 6c56bb2

File tree

130 files changed

+216
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+216
-371
lines changed

analysis_options.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
# See the configuration guide for more
88
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
99
#
10-
# There are four similar analysis options files in the flutter repos:
10+
# There are four similar analysis options files in the flutter repo:
1111
# - analysis_options.yaml (this file)
1212
# - packages/flutter/lib/analysis_options_user.yaml
1313
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
1414
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
1515
#
16-
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
17-
# Android Studio, and the `flutter analyze` command.
16+
# This file contains the analysis options used by Flutter tools, such as
17+
# IntelliJ, Android Studio, and the 'flutter analyze' command.
1818
#
19-
# The flutter/plugins repo contains a copy of this file, which should be kept
20-
# in sync with this file.
19+
# The flutter/plugins and flutter/engine repos contain a copy of this file,
20+
# which should be kept in sync with this file.
2121

2222
analyzer:
2323
language:
@@ -124,13 +124,15 @@ linter:
124124
- prefer_final_locals
125125
- prefer_foreach
126126
# - prefer_function_declarations_over_variables # not yet tested
127+
- prefer_generic_function_type_aliases
127128
- prefer_initializing_formals
128129
# - prefer_interpolation_to_compose_strings # not yet tested
129130
# - prefer_iterable_whereType # https://github.com/dart-lang/sdk/issues/32463
130131
- prefer_is_empty
131132
- prefer_is_not_empty
132133
- prefer_single_quotes
133134
- prefer_typing_uninitialized_variables
135+
- public_member_api_docs
134136
- recursive_getters
135137
- slash_for_doc_comments
136138
- sort_constructors_first

analysis_options_repo.yaml

Lines changed: 0 additions & 157 deletions
This file was deleted.

dev/bots/prepare_package.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class ProcessRunner {
175175
}
176176
}
177177

178-
typedef Future<Uint8List> HttpReader(Uri url, {Map<String, String> headers});
178+
typedef HttpReader = Future<Uint8List> Function(Uri url, {Map<String, String> headers});
179179

180180
/// Creates a pre-populated Flutter archive from a git repo.
181181
class ArchiveCreator {

dev/bots/test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:io';
88

99
import 'package:path/path.dart' as path;
1010

11-
typedef Future<Null> ShardRunner();
11+
typedef ShardRunner = Future<Null> Function();
1212

1313
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
1414
final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');

dev/bots/test/fake_process_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class FakeProcess extends Mock implements Process {
150150
}
151151

152152
/// Callback used to receive stdin input when it occurs.
153-
typedef void StringReceivedCallback(String received);
153+
typedef StringReceivedCallback = void Function(String received);
154154

155155
/// A stream consumer class that consumes UTF8 strings as lists of ints.
156156
class StringStreamConsumer implements StreamConsumer<List<int>> {

dev/devicelab/lib/framework/framework.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const Duration _kDefaultTaskTimeout = const Duration(minutes: 15);
2020

2121
/// Represents a unit of work performed in the CI environment that can
2222
/// succeed, fail and be retried independently of others.
23-
typedef Future<TaskResult> TaskFunction();
23+
typedef TaskFunction = Future<TaskResult> Function();
2424

2525
bool _isTaskRegistered = false;
2626

dev/devicelab/lib/tasks/analysis.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const int _kRunsPerBenchmark = 3;
1515

1616
/// Runs a benchmark once and reports the result as a lower-is-better numeric
1717
/// value.
18-
typedef Future<double> _Benchmark();
18+
typedef _Benchmark = Future<double> Function();
1919

2020
/// Path to the generated "mega gallery" app.
2121
Directory get _megaGalleryDirectory => dir(path.join(Directory.systemTemp.path, 'mega_gallery'));

dev/devicelab/test/adb_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ CommandArgs cmd({
112112
);
113113
}
114114

115-
typedef dynamic ExitErrorFactory();
115+
typedef ExitErrorFactory = dynamic Function();
116116

117117
class CommandArgs {
118118
CommandArgs({ this.command, this.arguments, this.environment });

dev/integration_tests/channels/lib/src/test_step.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'pair.dart';
1111

1212
enum TestStatus { ok, pending, failed, complete }
1313

14-
typedef Future<TestStepResult> TestStep();
14+
typedef TestStep = Future<TestStepResult> Function();
1515

1616
const String nothing = '-';
1717

dev/integration_tests/platform_interaction/lib/src/test_step.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
88

99
enum TestStatus { ok, pending, failed, complete }
1010

11-
typedef Future<TestStepResult> TestStep();
11+
typedef TestStep = Future<TestStepResult> Function();
1212

1313
const String nothing = '-';
1414

0 commit comments

Comments
 (0)