Skip to content

Commit

Permalink
Update typedef syntax to use Function notation and turn on lint for o…
Browse files Browse the repository at this point in the history
…ld 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.
  • Loading branch information
gspencergoog authored Jun 11, 2018
1 parent 3019ad9 commit 6c56bb2
Show file tree
Hide file tree
Showing 130 changed files with 216 additions and 371 deletions.
12 changes: 7 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
# There are four similar analysis options files in the flutter repos:
# There are four similar analysis options files in the flutter repo:
# - analysis_options.yaml (this file)
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
# This file contains the analysis options used by Flutter tools, such as
# IntelliJ, Android Studio, and the 'flutter analyze' command.
#
# The flutter/plugins repo contains a copy of this file, which should be kept
# in sync with this file.
# The flutter/plugins and flutter/engine repos contain a copy of this file,
# which should be kept in sync with this file.

analyzer:
language:
Expand Down Expand Up @@ -124,13 +124,15 @@ linter:
- prefer_final_locals
- prefer_foreach
# - prefer_function_declarations_over_variables # not yet tested
- prefer_generic_function_type_aliases
- prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
# - prefer_iterable_whereType # https://github.com/dart-lang/sdk/issues/32463
- prefer_is_empty
- prefer_is_not_empty
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- public_member_api_docs
- recursive_getters
- slash_for_doc_comments
- sort_constructors_first
Expand Down
157 changes: 0 additions & 157 deletions analysis_options_repo.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion dev/bots/prepare_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class ProcessRunner {
}
}

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

