Commit 610955f8 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

upgrade to linter-0.1.30 (#9297)

* upgrade to linter-0.1.30

* add prefer_is_empty lint
* add directives_ordering lint
* add no_adjacent_strings_in_list lint
* add no_duplicate_case_values lint
* add prefer_collection_literals lint
* add prefer_const_constructors lint
* add prefer_contains lint
* add prefer_initializing_formals lint
* add unnecessary_null_aware_assignments lint
* add unnecessary_null_in_if_null_operators lint
parent 361afef3
...@@ -74,11 +74,14 @@ linter: ...@@ -74,11 +74,14 @@ linter:
- await_only_futures - await_only_futures
- camel_case_types - camel_case_types
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- directives_ordering
- empty_catches - empty_catches
- empty_constructor_bodies - empty_constructor_bodies
- implementation_imports - implementation_imports
- library_names - library_names
- library_prefixes - library_prefixes
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names - non_constant_identifier_names
# - one_member_abstracts # too many false positives # - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
...@@ -87,7 +90,12 @@ linter: ...@@ -87,7 +90,12 @@ linter:
- package_prefixed_library_names - package_prefixed_library_names
# - parameter_assignments # we do this commonly # - parameter_assignments # we do this commonly
# - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197 # - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197
- prefer_collection_literals
- prefer_const_constructors
- prefer_contains
- prefer_final_locals - prefer_final_locals
- prefer_initializing_formals
- prefer_is_empty
- prefer_is_not_empty - prefer_is_not_empty
# - public_member_api_docs # this is the only difference from .analysis_options_repo # - public_member_api_docs # this is the only difference from .analysis_options_repo
- slash_for_doc_comments - slash_for_doc_comments
...@@ -99,6 +107,8 @@ linter: ...@@ -99,6 +107,8 @@ linter:
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interp - unnecessary_brace_in_string_interp
- unnecessary_getters_setters - unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
# === pub rules === # === pub rules ===
- package_names - package_names
...@@ -72,11 +72,14 @@ linter: ...@@ -72,11 +72,14 @@ linter:
- await_only_futures - await_only_futures
- camel_case_types - camel_case_types
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- directives_ordering
- empty_catches - empty_catches
- empty_constructor_bodies - empty_constructor_bodies
- implementation_imports - implementation_imports
- library_names - library_names
- library_prefixes - library_prefixes
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names - non_constant_identifier_names
# - one_member_abstracts # too many false positives # - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
...@@ -85,7 +88,12 @@ linter: ...@@ -85,7 +88,12 @@ linter:
- package_prefixed_library_names - package_prefixed_library_names
# - parameter_assignments # we do this commonly # - parameter_assignments # we do this commonly
# - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197 # - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197
- prefer_collection_literal
- prefer_const_constructors
- prefer_contains
- prefer_final_locals - prefer_final_locals
- prefer_initializing_formals
- prefer_is_empty
- prefer_is_not_empty - prefer_is_not_empty
- public_member_api_docs # this is the only difference from .analysis_options - public_member_api_docs # this is the only difference from .analysis_options
- slash_for_doc_comments - slash_for_doc_comments
...@@ -95,8 +103,10 @@ linter: ...@@ -95,8 +103,10 @@ linter:
# - type_annotate_public_apis # subset of always_specify_types # - type_annotate_public_apis # subset of always_specify_types
- type_init_formals - type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interp - unnecessary_brace_in_string_interps
- unnecessary_getters_setters - unnecessary_getters_setters
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
# === pub rules === # === pub rules ===
- package_names - package_names
...@@ -60,7 +60,7 @@ class ComplexLayoutState extends State<ComplexLayout> { ...@@ -60,7 +60,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
title: const Text('Advanced Layout'), title: const Text('Advanced Layout'),
actions: <Widget>[ actions: <Widget>[
new IconButton( new IconButton(
icon: new Icon(Icons.create), icon: const Icon(Icons.create),
tooltip: 'Search', tooltip: 'Search',
onPressed: () { onPressed: () {
print('Pressed search'); print('Pressed search');
...@@ -386,11 +386,11 @@ class ItemImageBox extends StatelessWidget { ...@@ -386,11 +386,11 @@ class ItemImageBox extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
new IconButton( new IconButton(
icon: new Icon(Icons.edit), icon: const Icon(Icons.edit),
onPressed: () { print('Pressed edit button'); } onPressed: () { print('Pressed edit button'); }
), ),
new IconButton( new IconButton(
icon: new Icon(Icons.zoom_in), icon: const Icon(Icons.zoom_in),
onPressed: () { print('Pressed zoom button'); } onPressed: () { print('Pressed zoom button'); }
), ),
] ]
...@@ -578,7 +578,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -578,7 +578,7 @@ class GalleryDrawer extends StatelessWidget {
children: <Widget>[ children: <Widget>[
new FancyDrawerHeader(), new FancyDrawerHeader(),
new ListTile( new ListTile(
leading: new Icon(Icons.brightness_5), leading: const Icon(Icons.brightness_5),
title: const Text('Light'), title: const Text('Light'),
onTap: () { _changeTheme(context, true); }, onTap: () { _changeTheme(context, true); },
selected: ComplexLayoutApp.of(context).lightTheme, selected: ComplexLayoutApp.of(context).lightTheme,
...@@ -589,7 +589,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -589,7 +589,7 @@ class GalleryDrawer extends StatelessWidget {
), ),
), ),
new ListTile( new ListTile(
leading: new Icon(Icons.brightness_7), leading: const Icon(Icons.brightness_7),
title: const Text('Dark'), title: const Text('Dark'),
onTap: () { _changeTheme(context, false); }, onTap: () { _changeTheme(context, false); },
selected: !ComplexLayoutApp.of(context).lightTheme, selected: !ComplexLayoutApp.of(context).lightTheme,
...@@ -601,7 +601,7 @@ class GalleryDrawer extends StatelessWidget { ...@@ -601,7 +601,7 @@ class GalleryDrawer extends StatelessWidget {
), ),
new Divider(), new Divider(),
new ListTile( new ListTile(
leading: new Icon(Icons.hourglass_empty), leading: const Icon(Icons.hourglass_empty),
title: const Text('Animate Slowly'), title: const Text('Animate Slowly'),
selected: timeDilation != 1.0, selected: timeDilation != 1.0,
onTap: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); }, onTap: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); },
......
...@@ -108,7 +108,7 @@ class CardCollectionState extends State<CardCollection> { ...@@ -108,7 +108,7 @@ class CardCollectionState extends State<CardCollection> {
buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable), buildFontRadioItem("Right-align text", TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable),
new Divider(), new Divider(),
new ListTile( new ListTile(
leading: new Icon(Icons.dvr), leading: const Icon(Icons.dvr),
onTap: () { debugDumpApp(); debugDumpRenderTree(); }, onTap: () { debugDumpApp(); debugDumpRenderTree(); },
title: const Text('Dump App to Console'), title: const Text('Dump App to Console'),
), ),
...@@ -281,7 +281,7 @@ class CardCollectionState extends State<CardCollection> { ...@@ -281,7 +281,7 @@ class CardCollectionState extends State<CardCollection> {
} }
// TODO(abarth): This icon is wrong in RTL. // TODO(abarth): This icon is wrong in RTL.
Widget leftArrowIcon = new Icon(Icons.arrow_back, size: 36.0); Widget leftArrowIcon = const Icon(Icons.arrow_back, size: 36.0);
if (_dismissDirection == DismissDirection.startToEnd) if (_dismissDirection == DismissDirection.startToEnd)
leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon); leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon);
......
...@@ -452,7 +452,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM ...@@ -452,7 +452,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
floatingActionButton: new Builder( floatingActionButton: new Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return new FloatingActionButton( return new FloatingActionButton(
child: new Icon(Icons.refresh), child: const Icon(Icons.refresh),
onPressed: () { onPressed: () {
_play(_allDemos[DefaultTabController.of(context).index]); _play(_allDemos[DefaultTabController.of(context).index]);
}, },
......
...@@ -92,7 +92,7 @@ class PageViewAppState extends State<PageViewApp> { ...@@ -92,7 +92,7 @@ class PageViewAppState extends State<PageViewApp> {
onTap: switchScrollDirection, onTap: switchScrollDirection,
), ),
new ListTile( new ListTile(
leading: new Icon(Icons.more_vert), leading: const Icon(Icons.more_vert),
selected: scrollDirection == Axis.vertical, selected: scrollDirection == Axis.vertical,
trailing: const Text('Vertical Layout'), trailing: const Text('Vertical Layout'),
onTap: switchScrollDirection, onTap: switchScrollDirection,
......
...@@ -22,6 +22,13 @@ ...@@ -22,6 +22,13 @@
/// initialized with those features. /// initialized with those features.
library rendering; library rendering;
export 'package:flutter/foundation.dart' show
VoidCallback,
ValueChanged,
ValueGetter,
ValueSetter;
export 'package:vector_math/vector_math_64.dart' show Matrix4;
export 'src/rendering/animated_size.dart'; export 'src/rendering/animated_size.dart';
export 'src/rendering/binding.dart'; export 'src/rendering/binding.dart';
export 'src/rendering/block.dart'; export 'src/rendering/block.dart';
...@@ -57,10 +64,3 @@ export 'src/rendering/view.dart'; ...@@ -57,10 +64,3 @@ export 'src/rendering/view.dart';
export 'src/rendering/viewport.dart'; export 'src/rendering/viewport.dart';
export 'src/rendering/viewport_offset.dart'; export 'src/rendering/viewport_offset.dart';
export 'src/rendering/wrap.dart'; export 'src/rendering/wrap.dart';
export 'package:flutter/foundation.dart' show
VoidCallback,
ValueChanged,
ValueGetter,
ValueSetter;
export 'package:vector_math/vector_math_64.dart' show Matrix4;
...@@ -467,7 +467,7 @@ class _MonthPickerState extends State<MonthPicker> { ...@@ -467,7 +467,7 @@ class _MonthPickerState extends State<MonthPicker> {
top: 0.0, top: 0.0,
left: 8.0, left: 8.0,
child: new IconButton( child: new IconButton(
icon: new Icon(Icons.chevron_left), icon: const Icon(Icons.chevron_left),
tooltip: 'Previous month', tooltip: 'Previous month',
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth, onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
), ),
...@@ -476,7 +476,7 @@ class _MonthPickerState extends State<MonthPicker> { ...@@ -476,7 +476,7 @@ class _MonthPickerState extends State<MonthPicker> {
top: 0.0, top: 0.0,
right: 8.0, right: 8.0,
child: new IconButton( child: new IconButton(
icon: new Icon(Icons.chevron_right), icon: const Icon(Icons.chevron_right),
tooltip: 'Next month', tooltip: 'Next month',
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
), ),
......
...@@ -9,8 +9,8 @@ import 'dart:typed_data'; ...@@ -9,8 +9,8 @@ import 'dart:typed_data';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'platform_messages.dart';
import 'http_client.dart'; import 'http_client.dart';
import 'platform_messages.dart';
/// A collection of resources used by the application. /// A collection of resources used by the application.
/// ///
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'platform_channel.dart';
import 'message_codecs.dart'; import 'message_codecs.dart';
import 'platform_channel.dart';
/// Platform channels used by the Flutter system. /// Platform channels used by the Flutter system.
class SystemChannels { class SystemChannels {
......
...@@ -7,9 +7,9 @@ import 'dart:ui' show TextAffinity, hashValues; ...@@ -7,9 +7,9 @@ import 'dart:ui' show TextAffinity, hashValues;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'message_codec.dart';
import 'system_channels.dart'; import 'system_channels.dart';
import 'text_editing.dart'; import 'text_editing.dart';
import 'message_codec.dart';
export 'dart:ui' show TextAffinity; export 'dart:ui' show TextAffinity;
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:typed_data';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'dart:typed_data';
void main() { void main() {
group('Write and read buffer round-trip', () { group('Write and read buffer round-trip', () {
test('of single byte', () { test('of single byte', () {
...@@ -77,4 +77,4 @@ void main() { ...@@ -77,4 +77,4 @@ void main() {
expect(readDoubles[1], isNaN); expect(readDoubles[1], isNaN);
}); });
}); });
} }
\ No newline at end of file
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
import 'dart:async'; import 'dart:async';
import '../base/io.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
...@@ -50,7 +50,7 @@ class AndroidWorkflow extends DoctorValidator implements Workflow { ...@@ -50,7 +50,7 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
final String javaHomeOutput = runCheckedSync(<String>['/usr/libexec/java_home'], hideStdout: true); final String javaHomeOutput = runCheckedSync(<String>['/usr/libexec/java_home'], hideStdout: true);
if (javaHomeOutput != null) { if (javaHomeOutput != null) {
final List<String> javaHomeOutputSplit = javaHomeOutput.split('\n'); final List<String> javaHomeOutputSplit = javaHomeOutput.split('\n');
if ((javaHomeOutputSplit != null) && (javaHomeOutputSplit.length > 0)) { if ((javaHomeOutputSplit != null) && (javaHomeOutputSplit.isNotEmpty)) {
final String javaHome = javaHomeOutputSplit[0].trim(); final String javaHome = javaHomeOutputSplit[0].trim();
return fs.path.join(javaHome, 'bin', 'java'); return fs.path.join(javaHome, 'bin', 'java');
} }
......
...@@ -74,7 +74,7 @@ class FuchsiaReloadCommand extends FlutterCommand { ...@@ -74,7 +74,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
// Find the network ports used on the device by VM service instances. // Find the network ports used on the device by VM service instances.
final List<int> servicePorts = await _getServicePorts(); final List<int> servicePorts = await _getServicePorts();
if (servicePorts.length == 0) { if (servicePorts.isEmpty) {
throwToolExit("Couldn't find any running Observatory instances."); throwToolExit("Couldn't find any running Observatory instances.");
} }
for (int port in servicePorts) { for (int port in servicePorts) {
...@@ -85,7 +85,7 @@ class FuchsiaReloadCommand extends FlutterCommand { ...@@ -85,7 +85,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
// ports, and find the Isolates that are running the target app. // ports, and find the Isolates that are running the target app.
final String isolateName = "$_binaryName\$main"; final String isolateName = "$_binaryName\$main";
final List<int> targetPorts = await _filterPorts(servicePorts, isolateName); final List<int> targetPorts = await _filterPorts(servicePorts, isolateName);
if (targetPorts.length == 0) { if (targetPorts.isEmpty) {
throwToolExit("No VMs found running $_binaryName"); throwToolExit("No VMs found running $_binaryName");
} }
for (int port in targetPorts) { for (int port in targetPorts) {
...@@ -110,7 +110,7 @@ class FuchsiaReloadCommand extends FlutterCommand { ...@@ -110,7 +110,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
// Find ports where there is a view isolate with the given name // Find ports where there is a view isolate with the given name
Future<List<int>> _filterPorts(List<int> ports, String isolateFilter) async { Future<List<int>> _filterPorts(List<int> ports, String isolateFilter) async {
final List<int> result = new List<int>(); final List<int> result = <int>[];
for (int port in ports) { for (int port in ports) {
final String addr = "http://$_address:$port"; final String addr = "http://$_address:$port";
final Uri uri = Uri.parse(addr); final Uri uri = Uri.parse(addr);
...@@ -206,7 +206,7 @@ class FuchsiaReloadCommand extends FlutterCommand { ...@@ -206,7 +206,7 @@ class FuchsiaReloadCommand extends FlutterCommand {
final FuchsiaDeviceCommandRunner runner = final FuchsiaDeviceCommandRunner runner =
new FuchsiaDeviceCommandRunner(_fuchsiaRoot); new FuchsiaDeviceCommandRunner(_fuchsiaRoot);
final List<String> lsOutput = await runner.run("ls /tmp/dart.services"); final List<String> lsOutput = await runner.run("ls /tmp/dart.services");
final List<int> ports = new List<int>(); final List<int> ports = <int>[];
for (String s in lsOutput) { for (String s in lsOutput) {
final String trimmed = s.trim(); final String trimmed = s.trim();
final int lastSpace = trimmed.lastIndexOf(' '); final int lastSpace = trimmed.lastIndexOf(' ');
......
...@@ -8,11 +8,11 @@ import 'dart:convert' show JSON; ...@@ -8,11 +8,11 @@ import 'dart:convert' show JSON;
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import '../application_package.dart'; import '../application_package.dart';
import '../base/context.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
......
...@@ -18,7 +18,7 @@ dependencies: ...@@ -18,7 +18,7 @@ dependencies:
intl: '>=0.14.0 <0.15.0' intl: '>=0.14.0 <0.15.0'
json_rpc_2: ^2.0.0 json_rpc_2: ^2.0.0
json_schema: 1.0.6 json_schema: 1.0.6
linter: 0.1.30-alpha.1 linter: 0.1.30
meta: ^1.0.4 meta: ^1.0.4
mustache: ^0.2.5 mustache: ^0.2.5
package_config: '>=0.1.5 <2.0.0' package_config: '>=0.1.5 <2.0.0'
......
...@@ -2,13 +2,12 @@ ...@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:flutter_tools/src/version.dart';
import '../context.dart';
import '../common.dart'; import '../common.dart';
import '../context.dart';
import 'flutter_command_test.dart'; import 'flutter_command_test.dart';
void main() { void main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment