More lints (#70500)
This commit is contained in:
parent
9a2bf0e70f
commit
6cff33832e
@ -83,7 +83,7 @@ linter:
|
|||||||
- avoid_returning_null_for_void
|
- avoid_returning_null_for_void
|
||||||
# - avoid_returning_this # there are plenty of valid reasons to return this
|
# - avoid_returning_this # there are plenty of valid reasons to return this
|
||||||
# - avoid_setters_without_getters # not yet tested
|
# - avoid_setters_without_getters # not yet tested
|
||||||
# - avoid_shadowing_type_parameters # not yet tested
|
- avoid_shadowing_type_parameters
|
||||||
- avoid_single_cascade_in_expression_statements
|
- avoid_single_cascade_in_expression_statements
|
||||||
- avoid_slow_async_io
|
- avoid_slow_async_io
|
||||||
# - avoid_type_to_string # we do this commonly
|
# - avoid_type_to_string # we do this commonly
|
||||||
@ -103,7 +103,7 @@ linter:
|
|||||||
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
|
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
|
||||||
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
|
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
|
||||||
- control_flow_in_finally
|
- control_flow_in_finally
|
||||||
# - curly_braces_in_flow_control_structures # not yet tested
|
# - curly_braces_in_flow_control_structures # not required by flutter style
|
||||||
# - diagnostic_describe_all_properties # not yet tested
|
# - diagnostic_describe_all_properties # not yet tested
|
||||||
- directives_ordering
|
- directives_ordering
|
||||||
# - do_not_use_environment # we do this commonly
|
# - do_not_use_environment # we do this commonly
|
||||||
@ -117,22 +117,22 @@ linter:
|
|||||||
- implementation_imports
|
- implementation_imports
|
||||||
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
|
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
|
||||||
- iterable_contains_unrelated_type
|
- iterable_contains_unrelated_type
|
||||||
# - join_return_with_assignment # not yet tested
|
# - join_return_with_assignment # not required by flutter style
|
||||||
- leading_newlines_in_multiline_strings
|
- leading_newlines_in_multiline_strings
|
||||||
- library_names
|
- library_names
|
||||||
- library_prefixes
|
- library_prefixes
|
||||||
# - lines_longer_than_80_chars # not yet tested
|
# - 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/sdk/issues/34181
|
||||||
# - missing_whitespace_between_adjacent_strings # not yet tested
|
# - missing_whitespace_between_adjacent_strings # not yet tested
|
||||||
- no_adjacent_strings_in_list
|
- no_adjacent_strings_in_list
|
||||||
# - no_default_cases # too many false positives
|
# - no_default_cases # too many false positives
|
||||||
- no_duplicate_case_values
|
- no_duplicate_case_values
|
||||||
# - no_logic_in_create_state # not yet tested
|
- no_logic_in_create_state
|
||||||
# - no_runtimeType_toString # not yet tested
|
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
|
||||||
- non_constant_identifier_names
|
- non_constant_identifier_names
|
||||||
- null_check_on_nullable_type_parameter
|
- null_check_on_nullable_type_parameter
|
||||||
# - null_closures # not yet tested
|
# - null_closures # not required by flutter style
|
||||||
# - omit_local_variable_types # opposite of always_specify_types
|
# - omit_local_variable_types # opposite of always_specify_types
|
||||||
# - one_member_abstracts # too many false positives
|
# - one_member_abstracts # too many false positives
|
||||||
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
|
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
|
||||||
@ -143,14 +143,14 @@ linter:
|
|||||||
# - parameter_assignments # we do this commonly
|
# - parameter_assignments # we do this commonly
|
||||||
- prefer_adjacent_string_concatenation
|
- prefer_adjacent_string_concatenation
|
||||||
- prefer_asserts_in_initializer_lists
|
- prefer_asserts_in_initializer_lists
|
||||||
# - prefer_asserts_with_message # not yet tested
|
# - prefer_asserts_with_message # not required by flutter style
|
||||||
- prefer_collection_literals
|
- prefer_collection_literals
|
||||||
- prefer_conditional_assignment
|
- prefer_conditional_assignment
|
||||||
- prefer_const_constructors
|
- prefer_const_constructors
|
||||||
- prefer_const_constructors_in_immutables
|
- prefer_const_constructors_in_immutables
|
||||||
- prefer_const_declarations
|
- prefer_const_declarations
|
||||||
- prefer_const_literals_to_create_immutables
|
- prefer_const_literals_to_create_immutables
|
||||||
# - prefer_constructors_over_static_methods # not yet tested
|
# - prefer_constructors_over_static_methods # far too many false positives
|
||||||
- prefer_contains
|
- prefer_contains
|
||||||
# - prefer_double_quotes # opposite of prefer_single_quotes
|
# - prefer_double_quotes # opposite of prefer_single_quotes
|
||||||
- prefer_equal_for_default_values
|
- prefer_equal_for_default_values
|
||||||
|
@ -12,34 +12,34 @@ enum FilterType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FilteredChildAnimationPage extends StatefulWidget {
|
class FilteredChildAnimationPage extends StatefulWidget {
|
||||||
const FilteredChildAnimationPage(
|
const FilteredChildAnimationPage(this.initialFilterType, [
|
||||||
this._filterType,
|
this.initialComplexChild = true,
|
||||||
[
|
this.initialUseRepaintBoundary = true,
|
||||||
this._complexChild = true,
|
]);
|
||||||
this._useRepaintBoundary = true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
final FilterType _filterType;
|
final FilterType initialFilterType;
|
||||||
final bool _complexChild;
|
final bool initialComplexChild;
|
||||||
final bool _useRepaintBoundary;
|
final bool initialUseRepaintBoundary;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_FilteredChildAnimationPageState createState() => _FilteredChildAnimationPageState(_filterType, _complexChild, _useRepaintBoundary);
|
_FilteredChildAnimationPageState createState() => _FilteredChildAnimationPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage> with SingleTickerProviderStateMixin {
|
class _FilteredChildAnimationPageState extends State<FilteredChildAnimationPage> with SingleTickerProviderStateMixin {
|
||||||
_FilteredChildAnimationPageState(this._filterType, this._complexChild, this._useRepaintBoundary);
|
|
||||||
|
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
bool _useRepaintBoundary;
|
|
||||||
bool _complexChild;
|
|
||||||
FilterType _filterType;
|
|
||||||
final GlobalKey _childKey = GlobalKey(debugLabel: 'child to animate');
|
final GlobalKey _childKey = GlobalKey(debugLabel: 'child to animate');
|
||||||
Offset _childCenter = Offset.zero;
|
Offset _childCenter = Offset.zero;
|
||||||
|
|
||||||
|
FilterType _filterType;
|
||||||
|
bool _complexChild;
|
||||||
|
bool _useRepaintBoundary;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_filterType = widget.initialFilterType;
|
||||||
|
_complexChild = widget.initialComplexChild;
|
||||||
|
_useRepaintBoundary = widget.initialUseRepaintBoundary;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
final RenderBox childBox = _childKey.currentContext.findRenderObject() as RenderBox;
|
final RenderBox childBox = _childKey.currentContext.findRenderObject() as RenderBox;
|
||||||
_childCenter = childBox.paintBounds.center;
|
_childCenter = childBox.paintBounds.center;
|
||||||
|
@ -528,11 +528,16 @@ class _WidgetBuildRecorderHost extends StatefulWidget {
|
|||||||
final WidgetBuildRecorder recorder;
|
final WidgetBuildRecorder recorder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() =>
|
State<StatefulWidget> createState() => _WidgetBuildRecorderHostState();
|
||||||
recorder._hostState = _WidgetBuildRecorderHostState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _WidgetBuildRecorderHostState extends State<_WidgetBuildRecorderHost> {
|
class _WidgetBuildRecorderHostState extends State<_WidgetBuildRecorderHost> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
widget.recorder._hostState = this;
|
||||||
|
}
|
||||||
|
|
||||||
// This is just to bypass the @protected on setState.
|
// This is just to bypass the @protected on setState.
|
||||||
void _setStateTrampoline() {
|
void _setStateTrampoline() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# Take our settings from the repo's main analysis_options.yaml file, but include
|
# Take our settings from the repo's main analysis_options.yaml file, and include
|
||||||
# an additional rule to validate that public members are documented.
|
# additional rules that are specific to production code.
|
||||||
|
|
||||||
include: ../analysis_options.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
- public_member_api_docs
|
- 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
|
||||||
|
@ -5,7 +5,4 @@ include: ../analysis_options.yaml
|
|||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
always_require_non_null_named_parameters: false # not needed with nnbd
|
always_require_non_null_named_parameters: false # not needed with nnbd
|
||||||
type_init_formals: false # https://github.com/dart-lang/linter/issues/2192
|
|
||||||
unrelated_type_equality_checks: false # https://github.com/dart-lang/linter/issues/2196
|
|
||||||
void_checks: false # https://github.com/dart-lang/linter/issues/2185
|
|
||||||
unnecessary_null_comparison: false # Turned off until null-safe rollout is complete.
|
unnecessary_null_comparison: false # Turned off until null-safe rollout is complete.
|
||||||
|
@ -369,7 +369,7 @@ class CupertinoDatePicker extends StatefulWidget {
|
|||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() { // ignore: no_logic_in_create_state, https://github.com/flutter/flutter/issues/70499
|
||||||
// The `time` mode and `dateAndTime` mode of the picker share the time
|
// The `time` mode and `dateAndTime` mode of the picker share the time
|
||||||
// columns, so they are placed together to one state.
|
// columns, so they are placed together to one state.
|
||||||
// The `date` mode has different children and is implemented in a different
|
// The `date` mode has different children and is implemented in a different
|
||||||
|
@ -136,7 +136,7 @@ class CupertinoSearchTextField extends StatefulWidget {
|
|||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
this.borderRadius,
|
this.borderRadius,
|
||||||
this.padding = const EdgeInsetsDirectional.fromSTEB(3.8, 8, 5, 8),
|
this.padding = const EdgeInsetsDirectional.fromSTEB(3.8, 8, 5, 8),
|
||||||
Color this.itemColor = CupertinoColors.secondaryLabel,
|
this.itemColor = CupertinoColors.secondaryLabel,
|
||||||
this.itemSize = 20.0,
|
this.itemSize = 20.0,
|
||||||
this.prefixInsets = const EdgeInsetsDirectional.fromSTEB(6, 0, 0, 4),
|
this.prefixInsets = const EdgeInsetsDirectional.fromSTEB(6, 0, 0, 4),
|
||||||
this.suffixInsets = const EdgeInsetsDirectional.fromSTEB(0, 0, 5, 2),
|
this.suffixInsets = const EdgeInsetsDirectional.fromSTEB(0, 0, 5, 2),
|
||||||
|
@ -375,7 +375,7 @@ class SystemMouseCursor extends MouseCursor {
|
|||||||
final String kind;
|
final String kind;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get debugDescription => '$runtimeType($kind)';
|
String get debugDescription => '${objectRuntimeType(this, 'SystemMouseCursor')}($kind)';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@protected
|
@protected
|
||||||
|
@ -936,7 +936,7 @@ abstract class StatefulWidget extends Widget {
|
|||||||
/// [State] objects.
|
/// [State] objects.
|
||||||
@protected
|
@protected
|
||||||
@factory
|
@factory
|
||||||
State createState();
|
State createState(); // ignore: no_logic_in_create_state, this is the original sin
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tracks the lifecycle of [State] objects when asserts are enabled.
|
/// Tracks the lifecycle of [State] objects when asserts are enabled.
|
||||||
|
@ -297,7 +297,7 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget {
|
|||||||
final VoidCallback? onEnd;
|
final VoidCallback? onEnd;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState();
|
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState(); // ignore: no_logic_in_create_state, https://github.com/dart-lang/linter/issues/2345
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
@ -28,7 +28,7 @@ abstract class UniqueWidget<T extends State<StatefulWidget>> extends StatefulWid
|
|||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
T createState();
|
T createState(); // ignore: no_logic_in_create_state, https://github.com/dart-lang/linter/issues/2345
|
||||||
|
|
||||||
/// The state for the unique inflated instance of this widget.
|
/// The state for the unique inflated instance of this widget.
|
||||||
///
|
///
|
||||||
|
@ -27,8 +27,9 @@ void main() {
|
|||||||
expect(await stream.single, equals(42));
|
expect(await stream.single, equals(42));
|
||||||
|
|
||||||
bool ranAction = false;
|
bool ranAction = false;
|
||||||
final Future<int> completeResult = future.whenComplete(() {
|
final Future<int> completeResult = future.whenComplete(() { // ignore: void_checks, https://github.com/dart-lang/linter/issues/1675
|
||||||
ranAction = true;
|
ranAction = true;
|
||||||
|
// verify that whenComplete does NOT propagate its return value:
|
||||||
return Future<int>.value(31);
|
return Future<int>.value(31);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ void main() {
|
|||||||
|
|
||||||
Object? exception;
|
Object? exception;
|
||||||
try {
|
try {
|
||||||
await future.whenComplete(() {
|
await future.whenComplete(() { // ignore: void_checks, https://github.com/dart-lang/linter/issues/1675
|
||||||
throw ArgumentError();
|
throw ArgumentError();
|
||||||
});
|
});
|
||||||
// Unreached.
|
// Unreached.
|
||||||
|
@ -24,7 +24,7 @@ class TestImageInfo implements ImageInfo {
|
|||||||
final int value;
|
final int value;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($value)';
|
String toString() => '${objectRuntimeType(this, 'TestImageInfo')}($value)';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TestImageInfo clone() {
|
TestImageInfo clone() {
|
||||||
@ -81,7 +81,7 @@ class TestImageProvider extends ImageProvider<int> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($key, $imageValue)';
|
String toString() => '${objectRuntimeType(this, 'TestImageProvider')}($key, $imageValue)';
|
||||||
}
|
}
|
||||||
|
|
||||||
class FailingTestImageProvider extends TestImageProvider {
|
class FailingTestImageProvider extends TestImageProvider {
|
||||||
|
@ -374,7 +374,7 @@ class TestAnimatedWidget extends StatefulWidget {
|
|||||||
final State<StatefulWidget> state;
|
final State<StatefulWidget> state;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => state;
|
State<StatefulWidget> createState() => state; // ignore: no_logic_in_create_state, this test predates the lint
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _TestAnimatedWidgetState extends State<TestAnimatedWidget> {
|
abstract class _TestAnimatedWidgetState extends State<TestAnimatedWidget> {
|
||||||
|
@ -29,8 +29,8 @@ class TestScrollPhysics extends ScrollPhysics {
|
|||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
return '$runtimeType($name)';
|
return '${objectRuntimeType(this, 'TestScrollPhysics')}($name)';
|
||||||
return '$runtimeType($name) -> $parent';
|
return '${objectRuntimeType(this, 'TestScrollPhysics')}($name) -> $parent';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ class TestSemantics {
|
|||||||
String toString([ int indentAmount = 0 ]) {
|
String toString([ int indentAmount = 0 ]) {
|
||||||
final String indent = ' ' * indentAmount;
|
final String indent = ' ' * indentAmount;
|
||||||
final StringBuffer buf = StringBuffer();
|
final StringBuffer buf = StringBuffer();
|
||||||
buf.writeln('$indent$runtimeType(');
|
buf.writeln('$indent${objectRuntimeType(this, 'TestSemantics')}(');
|
||||||
if (id != null)
|
if (id != null)
|
||||||
buf.writeln('$indent id: $id,');
|
buf.writeln('$indent id: $id,');
|
||||||
if (flags is int && flags != 0 || flags is List<SemanticsFlag> && (flags as List<SemanticsFlag>).isNotEmpty)
|
if (flags is int && flags != 0 || flags is List<SemanticsFlag> && (flags as List<SemanticsFlag>).isNotEmpty)
|
||||||
|
@ -114,7 +114,7 @@ class CyclicDiagnostic extends DiagnosticableTree {
|
|||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toStringShort() => '$runtimeType-$name';
|
String toStringShort() => '${objectRuntimeType(this, 'CyclicDiagnistic')}-$name';
|
||||||
|
|
||||||
// We have to override toString to avoid the toString call itself triggering a
|
// We have to override toString to avoid the toString call itself triggering a
|
||||||
// stack overflow.
|
// stack overflow.
|
||||||
|
@ -777,7 +777,7 @@ class DriverOffset {
|
|||||||
final double dy;
|
final double dy;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($dx, $dy)';
|
String toString() => '$runtimeType($dx, $dy)'; // ignore: no_runtimetype_tostring, can't access package:flutter here to use objectRuntimeType
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
|
@ -52,7 +52,7 @@ class SyncTestLocalizationsDelegate extends LocalizationsDelegate<TestLocalizati
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($prefix)';
|
String toString() => '${objectRuntimeType(this, 'SyncTestLocalizationsDelegate')}($prefix)';
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsyncTestLocalizationsDelegate extends LocalizationsDelegate<TestLocalizations> {
|
class AsyncTestLocalizationsDelegate extends LocalizationsDelegate<TestLocalizations> {
|
||||||
@ -74,7 +74,7 @@ class AsyncTestLocalizationsDelegate extends LocalizationsDelegate<TestLocalizat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => '$runtimeType($prefix)';
|
String toString() => '${objectRuntimeType(this, 'AsyncTestLocalizationsDelegate')}($prefix)';
|
||||||
}
|
}
|
||||||
|
|
||||||
class MoreLocalizations {
|
class MoreLocalizations {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user