Skip to content

Commit ec459a5

Browse files
Hixiegspencergoog
authored andcommitted
Taboo the word "simply" from our API documentation. (flutter#116061)
1 parent 59705bc commit ec459a5

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

Lines changed: 12 additions & 12 deletions
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

Lines changed: 30 additions & 5 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 13 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 9 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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);

0 commit comments

Comments
 (0)