Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[all] Switch to pedantic lint package #2258

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 2 additions & 138 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,140 +1,4 @@
# Specify analysis options.
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
# NOTE: Please keep this file in sync with
# https://github.com/flutter/flutter/blob/master/analysis_options.yaml

include: package:pedantic/analysis_options.yaml
analyzer:
language:
enableStrictCallChecks: true
enableSuperMixins: true
enableAssertInitializer: true
strong-mode:
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
exclude:
- 'bin/cache/**'
# the following two are relative to the stocks example and the flutter package respectively
# see https://github.com/dart-lang/sdk/issues/28463
- 'lib/i18n/stock_messages_*.dart'
- 'lib/src/http/**'

linter:
rules:
# these rules are documented on and in the same order as
# the Dart Lint rules page to make maintenance easier
# http://dart-lang.github.io/linter/lints/

# === error rules ===
- avoid_empty_else
- avoid_slow_async_io
- cancel_subscriptions
# - close_sinks # https://github.com/flutter/flutter/issues/5789
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
- control_flow_in_finally
- empty_statements
- hash_and_equals
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
- iterable_contains_unrelated_type
- list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
- no_adjacent_strings_in_list
- no_duplicate_case_values
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
- valid_regexps

# === style rules ===
- always_declare_return_types
# - always_put_control_body_on_new_line
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
# - avoid_annotating_with_dynamic # not yet tested
- avoid_as
# - avoid_catches_without_on_clauses # not yet tested
# - avoid_catching_errors # not yet tested
# - avoid_classes_with_only_static_members # not yet tested
# - avoid_function_literals_in_foreach_calls # not yet tested
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
# - avoid_positional_boolean_parameters # not yet tested
- avoid_return_types_on_setters
# - avoid_returning_null # not yet tested
# - avoid_returning_this # not yet tested
# - avoid_setters_without_getters # not yet tested
# - avoid_types_on_closure_parameters # not yet tested
- await_only_futures
- camel_case_types
# - cascade_invocations # not yet tested
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- directives_ordering
- empty_catches
- empty_constructor_bodies
- implementation_imports
# - join_return_with_assignment # not yet tested
- library_names
- library_prefixes
- non_constant_identifier_names
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
- overridden_fields
- package_api_docs
- package_prefixed_library_names
# - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation
- prefer_collection_literals
# - prefer_conditional_assignment # not yet tested
- prefer_const_constructors
# - prefer_constructors_over_static_methods # not yet tested
- prefer_contains
- prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
# - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
- prefer_final_locals
# - prefer_foreach # not yet tested
# - prefer_function_declarations_over_variables # not yet tested
- prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
- prefer_is_empty
- prefer_is_not_empty
- prefer_void_to_null
# - recursive_getters # https://github.com/dart-lang/linter/issues/452
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
# - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627
- unnecessary_statements
- unnecessary_this
- use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review

# === pub rules ===
- package_names
- '**/*.g.dart' # Ignore generated files
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'dart:io';

import 'package:android_intent/android_intent.dart';
import 'package:android_intent_example/main.dart';
import 'package:e2e/e2e.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import '../../lib/android_intent.dart';

