From 5de96bb7341c521f7a6a3dec8cf24628aa1aa3e7 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Tue, 2 Oct 2018 17:14:59 +0200 Subject: [PATCH] unnecessary this in field initializers (#22522) --- dev/devicelab/lib/framework/framework.dart | 10 +++++----- dev/tools/vitool/lib/vitool.dart | 2 +- .../flutter/lib/src/cupertino/date_picker.dart | 2 +- packages/flutter/lib/src/material/button.dart | 2 +- .../flutter/lib/src/material/expansion_panel.dart | 2 +- .../src/widgets/bottom_navigation_bar_item.dart | 2 +- packages/flutter/lib/src/widgets/navigator.dart | 2 +- packages/flutter_driver/lib/src/common/find.dart | 4 ++-- .../flutter_driver/lib/src/common/frame_sync.dart | 2 +- .../flutter_driver/lib/src/common/gesture.dart | 10 +++++----- .../flutter_driver/lib/src/common/message.dart | 2 +- .../lib/src/common/request_data.dart | 2 +- .../flutter_driver/lib/src/common/semantics.dart | 2 +- .../lib/src/driver/timeline_summary.dart | 2 +- .../lib/src/material_localizations.dart | 14 +++++++------- .../lib/src/android/android_studio.dart | 2 +- .../flutter_tools/lib/src/resident_runner.dart | 2 +- .../flutter_tools/lib/src/test/event_printer.dart | 2 +- packages/flutter_tools/lib/src/vscode/vscode.dart | 4 ++-- .../test/integration/test_driver.dart | 2 +- .../lib/src/common/logging.dart | 4 ++-- 21 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dev/devicelab/lib/framework/framework.dart b/dev/devicelab/lib/framework/framework.dart index f3583f0b3e..7bc0b648e6 100644 --- a/dev/devicelab/lib/framework/framework.dart +++ b/dev/devicelab/lib/framework/framework.dart @@ -148,8 +148,8 @@ class _TaskRunner { class TaskResult { /// Constructs a successful result. TaskResult.success(this.data, {this.benchmarkScoreKeys = const []}) - : this.succeeded = true, - this.message = 'success' { + : succeeded = true, + message = 'success' { const JsonEncoder prettyJson = JsonEncoder.withIndent(' '); if (benchmarkScoreKeys != null) { for (String key in benchmarkScoreKeys) { @@ -173,9 +173,9 @@ class TaskResult { /// Constructs an unsuccessful result. TaskResult.failure(this.message) - : this.succeeded = false, - this.data = null, - this.benchmarkScoreKeys = const []; + : succeeded = false, + data = null, + benchmarkScoreKeys = const []; /// Whether the task succeeded. final bool succeeded; diff --git a/dev/tools/vitool/lib/vitool.dart b/dev/tools/vitool/lib/vitool.dart index 0e1ab4e9a8..e3545d5d13 100644 --- a/dev/tools/vitool/lib/vitool.dart +++ b/dev/tools/vitool/lib/vitool.dart @@ -446,7 +446,7 @@ class _Transform { /// Constructs a new _Transform, default arguments create a no-op transform. _Transform({Matrix3 transformMatrix, this.opacity = 1.0}) : - this.transformMatrix = transformMatrix ?? Matrix3.identity(); + transformMatrix = transformMatrix ?? Matrix3.identity(); final Matrix3 transformMatrix; final double opacity; diff --git a/packages/flutter/lib/src/cupertino/date_picker.dart b/packages/flutter/lib/src/cupertino/date_picker.dart index 6d687b3f02..818d16662a 100644 --- a/packages/flutter/lib/src/cupertino/date_picker.dart +++ b/packages/flutter/lib/src/cupertino/date_picker.dart @@ -172,7 +172,7 @@ class CupertinoDatePicker extends StatefulWidget { this.maximumYear, this.minuteInterval = 1, this.use24hFormat = false, - }) : this.initialDateTime = initialDateTime ?? DateTime.now(), + }) : initialDateTime = initialDateTime ?? DateTime.now(), assert(mode != null), assert(onDateTimeChanged != null), assert(initialDateTime != null), diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index d3c75d9ea4..7f75ee4542 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -49,7 +49,7 @@ class RawMaterialButton extends StatefulWidget { this.clipBehavior = Clip.none, MaterialTapTargetSize materialTapTargetSize, this.child, - }) : this.materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded, + }) : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded, assert(shape != null), assert(elevation != null), assert(highlightElevation != null), diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 01eabb6dec..933c709678 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -128,7 +128,7 @@ class ExpansionPanelList extends StatefulWidget { }) : assert(children != null), assert(animationDuration != null), _allowOnlyOnePanelOpen = false, - this.initialOpenPanelValue = null, + initialOpenPanelValue = null, super(key: key); /// Creates a radio expansion panel list widget. diff --git a/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart b/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart index bc82034a68..c7d743681b 100644 --- a/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart +++ b/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart @@ -27,7 +27,7 @@ class BottomNavigationBarItem { @required this.title, Widget activeIcon, this.backgroundColor, - }) : this.activeIcon = activeIcon ?? icon, + }) : activeIcon = activeIcon ?? icon, assert(icon != null), assert(title != null); diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index b4182405c6..48aa6c9af8 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -78,7 +78,7 @@ abstract class Route { /// /// If the [settings] are not provided, an empty [RouteSettings] object is /// used instead. - Route({ RouteSettings settings }) : this.settings = settings ?? const RouteSettings(); + Route({ RouteSettings settings }) : settings = settings ?? const RouteSettings(); /// The navigator that the route is in, if any. NavigatorState get navigator => _navigator; diff --git a/packages/flutter_driver/lib/src/common/find.dart b/packages/flutter_driver/lib/src/common/find.dart index 8610485728..b24b569fa9 100644 --- a/packages/flutter_driver/lib/src/common/find.dart +++ b/packages/flutter_driver/lib/src/common/find.dart @@ -191,8 +191,8 @@ class ByText extends SerializableFinder { class ByValueKey extends SerializableFinder { /// Creates a finder given the key value. ByValueKey(this.keyValue) - : this.keyValueString = '$keyValue', - this.keyValueType = '${keyValue.runtimeType}' { + : keyValueString = '$keyValue', + keyValueType = '${keyValue.runtimeType}' { if (!_supportedKeyValueTypes.contains(keyValue.runtimeType)) throw _createInvalidKeyValueTypeError('$keyValue.runtimeType'); } diff --git a/packages/flutter_driver/lib/src/common/frame_sync.dart b/packages/flutter_driver/lib/src/common/frame_sync.dart index 51cf884ee2..114a55a113 100644 --- a/packages/flutter_driver/lib/src/common/frame_sync.dart +++ b/packages/flutter_driver/lib/src/common/frame_sync.dart @@ -11,7 +11,7 @@ class SetFrameSync extends Command { /// Deserializes this command from the value generated by [serialize]. SetFrameSync.deserialize(Map params) - : this.enabled = params['enabled'].toLowerCase() == 'true', + : enabled = params['enabled'].toLowerCase() == 'true', super.deserialize(params); /// Whether frameSync should be enabled or disabled. diff --git a/packages/flutter_driver/lib/src/common/gesture.dart b/packages/flutter_driver/lib/src/common/gesture.dart index d1c535afbb..6da0b1dd52 100644 --- a/packages/flutter_driver/lib/src/common/gesture.dart +++ b/packages/flutter_driver/lib/src/common/gesture.dart @@ -44,10 +44,10 @@ class Scroll extends CommandWithTarget { /// Deserializes this command from the value generated by [serialize]. Scroll.deserialize(Map json) - : this.dx = double.parse(json['dx']), - this.dy = double.parse(json['dy']), - this.duration = Duration(microseconds: int.parse(json['duration'])), - this.frequency = int.parse(json['frequency']), + : dx = double.parse(json['dx']), + dy = double.parse(json['dy']), + duration = Duration(microseconds: int.parse(json['duration'])), + frequency = int.parse(json['frequency']), super.deserialize(json); /// Delta X offset per move event. @@ -94,7 +94,7 @@ class ScrollIntoView extends CommandWithTarget { /// Deserializes this command from the value generated by [serialize]. ScrollIntoView.deserialize(Map json) - : this.alignment = double.parse(json['alignment']), + : alignment = double.parse(json['alignment']), super.deserialize(json); /// How the widget should be aligned. diff --git a/packages/flutter_driver/lib/src/common/message.dart b/packages/flutter_driver/lib/src/common/message.dart index e834ebf6cd..36aab524c5 100644 --- a/packages/flutter_driver/lib/src/common/message.dart +++ b/packages/flutter_driver/lib/src/common/message.dart @@ -10,7 +10,7 @@ abstract class Command { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. const Command({ Duration timeout }) - : this.timeout = timeout ?? const Duration(seconds: 5); + : timeout = timeout ?? const Duration(seconds: 5); /// Deserializes this command from the value generated by [serialize]. Command.deserialize(Map json) diff --git a/packages/flutter_driver/lib/src/common/request_data.dart b/packages/flutter_driver/lib/src/common/request_data.dart index 82026b7b4d..d9b6598a30 100644 --- a/packages/flutter_driver/lib/src/common/request_data.dart +++ b/packages/flutter_driver/lib/src/common/request_data.dart @@ -12,7 +12,7 @@ class RequestData extends Command { /// Deserializes this command from the value generated by [serialize]. RequestData.deserialize(Map params) - : this.message = params['message'], + : message = params['message'], super.deserialize(params); /// The message being sent from the test to the application. diff --git a/packages/flutter_driver/lib/src/common/semantics.dart b/packages/flutter_driver/lib/src/common/semantics.dart index f015f67270..048c3d0857 100644 --- a/packages/flutter_driver/lib/src/common/semantics.dart +++ b/packages/flutter_driver/lib/src/common/semantics.dart @@ -11,7 +11,7 @@ class SetSemantics extends Command { /// Deserializes this command from the value generated by [serialize]. SetSemantics.deserialize(Map params) - : this.enabled = params['enabled'].toLowerCase() == 'true', + : enabled = params['enabled'].toLowerCase() == 'true', super.deserialize(params); /// Whether semantics should be enabled (true) or disabled (false). diff --git a/packages/flutter_driver/lib/src/driver/timeline_summary.dart b/packages/flutter_driver/lib/src/driver/timeline_summary.dart index 64e7dc0056..85322c2fdb 100644 --- a/packages/flutter_driver/lib/src/driver/timeline_summary.dart +++ b/packages/flutter_driver/lib/src/driver/timeline_summary.dart @@ -207,7 +207,7 @@ class TimelineSummary { class TimedEvent { /// Creates a timed event given begin and end timestamps in microseconds. TimedEvent(int beginTimeMicros, int endTimeMicros) - : this.duration = Duration(microseconds: endTimeMicros - beginTimeMicros); + : duration = Duration(microseconds: endTimeMicros - beginTimeMicros); /// The duration of the event. final Duration duration; diff --git a/packages/flutter_localizations/lib/src/material_localizations.dart b/packages/flutter_localizations/lib/src/material_localizations.dart index 453b9448d9..61debf8446 100644 --- a/packages/flutter_localizations/lib/src/material_localizations.dart +++ b/packages/flutter_localizations/lib/src/material_localizations.dart @@ -100,19 +100,19 @@ abstract class GlobalMaterialLocalizations implements MaterialLocalizations { @required intl.NumberFormat decimalFormat, @required intl.NumberFormat twoDigitZeroPaddedFormat, }) : assert(localeName != null), - this._localeName = localeName, + _localeName = localeName, assert(fullYearFormat != null), - this._fullYearFormat = fullYearFormat, + _fullYearFormat = fullYearFormat, assert(mediumDateFormat != null), - this._mediumDateFormat = mediumDateFormat, + _mediumDateFormat = mediumDateFormat, assert(longDateFormat != null), - this._longDateFormat = longDateFormat, + _longDateFormat = longDateFormat, assert(yearMonthFormat != null), - this._yearMonthFormat = yearMonthFormat, + _yearMonthFormat = yearMonthFormat, assert(decimalFormat != null), - this._decimalFormat = decimalFormat, + _decimalFormat = decimalFormat, assert(twoDigitZeroPaddedFormat != null), - this._twoDigitZeroPaddedFormat = twoDigitZeroPaddedFormat; + _twoDigitZeroPaddedFormat = twoDigitZeroPaddedFormat; final String _localeName; final intl.DateFormat _fullYearFormat; diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart index 4c3dc98696..932433bfae 100644 --- a/packages/flutter_tools/lib/src/android/android_studio.dart +++ b/packages/flutter_tools/lib/src/android/android_studio.dart @@ -32,7 +32,7 @@ String get javaPath => androidStudio?.javaPath; class AndroidStudio implements Comparable { AndroidStudio(this.directory, {Version version, this.configured, this.studioAppName = 'AndroidStudio'}) - : this.version = version ?? Version.unknown { + : version = version ?? Version.unknown { _init(); } diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 73cee56b59..53cd22cf46 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -35,7 +35,7 @@ class FlutterDevice { this.fileSystemRoots, this.fileSystemScheme, ResidentCompiler generator, - }) : this.generator = generator ?? ResidentCompiler( + }) : generator = generator ?? ResidentCompiler( artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), trackWidgetCreation: trackWidgetCreation, fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme diff --git a/packages/flutter_tools/lib/src/test/event_printer.dart b/packages/flutter_tools/lib/src/test/event_printer.dart index a19f5669d8..ab2648fb71 100644 --- a/packages/flutter_tools/lib/src/test/event_printer.dart +++ b/packages/flutter_tools/lib/src/test/event_printer.dart @@ -9,7 +9,7 @@ import 'watcher.dart'; /// Prints JSON events when running a test in --machine mode. class EventPrinter extends TestWatcher { - EventPrinter({StringSink out}) : this._out = out == null ? stdout: out; + EventPrinter({StringSink out}) : _out = out == null ? stdout: out; final StringSink _out; diff --git a/packages/flutter_tools/lib/src/vscode/vscode.dart b/packages/flutter_tools/lib/src/vscode/vscode.dart index 3ea9a3fe5e..e92b9e3d1d 100644 --- a/packages/flutter_tools/lib/src/vscode/vscode.dart +++ b/packages/flutter_tools/lib/src/vscode/vscode.dart @@ -14,7 +14,7 @@ const bool _includeInsiders = false; class VsCode { VsCode._(this.directory, this.extensionDirectory, { Version version, this.edition }) - : this.version = version ?? Version.unknown { + : version = version ?? Version.unknown { if (!fs.isDirectorySync(directory)) { _validationMessages.add('VS Code not found at $directory'); @@ -195,7 +195,7 @@ class VsCode { class _VsCodeInstallLocation { const _VsCodeInstallLocation(this.installPath, this.extensionsFolder, { this.edition, bool isInsiders }) - : this.isInsiders = isInsiders ?? false; + : isInsiders = isInsiders ?? false; final String installPath; final String extensionsFolder; final String edition; diff --git a/packages/flutter_tools/test/integration/test_driver.dart b/packages/flutter_tools/test/integration/test_driver.dart index b8503a2008..d4a94e8a96 100644 --- a/packages/flutter_tools/test/integration/test_driver.dart +++ b/packages/flutter_tools/test/integration/test_driver.dart @@ -24,7 +24,7 @@ const Duration quitTimeout = Duration(seconds: 10); class FlutterTestDriver { FlutterTestDriver(this._projectFolder, {String logPrefix}): - this._logPrefix = logPrefix != null ? '$logPrefix: ' : ''; + _logPrefix = logPrefix != null ? '$logPrefix: ' : ''; final Directory _projectFolder; final String _logPrefix; diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart index d015c71711..8a1e6662ae 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart @@ -69,9 +69,9 @@ class LogMessage { /// /// When this message is created, it sets its [time] to [DateTime.now]. LogMessage(this.message, this.tag, this.level) - : this.levelName = + : levelName = level.toString().substring(level.toString().indexOf('.') + 1), - this.time = DateTime.now(); + time = DateTime.now(); /// The actual log message. final String message;