Clean up ignores that are not ignoring anything (#78484)

This commit is contained in:
Michael Goderbauer 2021-03-18 13:40:08 -07:00 committed by GitHub
parent 51dbc768d8
commit efbde443d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 50 additions and 106 deletions

View file

@ -1304,7 +1304,6 @@ class ElasticInOutCurve extends Curve {
class Curves {
// This class is not meant to be instatiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
Curves._();
/// A linear animation curve.

View file

@ -20,7 +20,6 @@ import 'theme.dart';
class CupertinoColors {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
CupertinoColors._();
/// iOS 13's default blue color. Used to indicate active elements such as

View file

@ -33,7 +33,6 @@ import 'package:flutter/widgets.dart';
class CupertinoIcons {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
CupertinoIcons._();
/// The icon font used for Cupertino icons.

View file

@ -211,10 +211,7 @@ mixin CupertinoRouteTransitionMixin<T> on PageRoute<T> {
child: child,
);
assert(() {
// `child` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (child == null) { // ignore: dead_code
if (child == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The builder for route "${settings.name}" returned null.'),
ErrorDescription('Route builders must never return null.'),

View file

@ -358,8 +358,7 @@ class _CupertinoTextSelectionToolbarContent extends StatefulWidget {
required this.toolbarBuilder,
required this.children,
}) : assert(children != null),
// This ignore is used because .isNotEmpty isn't compatible with const.
assert(children.length > 0), // ignore: prefer_is_empty
assert(children.length > 0),
super(key: key);
final Offset anchor;

View file

@ -44,6 +44,4 @@ typedef _ComputeImpl = Future<R> Function<Q, R>(ComputeCallback<Q, R> callback,
///
/// The `debugLabel` argument can be specified to provide a name to add to the
/// [Timeline]. This is useful when profiling an application.
// Remove when https://github.com/dart-lang/sdk/issues/37149 is fixed.
// ignore: prefer_const_declarations
final _ComputeImpl compute = _isolates.compute;
const _ComputeImpl compute = _isolates.compute;

View file

@ -288,7 +288,6 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
class LicenseRegistry {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
LicenseRegistry._();
static List<LicenseEntryCollector>? _collectors;

View file

@ -13,7 +13,6 @@
class Unicode {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
Unicode._();
/// `U+202A LEFT-TO-RIGHT EMBEDDING`
///

View file

@ -35,7 +35,6 @@ int _synthesiseDownButtons(int buttons, PointerDeviceKind kind) {
class PointerEventConverter {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
PointerEventConverter._();
/// Expand the given packet of pointer data into a sequence of framework

View file

@ -62,7 +62,6 @@ const Icon _kDefaultDeleteIcon = Icon(Icons.cancel, size: _kDeleteIconSize);
abstract class ChipAttributes {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
ChipAttributes._();
/// The primary content of the chip.
@ -203,7 +202,6 @@ abstract class ChipAttributes {
abstract class DeletableChipAttributes {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
DeletableChipAttributes._();
/// The icon displayed when [onDeleted] is set.
@ -315,7 +313,6 @@ abstract class DeletableChipAttributes {
abstract class CheckmarkableChipAttributes {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
CheckmarkableChipAttributes._();
/// Whether or not to show a check mark when
@ -351,7 +348,6 @@ abstract class CheckmarkableChipAttributes {
abstract class SelectableChipAttributes {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
SelectableChipAttributes._();
/// Whether or not this chip is selected.
@ -462,7 +458,6 @@ abstract class SelectableChipAttributes {
abstract class DisabledChipAttributes {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
DisabledChipAttributes._();
/// Whether or not this chip is enabled for input.
@ -510,7 +505,6 @@ abstract class DisabledChipAttributes {
abstract class TappableChipAttributes {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
TappableChipAttributes._();
/// Called when the user taps the chip.

View file

@ -196,7 +196,6 @@ class MaterialAccentColor extends ColorSwatch<int> {
class Colors {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
Colors._();
/// Completely invisible.

View file

@ -13,7 +13,6 @@ import 'theme.dart';
class ElevationOverlay {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
ElevationOverlay._();
/// Applies an overlay color to a surface color to indicate

View file

@ -84,7 +84,6 @@ import 'theme.dart';
class Feedback {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
Feedback._();
/// Provides platform-specific feedback for a tap.

View file

@ -134,7 +134,6 @@ class _PlatformAdaptiveIcons {
class Icons {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
Icons._();
/// A set of platform-adaptive material design icons.

View file

@ -434,10 +434,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
));
return true;
}());
// `refreshResult` has a non-nullable type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (refreshResult == null) // ignore: dead_code
if (refreshResult == null)
return;
refreshResult.whenComplete(() {
if (mounted && _mode == _RefreshIndicatorMode.refresh) {

View file

@ -92,7 +92,7 @@ class NetworkImage
chunkCallback: (int bytes, int total) {
chunkEvents.add(ImageChunkEvent(
cumulativeBytesLoaded: bytes, expectedTotalBytes: total));
}) as Future<ui.Codec>; // ignore: undefined_function
}) as Future<ui.Codec>;
}
@override

View file

@ -674,10 +674,7 @@ abstract class AssetBundleImageProvider extends ImageProvider<AssetBundleImageKe
PaintingBinding.instance!.imageCache!.evict(key);
rethrow;
}
// `key.bundle.load` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (data == null) { // ignore: dead_code
if (data == null) {
PaintingBinding.instance!.imageCache!.evict(key);
throw StateError('Unable to read data');
}

View file

@ -14,7 +14,6 @@ import 'basic_types.dart';
class MatrixUtils {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
MatrixUtils._();
/// Returns the given [transform] matrix as an [Offset], if the matrix is

View file

@ -343,10 +343,7 @@ class TextSpan extends InlineSpan {
assert(() {
if (children != null) {
for (final InlineSpan child in children!) {
// `child` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (child == null) { // ignore: dead_code
if (child == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('TextSpan contains a null child.'),
ErrorDescription(
@ -459,7 +456,7 @@ class TextSpan extends InlineSpan {
// warning that the null-handling logic is dead code).
if (child != null) {
return child.toDiagnosticsNode();
} else { // ignore: dead_code
} else {
return DiagnosticsNode.message('<null child>');
}
}).toList();

View file

@ -1398,10 +1398,7 @@ abstract class RenderBox extends RenderObject {
@mustCallSuper
double getMinIntrinsicWidth(double height) {
assert(() {
// `height` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (height == null) { // ignore: dead_code
if (height == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The height argument to getMinIntrinsicWidth was null.'),
ErrorDescription('The argument to getMinIntrinsicWidth must not be negative or null.'),
@ -1550,10 +1547,7 @@ abstract class RenderBox extends RenderObject {
@mustCallSuper
double getMaxIntrinsicWidth(double height) {
assert(() {
// `height` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (height == null) { // ignore: dead_code
if (height == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The height argument to getMaxIntrinsicWidth was null.'),
ErrorDescription('The argument to getMaxIntrinsicWidth must not be negative or null.'),
@ -1636,10 +1630,7 @@ abstract class RenderBox extends RenderObject {
@mustCallSuper
double getMinIntrinsicHeight(double width) {
assert(() {
// `width` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (width == null) { // ignore: dead_code
if (width == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The width argument to getMinIntrinsicHeight was null.'),
ErrorDescription('The argument to getMinIntrinsicHeight must not be negative or null.'),
@ -1721,10 +1712,7 @@ abstract class RenderBox extends RenderObject {
@mustCallSuper
double getMaxIntrinsicHeight(double width) {
assert(() {
// `width` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (width == null) { // ignore: dead_code
if (width == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('The width argument to getMaxIntrinsicHeight was null.'),
ErrorDescription('The argument to getMaxIntrinsicHeight must not be negative or null.'),

View file

@ -187,10 +187,7 @@ abstract class MultiChildLayoutDelegate {
'There is no child with the id "$childId".'
);
}
// `offset` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (offset == null) { // ignore: dead_code
if (offset == null) {
throw FlutterError(
'The $this custom multichild layout delegate provided a null position for the child with id "$childId".'
);

View file

@ -1499,10 +1499,7 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
assert(clipBehavior != Clip.none),
_borderRadius = borderRadius,
super(child: child, clipper: clipper, clipBehavior: clipBehavior) {
// `_borderRadius` has a non-nullable return type, but might be null when
// running with weak checking, so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
assert(_borderRadius != null || clipper != null);// ignore: dead_code
assert(_borderRadius != null || clipper != null);
}
/// The border radius of the rounded corners.

View file

@ -32,7 +32,6 @@ enum CacheExtentStyle {
abstract class RenderAbstractViewport extends RenderObject {
// This class is intended to be used as an interface, and should not be
// extended directly; this constructor prevents instantiation and extension.
// ignore: unused_element
factory RenderAbstractViewport._() => throw Error();
/// Returns the [RenderAbstractViewport] that most tightly encloses the given

View file

@ -20,7 +20,6 @@ import 'semantics_event.dart' show AnnounceSemanticsEvent, TooltipSemanticsEvent
class SemanticsService {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
SemanticsService._();
/// Sends a semantic announcement.

View file

@ -66,11 +66,8 @@ abstract class AssetBundle {
/// implementation.)
Future<String> loadString(String key, { bool cache = true }) async {
final ByteData data = await load(key);
// Note: data has a non-nullable type, but might be null when running with
// weak checking, so we need to null check it anyway (and ignore the warning
// that the null-handling logic is dead code).
if (data == null)
throw FlutterError('Unable to load asset: $key'); // ignore: dead_code
throw FlutterError('Unable to load asset: $key');
// 50 KB of data should take 2-3 ms to parse on a Moto G4, and about 400 μs
// on a Pixel 4.
if (data.lengthInBytes < 50 * 1024) {

View file

@ -24,7 +24,6 @@ class ClipboardData {
class Clipboard {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
Clipboard._();
// Constants for common [getData] [format] types.

View file

@ -12,7 +12,6 @@ import 'system_channels.dart';
class HapticFeedback {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
HapticFeedback._();
/// Provides vibration haptic feedback to the user for a short duration.

View file

@ -11,7 +11,6 @@ import 'platform_channel.dart';
class SystemChannels {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
SystemChannels._();
/// A JSON [MethodChannel] for navigation.

View file

@ -219,7 +219,6 @@ List<String> _stringify(List<dynamic> list) => <String>[
class SystemChrome {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
SystemChrome._();
/// Specifies the set of orientations the application interface can

View file

@ -9,7 +9,6 @@ import 'system_channels.dart';
class SystemNavigator {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
SystemNavigator._();
/// Removes the topmost Flutter instance, presenting what was before

View file

@ -29,7 +29,6 @@ enum SystemSoundType {
class SystemSound {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
SystemSound._();
/// Play the specified system sound. If that sound is not present on the

View file

@ -1745,7 +1745,7 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {
assert(() {
for (int index = 0; index < children.length; index++) {
// TODO(a14n): remove this check to have a lot more const widget
if (children[index] == null) { // ignore: dead_code
if (children[index] == null) {
throw FlutterError(
"$runtimeType's children must not contain any null values, "
'but a null value was found at index $index'

View file

@ -5355,13 +5355,13 @@ abstract class _RestorationInformation {
final List<Object?> casted = data as List<Object?>;
assert(casted.isNotEmpty);
final _RouteRestorationType type = _RouteRestorationType.values[casted[0]! as int];
assert(type != null);
switch (type) {
case _RouteRestorationType.named:
return _NamedRestorationInformation.fromSerializableData(casted.sublist(1));
case _RouteRestorationType.anonymous:
return _AnonymousRestorationInformation.fromSerializableData(casted.sublist(1));
}
throw StateError('Invalid type: $type'); // ignore: dead_code
}
final _RouteRestorationType type;

View file

@ -1278,7 +1278,7 @@ class ListView extends BoxScrollView {
} else {
widget = separatorBuilder(context, itemIndex);
assert(() {
if (widget == null) { // ignore: dead_code
if (widget == null) {
throw FlutterError('separatorBuilder cannot return null.');
}
return true;

View file

@ -793,11 +793,13 @@ void main() {
for (final double textScaleFactor in textScaleFactorOptions) {
for (final TextDirection textDirection in textDirectionOptions) {
for (final Widget? icon in iconOptions) {
final String testName = 'ElevatedButton'
', text scale $textScaleFactor' // ignore: missing_whitespace_between_adjacent_strings, https://github.com/dart-lang/linter/issues/2489
'${icon != null ? ", with icon" : ""}'
'${textDirection == TextDirection.rtl ? ", RTL" : ""}';
final String testName = <String>[
'ElevatedButton, text scale $textScaleFactor',
if (icon != null)
'with icon',
if (textDirection == TextDirection.rtl)
'RTL',
].join(', ');
testWidgets(testName, (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(

View file

@ -1038,11 +1038,13 @@ void main() {
for (final double textScaleFactor in textScaleFactorOptions) {
for (final TextDirection textDirection in textDirectionOptions) {
for (final Widget? icon in iconOptions) {
final String testName = 'OutlinedButton'
', text scale $textScaleFactor' // ignore: missing_whitespace_between_adjacent_strings, https://github.com/dart-lang/linter/issues/2489
'${icon != null ? ", with icon" : ""}'
'${textDirection == TextDirection.rtl ? ", RTL" : ""}';
final String testName = <String>[
'OutlinedButton, text scale $textScaleFactor',
if (icon != null)
'with icon',
if (textDirection == TextDirection.rtl)
'RTL',
].join(', ');
testWidgets(testName, (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(

View file

@ -831,10 +831,13 @@ void main() {
for (final double textScaleFactor in textScaleFactorOptions) {
for (final TextDirection textDirection in textDirectionOptions) {
for (final Widget? icon in iconOptions) {
final String testName = 'TextButton'
', text scale $textScaleFactor' // ignore: missing_whitespace_between_adjacent_strings, https://github.com/dart-lang/linter/issues/2489
'${icon != null ? ", with icon" : ""}'
'${textDirection == TextDirection.rtl ? ", RTL" : ""}';
final String testName = <String>[
'TextButton, text scale $textScaleFactor',
if (icon != null)
'with icon',
if (textDirection == TextDirection.rtl)
'RTL',
].join(', ');
testWidgets(testName, (WidgetTester tester) async {
await tester.pumpWidget(

View file

@ -427,7 +427,7 @@ void _tests() {
);
// Ensure we preserve day period as we roll over.
final dynamic pickerState = tester.state(_timePickerDialog); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic pickerState = tester.state(_timePickerDialog);
expect(pickerState.selectedTime, const TimeOfDay(hour: 1, minute: 0));
await actAndExpect(
@ -492,7 +492,7 @@ void _tests() {
);
// Ensure we preserve hour period as we roll over.
final dynamic pickerState = tester.state(_timePickerDialog); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic pickerState = tester.state(_timePickerDialog);
expect(pickerState.selectedTime, const TimeOfDay(hour: 11, minute: 0));
await actAndExpect(

View file

@ -116,7 +116,7 @@ void main() {
// Use didPopRoute() to simulate the system back button. Check that
// didPopRoute() indicates that the notification was handled.
final dynamic widgetsAppState = tester.state(find.byType(WidgetsApp)); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic widgetsAppState = tester.state(find.byType(WidgetsApp));
expect(await widgetsAppState.didPopRoute(), isTrue);
expect(find.text('Sample Page'), findsOneWidget);

View file

@ -8,7 +8,6 @@ import 'dart:ui' as ui show Image;
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
// ignore: must_be_immutable
class TestImageInfo implements ImageInfo {
const TestImageInfo(this.value, { required this.image, this.scale = 1.0, this.debugLabel });

View file

@ -74,7 +74,7 @@ void main() {
),
),
);
final dynamic state = tester.state(find.byType(CupertinoDatePicker)); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic state = tester.state(find.byType(CupertinoDatePicker));
final Map<int, double> cache = state.estimatedColumnWidths as Map<int, double>;
expect(cache.isNotEmpty, isTrue);
const Map<String, dynamic> data = <String, dynamic>{
@ -100,7 +100,7 @@ void main() {
),
),
);
final dynamic state = tester.state(find.byType(CupertinoDatePicker)); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic state = tester.state(find.byType(CupertinoDatePicker));
final Map<int, double> cache = state.estimatedColumnWidths as Map<int, double>;
// Simulates font missing.
cache.clear();
@ -126,7 +126,7 @@ void main() {
),
),
);
final dynamic state = tester.state(find.byType(CupertinoTimerPicker)); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic state = tester.state(find.byType(CupertinoTimerPicker));
// Simulates wrong metrics due to font missing.
state.numberLabelWidth = 0.0;
state.numberLabelHeight = 0.0;

View file

@ -133,7 +133,7 @@ void main() {
test('basic structure', () async {
const TextInputType text = TextInputType.text;
const TextInputType number = TextInputType.number;
const TextInputType number2 = TextInputType.numberWithOptions(); // ignore: use_named_constants
const TextInputType number2 = TextInputType.numberWithOptions();
const TextInputType signed = TextInputType.numberWithOptions(signed: true);
const TextInputType signed2 = TextInputType.numberWithOptions(signed: true);
const TextInputType decimal = TextInputType.numberWithOptions(decimal: true);

View file

@ -908,7 +908,7 @@ class ButtonVariant extends TestVariant<int> {
const ButtonVariant({
required this.values,
required this.descriptions,
}) : assert(values.length != 0); // ignore: prefer_is_empty
}) : assert(values.length != 0);
@override
final List<int> values;

View file

@ -20,7 +20,7 @@ void main() {
],
child: const Text('loaded')
));
final dynamic state = tester.state(find.byType(Localizations)); // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic state = tester.state(find.byType(Localizations));
expect(state!.locale, isNull);
expect(find.text('loaded'), findsNothing);

View file

@ -1035,7 +1035,6 @@ void main() {
);
// By default, clipBehavior should be Clip.hardEdge
// ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic renderObject = tester.renderObject(find.byType(Overlay));
expect(renderObject.clipBehavior, equals(Clip.hardEdge));

View file

@ -50,7 +50,7 @@ void main() {
);
// 1st, check that the render object has received the default clip behavior.
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first;
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
// 2nd, height == widow.height test: check that the painting context does not call pushClipRect .
@ -104,7 +104,7 @@ void main() {
await tester.pumpWidget(SingleChildScrollView(child: Container(height: 2000.0)));
// 1st, check that the render object has received the default clip behavior.
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; // ignore: unnecessary_nullable_for_final_variable_declarations
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first;
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
// 2nd, check that the painting context has received the default clip behavior.