/// This is a smoke test that verifies that the example app builds and loads.
/// Because this plugin works by launching Android platform UIs it's not
/// possible to meaningfully test it through its Dart interface currently. There
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
6 changes: 3 additions & 3 deletions packages/android_intent/test/android_intent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() {
flags: <int>[Flag.FLAG_ACTIVITY_NEW_TASK],
channel: mockChannel,
platform: FakePlatform(operatingSystem: 'android'));
androidIntent.launch();
await androidIntent.launch();
verify(mockChannel.invokeMethod<void>('launch', <String, Object>{
'action': 'action_view',
'data': Uri.encodeFull('https://flutter.io'),
Expand All @@ -35,7 +35,7 @@ void main() {
action: null,
channel: mockChannel,
platform: FakePlatform(operatingSystem: 'android'));
androidIntent.launch();
await androidIntent.launch();
verify(mockChannel.invokeMethod<void>('launch', <String, Object>{
'action': null,
}));
Expand All @@ -46,7 +46,7 @@ void main() {
action: null,
channel: mockChannel,
platform: FakePlatform(operatingSystem: 'ios'));
androidIntent.launch();
await androidIntent.launch();
verifyZeroInteractions(mockChannel);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/battery/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Icon(Icons.battery_unknown),
onPressed: () async {
final int batteryLevel = await _battery.batteryLevel;
showDialog<void>(
await showDialog<void>(
context: context,
builder: (_) => AlertDialog(
content: Text('Battery: $batteryLevel%'),
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/example/test_driver/camera_e2e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void main() {
sleep(const Duration(milliseconds: 500));

await controller.stopImageStream();
controller.dispose();
await controller.dispose();
},
skip: !Platform.isAndroid,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/example/test_driver/camera_e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
print('Test finished. Revoking camera permissions...');
Process.runSync('adb', <String>[
'shell',
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/lib/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class CameraController extends ValueNotifier<CameraValue> {
throw CameraException(e.code, e.message);
}

_imageStreamSubscription.cancel();
await _imageStreamSubscription.cancel();
_imageStreamSubscription = null;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/connectivity/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _MyHomePageState extends State<MyHomePage> {
return;
}

_updateConnectionStatus(result);
await _updateConnectionStatus(result);
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
4 changes: 2 additions & 2 deletions packages/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import 'package:flutter_driver/flutter_driver.dart';
Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
```
Expand Down Expand Up @@ -118,7 +118,7 @@ To e2e test on a local Android device (emulated or physical):

## Firebase Test Lab

If this is you first time testing with Firebase Test Lab,
If this is you first time testing with Firebase Test Lab,
you'll need to follow the guides in the
[Firebase test lab documentation](https://firebase.google.com/docs/test-lab/?gclid=EAIaIQobChMIs5qVwqW25QIV8iCtBh3DrwyUEAAYASAAEgLFU_D_BwE)
to set up a project.
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/example/test_driver/example_e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
exit(result == 'pass' ? 0 : 1);
}
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/example/lib/marker_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MarkerIconsBodyState extends State<MarkerIconsBody> {
if (_markerIcon == null) {
final ImageConfiguration imageConfiguration =
createLocalImageConfiguration(context);
BitmapDescriptor.fromAssetImage(
await BitmapDescriptor.fromAssetImage(
imageConfiguration, 'assets/red_square.png')
.then(_updateBitmap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import 'package:flutter_driver/flutter_driver.dart';
Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
await driver.requestData(null, timeout: const Duration(minutes: 1));
driver.close();
await driver.close();
}
10 changes: 5 additions & 5 deletions packages/google_maps_flutter/lib/src/google_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,34 +253,34 @@ class _GoogleMapState extends State<GoogleMap> {
return;
}
final GoogleMapController controller = await _controller.future;
controller._updateMapOptions(updates);
await controller._updateMapOptions(updates);
_googleMapOptions = newOptions;
}

void _updateMarkers() async {
final GoogleMapController controller = await _controller.future;
controller._updateMarkers(
await controller._updateMarkers(
_MarkerUpdates.from(_markers.values.toSet(), widget.markers));
_markers = _keyByMarkerId(widget.markers);
}

void _updatePolygons() async {
final GoogleMapController controller = await _controller.future;
controller._updatePolygons(
await controller._updatePolygons(
_PolygonUpdates.from(_polygons.values.toSet(), widget.polygons));
_polygons = _keyByPolygonId(widget.polygons);
}

void _updatePolylines() async {
final GoogleMapController controller = await _controller.future;
controller._updatePolylines(
await controller._updatePolylines(
_PolylineUpdates.from(_polylines.values.toSet(), widget.polylines));
_polylines = _keyByPolylineId(widget.polylines);
}

void _updateCircles() async {
final GoogleMapController controller = await _controller.future;
controller._updateCircles(
await controller._updateCircles(
_CircleUpdates.from(_circles.values.toSet(), widget.circles));
_circles = _keyByCircleId(widget.circles);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SignInDemoState extends State<SignInDemo> {
}

Future<void> _handleSignOut() async {
_googleSignIn.disconnect();
await _googleSignIn.disconnect();
}

Widget _buildBody() {
Expand Down
3 changes: 0 additions & 3 deletions packages/in_app_purchase/analysis_options.yaml

This file was deleted.

Loading