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

Commit 9fdb64b

Browse files
authored
Taboo the word "simply" from our API documentation. (#116061)
1 parent 1fc166a commit 9fdb64b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+180
-133
lines changed

dev/benchmarks/macrobenchmarks/lib/src/web/bench_image_decoding.dart

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import 'dart:ui' as ui;
88

99
import 'recorder.dart';
1010

11-
/// Measures the performance of image decoding.
12-
///
13-
/// The benchmark measures the decoding latency and not impact on jank. It
14-
/// cannot distinguish between blocking and non-blocking decoding. It simply
15-
/// measures the total time it takes to decode image frames. For example, the
16-
/// WASM codecs execute on the main thread and block the UI, leading to jank,
17-
/// but the browser's WebCodecs API is asynchronous running on a separate thread
18-
/// and does not jank. However, the benchmark result may be the same.
19-
///
20-
/// This benchmark does not support the HTML renderer because the HTML renderer
21-
/// cannot decode image frames (it always returns 1 dummy frame, even for
22-
/// animated images).
11+
// Measures the performance of image decoding.
12+
//
13+
// The benchmark measures the decoding latency and not impact on jank. It
14+
// cannot distinguish between blocking and non-blocking decoding. It naively
15+
// measures the total time it takes to decode image frames. For example, the
16+
// WASM codecs execute on the main thread and block the UI, leading to jank,
17+
// but the browser's WebCodecs API is asynchronous running on a separate thread
18+
// and does not jank. However, the benchmark result may be the same.
19+
//
20+
// This benchmark does not support the HTML renderer because the HTML renderer
21+
// cannot decode image frames (it always returns 1 dummy frame, even for
22+
// animated images).
2323
class BenchImageDecoding extends RawRecorder {
2424
BenchImageDecoding() : super(
2525
name: benchmarkName,

dev/bots/analyze.dart

+30-5
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ Future<void> run(List<String> arguments) async {
143143
printProgress('null initialized debug fields...');
144144
await verifyNullInitializedDebugExpensiveFields(flutterRoot);
145145

146+
printProgress('Taboo words...');
147+
await verifyTabooDocumentation(flutterRoot);
148+
146149
// Ensure that all package dependencies are in sync.
147150
printProgress('Package dependencies...');
148151
await runCommand(flutter, <String>['update-packages', '--verify-only'],
@@ -1815,18 +1818,17 @@ Future<void> verifyNullInitializedDebugExpensiveFields(String workingDirectory,
18151818
final List<String> errors = <String>[];
18161819
for (final File file in files) {
18171820
final List<String> lines = file.readAsLinesSync();
1818-
for (int i = 0; i < lines.length; i += 1) {
1819-
final String line = lines[i];
1821+
for (int index = 0; index < lines.length; index += 1) {
1822+
final String line = lines[index];
18201823
if (!line.contains(_kDebugOnlyAnnotation)) {
18211824
continue;
18221825
}
1823-
final String nextLine = lines[i + 1];
1826+
final String nextLine = lines[index + 1];
18241827
if (_nullInitializedField.firstMatch(nextLine) == null) {
1825-
errors.add('${file.path} L$i');
1828+
errors.add('${file.path}:$index');
18261829
}
18271830
}
18281831
}
1829-
18301832
if (errors.isNotEmpty) {
18311833
foundError(<String>[
18321834
'${bold}ERROR: ${red}fields annotated with @_debugOnly must null initialize.$reset',
@@ -1839,6 +1841,29 @@ Future<void> verifyNullInitializedDebugExpensiveFields(String workingDirectory,
18391841
}
18401842
}
18411843

1844+
final RegExp tabooPattern = RegExp(r'^ *///.*\b(simply)\b', caseSensitive: false);
1845+
1846+
Future<void> verifyTabooDocumentation(String workingDirectory, { int minimumMatches = 100 }) async {
1847+
final List<String> errors = <String>[];
1848+
await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) {
1849+
final List<String> lines = file.readAsLinesSync();
1850+
for (int index = 0; index < lines.length; index += 1) {
1851+
final String line = lines[index];
1852+
final Match? match = tabooPattern.firstMatch(line);
1853+
if (match != null) {
1854+
errors.add('${file.path}:${index + 1}: Found use of the taboo word "${match.group(1)}" in documentation string.');
1855+
}
1856+
}
1857+
}
1858+
if (errors.isNotEmpty) {
1859+
foundError(<String>[
1860+
'${bold}Avoid the word "simply" in documentation. See https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-the-passive-voice-recommend-do-not-require-never-say-things-are-simple for details.$reset',
1861+
'${bold}In many cases the word can be omitted without loss of generality; in other cases it may require a bit of rewording to avoid implying that the task is simple.$reset',
1862+
...errors,
1863+
]);
1864+
}
1865+
}
1866+
18421867
Future<CommandResult> _runFlutterAnalyze(String workingDirectory, {
18431868
List<String> options = const <String>[],
18441869
}) async {

dev/bots/test/analyze-test-input/root/packages/flutter/lib/bar.dart

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ class Foo {
1616
@_debugOnly
1717
final Map<String, String>? bar = kDebugMode ? null : <String, String>{};
1818
}
19+
20+
/// Simply avoid this
21+
/// and simply do that.

dev/bots/test/analyze_test.dart

+13-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,18 @@ void main() {
176176
minimumMatches: 1,
177177
), shouldHaveErrors: true);
178178

179-
expect(result, contains('L15'));
180-
expect(result, isNot(contains('L12')));
179+
expect(result, contains(':15'));
180+
expect(result, isNot(contains(':12')));
181+
});
182+
183+
test('analyze.dart - verifyTabooDocumentation', () async {
184+
final String result = await capture(() => verifyTabooDocumentation(
185+
testRootPath,
186+
minimumMatches: 1,
187+
), shouldHaveErrors: true);
188+
189+
expect(result, isNot(contains(':19')));
190+
expect(result, contains(':20'));
191+
expect(result, contains(':21'));
181192
});
182193
}

packages/flutter/lib/src/animation/animations.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ class ProxyAnimation extends Animation<double>
255255
/// If the parent animation is running forward from 0.0 to 1.0, this animation
256256
/// is running in reverse from 1.0 to 0.0.
257257
///
258-
/// Using a [ReverseAnimation] is different from simply using a [Tween] with a
259-
/// begin of 1.0 and an end of 0.0 because the tween does not change the status
258+
/// Using a [ReverseAnimation] is different from using a [Tween] with a
259+
/// `begin` of 1.0 and an `end` of 0.0 because the tween does not change the status
260260
/// or direction of the animation.
261261
///
262262
/// See also:

packages/flutter/lib/src/cupertino/context_menu.dart

+8-9
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ enum _ContextMenuLocation {
9999
/// [Expanded] widget so that it will grow to fill the Overlay if its size is
100100
/// unconstrained.
101101
///
102-
/// When closed, the CupertinoContextMenu simply displays the child as if the
103-
/// CupertinoContextMenu were not there. Sizing and positioning is unaffected.
102+
/// When closed, the [CupertinoContextMenu] displays the child as if the
103+
/// [CupertinoContextMenu] were not there. Sizing and positioning is unaffected.
104104
/// The menu can be closed like other [PopupRoute]s, such as by tapping the
105-
/// background or by calling `Navigator.pop(context)`. Unlike PopupRoute, it can
105+
/// background or by calling `Navigator.pop(context)`. Unlike [PopupRoute], it can
106106
/// also be closed by swiping downwards.
107107
///
108108
/// The [previewBuilder] parameter is most commonly used to display a slight
@@ -111,8 +111,8 @@ enum _ContextMenuLocation {
111111
/// Photos app on iOS.
112112
///
113113
/// {@tool dartpad}
114-
/// This sample shows a very simple CupertinoContextMenu for the Flutter logo.
115-
/// Simply long press on it to open.
114+
/// This sample shows a very simple [CupertinoContextMenu] for the Flutter logo.
115+
/// Long press on it to open.
116116
///
117117
/// ** See code in examples/api/lib/cupertino/context_menu/cupertino_context_menu.0.dart **
118118
/// {@end-tool}
@@ -256,10 +256,9 @@ class CupertinoContextMenu extends StatefulWidget {
256256
/// and when it is fully open. This will overwrite the default animation that
257257
/// matches the behavior of an iOS 16.0 context menu.
258258
///
259-
/// This builder can be used instead of the child when either the intended
260-
/// child has a property that would conflict with the default animation, like
261-
/// a border radius or a shadow, or if simply a more custom animation is
262-
/// needed.
259+
/// This builder can be used instead of the child when the intended child has
260+
/// a property that would conflict with the default animation, such as a
261+
/// border radius or a shadow, or if a more custom animation is needed.
263262
///
264263
/// In addition to the current [BuildContext], the function is also called
265264
/// with an [Animation]. The complete animation goes from 0 to 1 when

packages/flutter/lib/src/cupertino/scrollbar.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const double _kScrollbarCrossAxisMargin = 3.0;
2929

3030
/// An iOS style scrollbar.
3131
///
32-
/// To add a scrollbar to a [ScrollView], simply wrap the scroll view widget in
32+
/// To add a scrollbar to a [ScrollView], wrap the scroll view widget in
3333
/// a [CupertinoScrollbar] widget.
3434
///
3535
/// {@youtube 560 315 https://www.youtube.com/watch?v=DbkIQSvwnZc}

packages/flutter/lib/src/cupertino/text_form_field_row.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'text_field.dart';
1313
/// Creates a [CupertinoFormRow] containing a [FormField] that wraps
1414
/// a [CupertinoTextField].
1515
///
16-
/// A [Form] ancestor is not required. The [Form] simply makes it easier to
16+
/// A [Form] ancestor is not required. The [Form] allows one to
1717
/// save, reset, or validate multiple fields at once. To use without a [Form],
1818
/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to
1919
/// save or reset the form field.

packages/flutter/lib/src/foundation/assertions.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class RepetitiveStackFrameFilter extends StackFilter {
140140
/// The string to replace the frames with.
141141
///
142142
/// If the same replacement string is used multiple times in a row, the
143-
/// [FlutterError.defaultStackFilter] will simply update a counter after this
143+
/// [FlutterError.defaultStackFilter] will insert a repeat count after this
144144
/// line rather than repeating it.
145145
final String replacement;
146146

packages/flutter/lib/src/gestures/tap.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer
216216
if (_down != null) {
217217
// This happens when this tap gesture has been rejected while the pointer
218218
// is down (i.e. due to movement), when another allowed pointer is added,
219-
// in which case all pointers are simply ignored. The `_down` being null
219+
// in which case all pointers are ignored. The `_down` being null
220220
// means that _reset() has been called, since it is always set at the
221221
// first allowed down event and will not be cleared except for reset(),
222222
super.addAllowedPointer(event);

packages/flutter/lib/src/material/button_theme.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ButtonThemeData with Diagnosticable {
235235
/// Defaults to [ButtonBarLayoutBehavior.padded].
236236
final ButtonBarLayoutBehavior layoutBehavior;
237237

238-
/// Simply a convenience that returns [minWidth] and [height] as a
238+
/// Convenience that returns [minWidth] and [height] as a
239239
/// [BoxConstraints] object.
240240
BoxConstraints get constraints {
241241
return BoxConstraints(

packages/flutter/lib/src/material/dropdown.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
15301530
/// This is a convenience widget that wraps a [DropdownButton] widget in a
15311531
/// [FormField].
15321532
///
1533-
/// A [Form] ancestor is not required. The [Form] simply makes it easier to
1533+
/// A [Form] ancestor is not required. The [Form] allows one to
15341534
/// save, reset, or validate multiple fields at once. To use without a [Form],
15351535
/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to
15361536
/// save or reset the form field.

packages/flutter/lib/src/material/expansion_panel.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ class ExpansionPanelList extends StatefulWidget {
207207
/// is pressed. The arguments passed to the callback are the index of the
208208
/// pressed panel and whether the panel is currently expanded or not.
209209
///
210-
/// If ExpansionPanelList.radio is used, the callback may be called a
210+
/// If [ExpansionPanelList.radio] is used, the callback may be called a
211211
/// second time if a different panel was previously open. The arguments
212212
/// passed to the second callback are the index of the panel that will close
213213
/// and false, marking that it will be closed.
214214
///
215-
/// For ExpansionPanelList, the callback needs to setState when it's notified
215+
/// For [ExpansionPanelList], the callback needs to setState when it's notified
216216
/// about the closing/opening panel. On the other hand, the callback for
217-
/// ExpansionPanelList.radio is simply meant to inform the parent widget of
217+
/// [ExpansionPanelList.radio] is intended to inform the parent widget of
218218
/// changes, as the radio panels' open/close states are managed internally.
219219
///
220220
/// This callback is useful in order to keep track of the expanded/collapsed

packages/flutter/lib/src/material/menu_anchor.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,10 @@ class MenuController {
700700
/// platform instead of by Flutter (on macOS, for example).
701701
/// * [ShortcutRegistry], a registry of shortcuts that apply for the entire
702702
/// application.
703-
/// * [VoidCallbackIntent] to define intents that will call a [VoidCallback] and
703+
/// * [VoidCallbackIntent], to define intents that will call a [VoidCallback] and
704704
/// work with the [Actions] and [Shortcuts] system.
705-
/// * [CallbackShortcuts] to define shortcuts that simply call a callback and
706-
/// don't involve using [Actions].
705+
/// * [CallbackShortcuts], to define shortcuts that call a callback without
706+
/// involving [Actions].
707707
class MenuBar extends StatelessWidget {
708708
/// Creates a const [MenuBar].
709709
///
@@ -789,10 +789,10 @@ class MenuBar extends StatelessWidget {
789789
/// platform instead of by Flutter (on macOS, for example).
790790
/// * [ShortcutRegistry], a registry of shortcuts that apply for the entire
791791
/// application.
792-
/// * [VoidCallbackIntent] to define intents that will call a [VoidCallback] and
792+
/// * [VoidCallbackIntent], to define intents that will call a [VoidCallback] and
793793
/// work with the [Actions] and [Shortcuts] system.
794-
/// * [CallbackShortcuts] to define shortcuts that simply call a callback and
795-
/// don't involve using [Actions].
794+
/// * [CallbackShortcuts] to define shortcuts that call a callback without
795+
/// involving [Actions].
796796
class MenuItemButton extends StatefulWidget {
797797
/// Creates a const [MenuItemButton].
798798
///

packages/flutter/lib/src/material/snack_bar.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ enum SnackBarClosedReason {
7171

7272
/// A button for a [SnackBar], known as an "action".
7373
///
74-
/// Snack bar actions are always enabled. If you want to disable a snack bar
75-
/// action, simply don't include it in the snack bar.
74+
/// Snack bar actions are always enabled. Instead of disabling a snack bar
75+
/// action, avoid including it in the snack bar in the first place.
7676
///
7777
/// Snack bar actions can only be pressed once. Subsequent presses are ignored.
7878
///

packages/flutter/lib/src/material/text_form_field.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export 'package:flutter/services.dart' show SmartDashesType, SmartQuotesType;
1717
/// This is a convenience widget that wraps a [TextField] widget in a
1818
/// [FormField].
1919
///
20-
/// A [Form] ancestor is not required. The [Form] simply makes it easier to
20+
/// A [Form] ancestor is not required. The [Form] allows one to
2121
/// save, reset, or validate multiple fields at once. To use without a [Form],
2222
/// pass a `GlobalKey<FormFieldState>` (see [GlobalKey]) to the constructor and use
2323
/// [GlobalKey.currentState] to save or reset the form field.

packages/flutter/lib/src/painting/matrix_utils.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ class MatrixUtils {
455455
///
456456
/// The `radius` simulates the radius of the cylinder the plane is being
457457
/// wrapped onto. If the transformation is applied to a 0-dimensional dot
458-
/// instead of a plane, the dot would simply translate by +/- `radius` pixels
459-
/// along the `orientation` [Axis] when rotating from 0 to +/- 90 degrees.
458+
/// instead of a plane, the dot would translate by ± `radius` pixels
459+
/// along the `orientation` [Axis] when rotating from 0 to ±90 degrees.
460460
///
461461
/// A positive radius means the object is closest at 0 `angle` and a negative
462462
/// radius means the object is closest at π `angle` or 180 degrees.
@@ -478,7 +478,7 @@ class MatrixUtils {
478478
/// The `orientation` is the direction of the rotation axis.
479479
///
480480
/// Because the viewing position is a point, it's never possible to see the
481-
/// outer side of the cylinder at or past +/- π / 2 or 90 degrees and it's
481+
/// outer side of the cylinder at or past ±π/2 or 90 degrees and it's
482482
/// almost always possible to end up seeing the inner side of the cylinder
483483
/// or the back side of the transformed plane before π / 2 when perspective > 0.
484484
static Matrix4 createCylindricalProjectionTransform({

packages/flutter/lib/src/rendering/box.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ abstract class RenderBox extends RenderObject {
19361936
/// may depend on the baseline of a child (which is not available without
19371937
/// doing a full layout), it may be computed by a callback about which the
19381938
/// render object cannot reason, or the layout is so complex that it
1939-
/// is simply impractical to calculate the size in an efficient way.
1939+
/// is impractical to calculate the size in an efficient way.
19401940
///
19411941
/// In such cases, it may be impossible (or at least impractical) to actually
19421942
/// return a valid answer. In such cases, the function should call
@@ -1964,7 +1964,7 @@ abstract class RenderBox extends RenderObject {
19641964
/// When asserts are enabled and [debugCheckingIntrinsics] is not true, this
19651965
/// method will either throw the provided [FlutterError] or it will create and
19661966
/// throw a [FlutterError] with the provided `reason`. Otherwise, it will
1967-
/// simply return true.
1967+
/// return true.
19681968
///
19691969
/// One of the arguments has to be provided.
19701970
///

packages/flutter/lib/src/rendering/flow.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ class FlowParentData extends ContainerBoxParentData<RenderBox> {
159159
///
160160
/// Rather than positioning the children during layout, the children are
161161
/// positioned using transformation matrices during the paint phase using the
162-
/// matrices from the [FlowDelegate.paintChildren] function. The children can be
163-
/// repositioned efficiently by simply repainting the flow.
162+
/// matrices from the [FlowDelegate.paintChildren] function. The children are thus
163+
/// repositioned efficiently by repainting the flow, skipping layout.
164164
///
165165
/// The most efficient way to trigger a repaint of the flow is to supply a
166166
/// repaint argument to the constructor of the [FlowDelegate]. The flow will

packages/flutter/lib/src/rendering/layer.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
546546
/// should search for annotations, or if the layer has its own annotations to
547547
/// add.
548548
///
549-
/// The default implementation simply returns `false`, which means neither
549+
/// The default implementation always returns `false`, which means neither
550550
/// the layer nor its children has annotations, and the annotation search
551551
/// is not absorbed either (see below for explanation).
552552
///
@@ -602,7 +602,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
602602
///
603603
/// Returns null if no matching annotations are found.
604604
///
605-
/// By default this method simply calls [findAnnotations] with `onlyFirst:
605+
/// By default this method calls [findAnnotations] with `onlyFirst:
606606
/// true` and returns the annotation of the first result. Prefer overriding
607607
/// [findAnnotations] instead of this method, because during an annotation
608608
/// search, only [findAnnotations] is recursively called, while custom
@@ -628,7 +628,7 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin {
628628
///
629629
/// Returns a result with empty entries if no matching annotations are found.
630630
///
631-
/// By default this method simply calls [findAnnotations] with `onlyFirst:
631+
/// By default this method calls [findAnnotations] with `onlyFirst:
632632
/// false` and returns the annotations of its result. Prefer overriding
633633
/// [findAnnotations] instead of this method, because during an annotation
634634
/// search, only [findAnnotations] is recursively called, while custom

packages/flutter/lib/src/rendering/mouse_tracker.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ class MouseTracker extends ChangeNotifier {
302302
/// [MouseTracker] filter which to react to.
303303
///
304304
/// The `getResult` is a function to return the hit test result at the
305-
/// position of the event. It should not simply return cached hit test
306-
/// result, because the cache does not change throughout a tap sequence.
305+
/// position of the event. It should not return a cached hit test
306+
/// result, because the cache would not change during a tap sequence.
307307
void updateWithEvent(PointerEvent event, ValueGetter<HitTestResult> getResult) {
308308
if (event.kind != PointerDeviceKind.mouse) {
309309
return;

0 commit comments

Comments
 (0)