Unverified Commit b3f63d38 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Document why some lints aren't enabled and fix some minor issues. (#91527)

parent cd5936e4
...@@ -27,13 +27,12 @@ analyzer: ...@@ -27,13 +27,12 @@ analyzer:
missing_required_param: warning missing_required_param: warning
# treat missing returns as a warning (not a hint) # treat missing returns as a warning (not a hint)
missing_return: warning missing_return: warning
# allow having TODO/HACK comments in the code # allow having TODO comments in the code
todo: ignore todo: ignore
hack: ignore
# allow self-reference to deprecated members (we do this because otherwise we have # allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something) # to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore deprecated_member_use_from_same_package: ignore
# TODO(https://github.com/flutter/flutter/issues/74381): # TODO(ianh): https://github.com/flutter/flutter/issues/74381
# Clean up existing unnecessary imports, and remove line to ignore. # Clean up existing unnecessary imports, and remove line to ignore.
unnecessary_import: ignore unnecessary_import: ignore
# Turned off until null-safe rollout is complete. # Turned off until null-safe rollout is complete.
...@@ -92,12 +91,12 @@ linter: ...@@ -92,12 +91,12 @@ linter:
- avoid_unnecessary_containers - avoid_unnecessary_containers
- avoid_unused_constructor_parameters - avoid_unused_constructor_parameters
- avoid_void_async - avoid_void_async
# - avoid_web_libraries_in_flutter # not yet tested # - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere
- await_only_futures - await_only_futures
- camel_case_extensions - camel_case_extensions
- camel_case_types - camel_case_types
- cancel_subscriptions - cancel_subscriptions
# - cascade_invocations # not yet tested # - cascade_invocations # doesn't match the typical style of this repo
- cast_nullable_to_non_nullable - cast_nullable_to_non_nullable
# - close_sinks # not reliable enough # - close_sinks # not reliable enough
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142 # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
...@@ -105,9 +104,9 @@ linter: ...@@ -105,9 +104,9 @@ linter:
- control_flow_in_finally - control_flow_in_finally
# - curly_braces_in_flow_control_structures # not required by flutter style # - curly_braces_in_flow_control_structures # not required by flutter style
- deprecated_consistency - deprecated_consistency
# - diagnostic_describe_all_properties # not yet tested # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
- directives_ordering - directives_ordering
# - do_not_use_environment # we do this commonly # - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
- empty_catches - empty_catches
- empty_constructor_bodies - empty_constructor_bodies
- empty_statements - empty_statements
...@@ -125,7 +124,7 @@ linter: ...@@ -125,7 +124,7 @@ linter:
- library_private_types_in_public_api - library_private_types_in_public_api
# - lines_longer_than_80_chars # not required by flutter style # - lines_longer_than_80_chars # not required by flutter style
- list_remove_unrelated_type - list_remove_unrelated_type
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181 # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
- missing_whitespace_between_adjacent_strings - missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list - no_adjacent_strings_in_list
# - no_default_cases # too many false positives # - no_default_cases # too many false positives
......
...@@ -21,22 +21,14 @@ String cwd = Directory.current.path; ...@@ -21,22 +21,14 @@ String cwd = Directory.current.path;
/// The local engine to use for [flutter] and [evalFlutter], if any. /// The local engine to use for [flutter] and [evalFlutter], if any.
String? get localEngine { String? get localEngine {
// Use two distinct `defaultValue`s to determine whether a 'localEngine' const bool isDefined = bool.hasEnvironment('localEngine');
// declaration exists in the environment.
const bool isDefined =
String.fromEnvironment('localEngine', defaultValue: 'a') ==
String.fromEnvironment('localEngine', defaultValue: 'b');
return isDefined ? const String.fromEnvironment('localEngine') : null; return isDefined ? const String.fromEnvironment('localEngine') : null;
} }
/// The local engine source path to use if a local engine is used for [flutter] /// The local engine source path to use if a local engine is used for [flutter]
/// and [evalFlutter]. /// and [evalFlutter].
String? get localEngineSrcPath { String? get localEngineSrcPath {
// Use two distinct `defaultValue`s to determine whether a const bool isDefined = bool.hasEnvironment('localEngineSrcPath');
// 'localEngineSrcPath' declaration exists in the environment.
const bool isDefined =
String.fromEnvironment('localEngineSrcPath', defaultValue: 'a') ==
String.fromEnvironment('localEngineSrcPath', defaultValue: 'b');
return isDefined ? const String.fromEnvironment('localEngineSrcPath') : null; return isDefined ? const String.fromEnvironment('localEngineSrcPath') : null;
} }
......
include: ../analysis_options.yaml
linter:
rules:
# - diagnostic_describe_all_properties # blocked on https://github.com/dart-lang/sdk/issues/47418
...@@ -556,53 +556,55 @@ abstract class FlutterDriver { ...@@ -556,53 +556,55 @@ abstract class FlutterDriver {
/// ///
/// The image will be returned as a PNG. /// The image will be returned as a PNG.
/// ///
/// HACK: There will be a 2-second artificial delay before screenshotting, /// **Warning:** This is not reliable.
/// the delay here is to deal with a race between the driver script and ///
/// the raster thread (formerly known as the GPU thread). The issue is /// There is a two-second artificial delay before screenshotting. The delay
/// that driver API synchronizes with the framework based on transient /// here is to deal with a race between the driver script and the raster
/// callbacks, which are out of sync with the raster thread. /// thread (formerly known as the GPU thread). The issue is that the driver
/// Here's the timeline of events in ASCII art: /// API synchronizes with the framework based on transient callbacks, which
/// /// are out of sync with the raster thread.
/// ------------------------------------------------------------------- ///
/// Without this delay: /// Here's the timeline of events in ASCII art:
/// ------------------------------------------------------------------- ///
/// UI : <-- build --> /// ---------------------------------------------------------------
/// Raster: <-- rasterize --> /// Without this delay:
/// Gap : | random | /// ---------------------------------------------------------------
/// Driver: <-- screenshot --> /// UI : <-- build -->
/// /// Raster: <-- rasterize -->
/// In the diagram above, the gap is the time between the last driver /// Gap : | random |
/// action taken, such as a `tap()`, and the subsequent call to /// Driver: <-- screenshot -->
/// `screenshot()`. The gap is random because it is determined by the ///
/// unpredictable network communication between the driver process and /// In the diagram above, the gap is the time between the last driver action
/// the application. If this gap is too short, which it typically will /// taken, such as a `tap()`, and the subsequent call to `screenshot()`. The
/// be, the screenshot is taken before the raster thread is done /// gap is random because it is determined by the unpredictable communication
/// rasterizing the frame, so the screenshot of the previous frame is /// channel between the driver process and the application. If this gap is too
/// taken, which is wrong. /// short, which it typically will be, the screenshot is taken before the
/// /// raster thread is done rasterizing the frame, so the screenshot of the
/// ------------------------------------------------------------------- /// previous frame is taken, which is not what is intended.
/// With this delay, if we're lucky: ///
/// ------------------------------------------------------------------- /// ---------------------------------------------------------------
/// UI : <-- build --> /// With this delay, if we're lucky:
/// Raster: <-- rasterize --> /// ---------------------------------------------------------------
/// Gap : | 2 seconds or more | /// UI : <-- build -->
/// Driver: <-- screenshot --> /// Raster: <-- rasterize -->
/// /// Gap : | 2 seconds or more |
/// The two-second gap should be long enough for the raster thread to /// Driver: <-- screenshot -->
/// finish rasterizing the frame, but not longer than necessary to keep ///
/// driver tests as fast a possible. /// The two-second gap should be long enough for the raster thread to finish
/// /// rasterizing the frame, but not longer than necessary to keep driver tests
/// ------------------------------------------------------------------- /// as fast a possible.
/// With this delay, if we're not lucky: ///
/// ------------------------------------------------------------------- /// ---------------------------------------------------------------
/// UI : <-- build --> /// With this delay, if we're not lucky:
/// Raster: <-- rasterize randomly slow today --> /// ---------------------------------------------------------------
/// Gap : | 2 seconds or more | /// UI : <-- build -->
/// Driver: <-- screenshot --> /// Raster: <-- rasterize randomly slow today -->
/// /// Gap : | 2 seconds or more |
/// In practice, sometimes the device gets really busy for a while and /// Driver: <-- screenshot -->
/// even two seconds isn't enough, which means that this is still racy ///
/// and a source of flakes. /// In practice, sometimes the device gets really busy for a while and even
/// two seconds isn't enough, which means that this is still racy and a source
/// of flakes.
Future<List<int>> screenshot() async { Future<List<int>> screenshot() async {
throw UnimplementedError(); throw UnimplementedError();
} }
......
...@@ -305,10 +305,11 @@ class PackagesInteractiveGetCommand extends FlutterCommand { ...@@ -305,10 +305,11 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
List<String> rest = argResults.rest; List<String> rest = argResults.rest;
final bool isHelp = rest.contains('-h') || rest.contains('--help'); final bool isHelp = rest.contains('-h') || rest.contains('--help');
String target; String target;
if (rest.length == 1 && (rest[0].contains('/') || rest[0].contains(r'\'))) { if (rest.length == 1 && (rest.single.contains('/') || rest.single.contains(r'\'))) {
// HACK: Supporting flutter specific behavior where you can pass a // For historical reasons, if there is one argument to the command and it contains
// folder to the command. // a multiple-component path (i.e. contains a slash) then we use that to determine
target = findProjectRoot(globals.fs, rest[0]); // to which project we're applying the command.
target = findProjectRoot(globals.fs, rest.single);
rest = <String>[]; rest = <String>[];
} else { } else {
target = findProjectRoot(globals.fs); target = findProjectRoot(globals.fs);
......
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