From 15aa3bfda3658d1094ae50cc4c608fc94642405a Mon Sep 17 00:00:00 2001 From: Pierre-Louis <6655696+guidezpl@users.noreply.github.com> Date: Thu, 2 Jun 2022 09:25:40 +0000 Subject: [PATCH] turn on `curly_braces_in_flow_control_structures` for develop-facing code (#105113) --- analysis_options.yaml | 2 +- examples/api/analysis_options.yaml | 2 ++ packages/analysis_options.yaml | 1 + packages/flutter/lib/src/material/ink_sparkle.dart | 3 ++- packages/flutter/lib/src/material/material.dart | 3 ++- packages/flutter/lib/src/material/selection_area.dart | 3 ++- packages/flutter/lib/src/rendering/editable.dart | 3 ++- packages/flutter/lib/src/rendering/mouse_tracker.dart | 3 ++- packages/flutter/test/widgets/selectable_region_test.dart | 3 ++- 9 files changed, 16 insertions(+), 7 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index fd80e4b7cb..c884b4afff 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -98,7 +98,7 @@ linter: # - conditional_uri_does_not_exist # not yet tested # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 - 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, but developer-facing code should have this on - depend_on_referenced_packages - deprecated_consistency # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib) diff --git a/examples/api/analysis_options.yaml b/examples/api/analysis_options.yaml index 76be938a6b..0b0b77874b 100644 --- a/examples/api/analysis_options.yaml +++ b/examples/api/analysis_options.yaml @@ -4,5 +4,7 @@ include: ../../analysis_options.yaml linter: rules: + # Developer-facing code + curly_braces_in_flow_control_structures: true # Samples want to print things pretty often. avoid_print: false diff --git a/packages/analysis_options.yaml b/packages/analysis_options.yaml index 3f0e82867e..e2f23b14f0 100644 --- a/packages/analysis_options.yaml +++ b/packages/analysis_options.yaml @@ -5,5 +5,6 @@ include: ../analysis_options.yaml linter: rules: + - curly_braces_in_flow_control_structures # Developer-facing code - public_member_api_docs # see https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#documentation-dartdocs-javadocs-etc - no_runtimeType_toString # use objectRuntimeType from package:foundation diff --git a/packages/flutter/lib/src/material/ink_sparkle.dart b/packages/flutter/lib/src/material/ink_sparkle.dart index 2fe42dc8c4..0367260397 100644 --- a/packages/flutter/lib/src/material/ink_sparkle.dart +++ b/packages/flutter/lib/src/material/ink_sparkle.dart @@ -212,8 +212,9 @@ class InkSparkle extends InteractiveInkFeature { } void _handleStatusChanged(AnimationStatus status) { - if (status == AnimationStatus.completed) + if (status == AnimationStatus.completed) { dispose(); + } } static const Duration _animationDuration = Duration(milliseconds: 617); diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index 83b91931d4..f3ffb8b1a0 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -561,8 +561,9 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController @visibleForTesting List? get debugInkFeatures { - if (kDebugMode) + if (kDebugMode) { return _inkFeatures; + } return null; } List? _inkFeatures; diff --git a/packages/flutter/lib/src/material/selection_area.dart b/packages/flutter/lib/src/material/selection_area.dart index c75c1f824f..ba49cfdd5c 100644 --- a/packages/flutter/lib/src/material/selection_area.dart +++ b/packages/flutter/lib/src/material/selection_area.dart @@ -56,8 +56,9 @@ class SelectionArea extends StatefulWidget { class _SelectionAreaState extends State { FocusNode get _effectiveFocusNode { - if (widget.focusNode != null) + if (widget.focusNode != null) { return widget.focusNode!; + } _internalNode ??= FocusNode(); return _internalNode!; } diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index f6a1886059..8eb0dfd020 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -3054,10 +3054,11 @@ class _CompositeRenderEditablePainter extends RenderEditablePainter { final Iterator oldPainters = oldDelegate.painters.iterator; final Iterator newPainters = painters.iterator; - while (oldPainters.moveNext() && newPainters.moveNext()) + while (oldPainters.moveNext() && newPainters.moveNext()) { if (newPainters.current.shouldRepaint(oldPainters.current)) { return true; } + } return false; } diff --git a/packages/flutter/lib/src/rendering/mouse_tracker.dart b/packages/flutter/lib/src/rendering/mouse_tracker.dart index 26629feef4..1bdd60c3d0 100644 --- a/packages/flutter/lib/src/rendering/mouse_tracker.dart +++ b/packages/flutter/lib/src/rendering/mouse_tracker.dart @@ -408,10 +408,11 @@ class MouseTracker extends ChangeNotifier { // hit-test order. final PointerExitEvent baseExitEvent = PointerExitEvent.fromMouseEvent(latestEvent); lastAnnotations.forEach((MouseTrackerAnnotation annotation, Matrix4 transform) { - if (!nextAnnotations.containsKey(annotation)) + if (!nextAnnotations.containsKey(annotation)) { if (annotation.validForMouseTracker && annotation.onExit != null) { annotation.onExit!(baseExitEvent.transformed(lastAnnotations[annotation])); } + } }); // Send enter events to annotations that are not in last but in next, in diff --git a/packages/flutter/test/widgets/selectable_region_test.dart b/packages/flutter/test/widgets/selectable_region_test.dart index ab3c47cc9a..e8ebaaa406 100644 --- a/packages/flutter/test/widgets/selectable_region_test.dart +++ b/packages/flutter/test/widgets/selectable_region_test.dart @@ -1292,8 +1292,9 @@ class RenderSelectAll extends RenderProxyBox ), ); set value(SelectionGeometry other) { - if (other == _value) + if (other == _value) { return; + } _value = other; for (final VoidCallback callback in listeners) { callback();