/// Creates a pre-populated Flutter archive from a git repo.
class ArchiveCreator {
Expand Down
2 changes: 1 addition & 1 deletion dev/bots/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:io';

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

typedef Future<Null> ShardRunner();
typedef ShardRunner = Future<Null> Function();

final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
Expand Down
2 changes: 1 addition & 1 deletion dev/bots/test/fake_process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class FakeProcess extends Mock implements Process {
}

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

/// A stream consumer class that consumes UTF8 strings as lists of ints.
class StringStreamConsumer implements StreamConsumer<List<int>> {
Expand Down
2 changes: 1 addition & 1 deletion dev/devicelab/lib/framework/framework.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Duration _kDefaultTaskTimeout = const Duration(minutes: 15);

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

bool _isTaskRegistered = false;

Expand Down
2 changes: 1 addition & 1 deletion dev/devicelab/lib/tasks/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const int _kRunsPerBenchmark = 3;

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

/// Path to the generated "mega gallery" app.
Directory get _megaGalleryDirectory => dir(path.join(Directory.systemTemp.path, 'mega_gallery'));
Expand Down
2 changes: 1 addition & 1 deletion dev/devicelab/test/adb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ CommandArgs cmd({
);
}

typedef dynamic ExitErrorFactory();
typedef ExitErrorFactory = dynamic Function();

class CommandArgs {
CommandArgs({ this.command, this.arguments, this.environment });
Expand Down
2 changes: 1 addition & 1 deletion dev/integration_tests/channels/lib/src/test_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'pair.dart';

enum TestStatus { ok, pending, failed, complete }

typedef Future<TestStepResult> TestStep();
typedef TestStep = Future<TestStepResult> Function();

const String nothing = '-';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter/material.dart';

enum TestStatus { ok, pending, failed, complete }

typedef Future<TestStepResult> TestStep();
typedef TestStep = Future<TestStepResult> Function();

const String nothing = '-';

Expand Down
2 changes: 1 addition & 1 deletion dev/manual_tests/lib/material_arc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class _RectangleDemoState extends State<_RectangleDemo> {
}
}

typedef Widget _DemoBuilder(_ArcDemo demo);
typedef _DemoBuilder = Widget Function(_ArcDemo demo);

class _ArcDemo {
_ArcDemo(this.title, this.builder, TickerProvider vsync)
Expand Down
2 changes: 1 addition & 1 deletion dev/manual_tests/lib/overlay_geometry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class OverlayGeometryApp extends StatefulWidget {
OverlayGeometryAppState createState() => new OverlayGeometryAppState();
}

typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition);
typedef CardTapCallback = void Function(GlobalKey targetKey, Offset globalPosition);

class CardBuilder extends SliverChildDelegate {
CardBuilder({ this.cardModels, this.onTapUp });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ enum _Location {
Bermuda
}

typedef Widget DemoItemBodyBuilder<T>(DemoItem<T> item);
typedef String ValueToString<T>(T value);
typedef DemoItemBodyBuilder<T> = Widget Function(DemoItem<T> item);
typedef ValueToString<T> = String Function(T value);

class DualHeaderWithHint extends StatelessWidget {
const DualHeaderWithHint({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum GridDemoTileStyle {
twoLine
}

typedef void BannerTapCallback(Photo photo);
typedef BannerTapCallback = void Function(Photo photo);

const double _kMinFlingVelocity = 800.0;
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
Expand Down
2 changes: 1 addition & 1 deletion examples/flutter_gallery/lib/gallery/updater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';

typedef Future<String> UpdateUrlFetcher();
typedef UpdateUrlFetcher = Future<String> Function();

class Updater extends StatefulWidget {
const Updater({ @required this.updateUrlFetcher, this.child, Key key })
Expand Down
4 changes: 2 additions & 2 deletions examples/layers/services/isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

typedef void OnProgressListener(double completed, double total);
typedef void OnResultListener(String result);
typedef OnProgressListener = void Function(double completed, double total);
typedef OnResultListener = void Function(String result);

// An encapsulation of a large amount of synchronous processing.
//
Expand Down
2 changes: 1 addition & 1 deletion examples/layers/widgets/styled_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import 'package:flutter/material.dart';

typedef Widget _TextTransformer(String name, String text);
typedef _TextTransformer = Widget Function(String name, String text);

// From https://en.wikiquote.org/wiki/2001:_A_Space_Odyssey_(film)
const String _kDialogText = '''
Expand Down
2 changes: 1 addition & 1 deletion examples/stocks/lib/i18n/stock_messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:intl/src/intl_helpers.dart';
import 'stock_messages_en.dart' as messages_en;
import 'stock_messages_es.dart' as messages_es;

typedef Future<dynamic> LibraryLoader();
typedef LibraryLoader = Future<dynamic> Function();
Map<String, LibraryLoader> _deferredLibraries = {
'en': () => new Future.value(null),
'es': () => new Future.value(null),
Expand Down
2 changes: 1 addition & 1 deletion examples/stocks/lib/i18n/stock_messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final messages = new MessageLookup();
final _keepAnalysisHappy = Intl.defaultLocale;

// ignore: non_constant_identifier_names
typedef MessageIfAbsent(String message_str, List args);
typedef MessageIfAbsent = dynamic Function(String message_str, List args);

class MessageLookup extends MessageLookupByLibrary {
get localeName => 'en';
Expand Down
2 changes: 1 addition & 1 deletion examples/stocks/lib/stock_home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'stock_strings.dart';
import 'stock_symbol_viewer.dart';
import 'stock_types.dart';

typedef void ModeUpdater(StockMode mode);
typedef ModeUpdater = void Function(StockMode mode);

enum _StockMenuItem { autorefresh, refresh, speedUp, speedDown }
enum StockHomeTab { market, portfolio }
Expand Down
2 changes: 1 addition & 1 deletion examples/stocks/lib/stock_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'stock_arrow.dart';
import 'stock_data.dart';

typedef void StockRowActionCallback(Stock stock);
typedef StockRowActionCallback = void Function(Stock stock);

class StockRow extends StatelessWidget {
StockRow({
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/animation/animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum AnimationStatus {
}

/// Signature for listeners attached using [Animation.addStatusListener].
typedef void AnimationStatusListener(AnimationStatus status);
typedef AnimationStatusListener = void Function(AnimationStatus status);

/// An animation with a value of type `T`.
///
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/cupertino/refresh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ enum RefreshIndicatorMode {
///
/// The `pulledExtent` parameter is the currently available space either from
/// overscrolling or as held by the sliver during refresh.
typedef Widget RefreshControlIndicatorBuilder(
typedef RefreshControlIndicatorBuilder = Widget Function(
BuildContext context,
RefreshIndicatorMode refreshState,
double pulledExtent,
Expand All @@ -216,7 +216,7 @@ typedef Widget RefreshControlIndicatorBuilder(
/// pulled a `refreshTriggerPullDistance`. Must return a [Future]. Upon
/// completion of the [Future], the [CupertinoRefreshControl] enters the
/// [RefreshIndicatorMode.done] state and will start to go away.
typedef Future<void> RefreshCallback();
typedef RefreshCallback = Future<void> Function();

/// A sliver widget implementing the iOS-style pull to refresh content control.
///
Expand Down
Loading

0 comments on commit 6c56bb2

Please sign in to comment.