Skip to content

Commit 2e4224e

Browse files
[ci] Enable no_runtimeType_toString (#3129)
Enables the `no_runtimeType_toString` analysis option. This isn't part of the base flutter/flutter analysis options, but is set in flutter/packages which this repo better corresponds to. This is already enabled in flutter/plugins, and is being enabled here as part of aligning their options. Part of flutter/flutter#113764
1 parent 2d48415 commit 2e4224e

File tree

14 files changed

+29
-16
lines changed

14 files changed

+29
-16
lines changed

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ linter:
115115
- no_leading_underscores_for_library_prefixes
116116
- no_leading_underscores_for_local_identifiers
117117
- no_logic_in_create_state
118-
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
118+
- no_runtimeType_toString # DIFFERENT FROM FLUTTER/FLUTTER
119119
- non_constant_identifier_names
120120
- noop_primitive_operations
121121
- null_check_on_nullable_type_parameter

packages/flutter_image/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.1.5
2+
3+
* Removes use of `runtimeType.toString()`.
4+
15
## 4.1.4
26

37
* Ignores lint warnings from new changes in Flutter master.

packages/flutter_image/lib/network.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ class NetworkImageWithRetry extends ImageProvider<NetworkImageWithRetry> {
214214
FlutterError.onError!(FlutterErrorDetails(
215215
exception: lastFailure!,
216216
library: 'package:flutter_image',
217-
context:
218-
ErrorDescription('$runtimeType failed to load ${instructions.uri}'),
217+
context: ErrorDescription(
218+
'${objectRuntimeType(this, 'NetworkImageWithRetry')} failed to load ${instructions.uri}'),
219219
));
220220
}
221221

@@ -236,7 +236,8 @@ class NetworkImageWithRetry extends ImageProvider<NetworkImageWithRetry> {
236236
int get hashCode => Object.hash(url, scale);
237237

238238
@override
239-
String toString() => '$runtimeType("$url", scale: $scale)';
239+
String toString() =>
240+
'${objectRuntimeType(this, 'NetworkImageWithRetry')}("$url", scale: $scale)';
240241
}
241242

242243
/// This function is called to get [FetchInstructions] to fetch an image.
@@ -295,7 +296,7 @@ class FetchInstructions {
295296

296297
@override
297298
String toString() {
298-
return '$runtimeType(\n'
299+
return '${objectRuntimeType(this, 'FetchInstructions')}(\n'
299300
' shouldGiveUp: $shouldGiveUp\n'
300301
' timeout: $timeout\n'
301302
' uri: $uri\n'
@@ -332,7 +333,7 @@ class FetchFailure implements Exception {
332333

333334
@override
334335
String toString() {
335-
return '$runtimeType(\n'
336+
return '${objectRuntimeType(this, 'FetchFailure')}(\n'
336337
' attemptCount: $attemptCount\n'
337338
' httpStatusCode: $httpStatusCode\n'
338339
' totalDuration: $totalDuration\n'

packages/flutter_image/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >
33
Image utilities for Flutter: improved network providers, effects, etc.
44
repository: https://github.com/flutter/packages/tree/main/packages/flutter_image
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_image%22
6-
version: 4.1.4
6+
version: 4.1.5
77

88
environment:
99
sdk: ">=2.12.0 <3.0.0"

packages/flutter_migrate/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.1+2
2+
3+
* Removes use of `runtimeType.toString()`.
4+
15
## 0.0.1+1
26

37
* Updates code to fix strict-cast violations.

packages/flutter_migrate/lib/src/base/terminal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class OutputPreferences {
7272

7373
@override
7474
String toString() {
75-
return '$runtimeType[wrapText: $wrapText, wrapColumn: $wrapColumn, showColor: $showColor]';
75+
return 'OutputPreferences[wrapText: $wrapText, wrapColumn: $wrapColumn, showColor: $showColor]';
7676
}
7777
}
7878

packages/flutter_migrate/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_migrate
22
description: A tool to migrate legacy flutter projects to modern versions.
3-
version: 0.0.1+1
3+
version: 0.0.1+2
44
repository: https://github.com/flutter/packages/tree/main/packages/flutter_migrate
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Ap%3A%20flutter_migrate
66
publish_to: none

packages/flutter_migrate/test/src/fakes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class FakeStopwatch implements Stopwatch {
265265
}
266266

267267
@override
268-
String toString() => '$runtimeType $elapsed $isRunning';
268+
String toString() => 'FakeStopwatch $elapsed $isRunning';
269269
}
270270

271271
class FakeStopwatchFactory implements StopwatchFactory {

packages/multicast_dns/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.3.2+3
22

3+
* Removes use of `runtimeType.toString()`.
34
* Updates minimum SDK version to Flutter 3.0.
45

56
## 0.3.2+2

packages/multicast_dns/lib/src/resource_record.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class ResourceRecordQuery {
167167

168168
@override
169169
String toString() =>
170-
'$runtimeType{$fullyQualifiedName, type: ${ResourceRecordType.toDebugString(resourceRecordType)}, isMulticast: $isMulticast}';
170+
'ResourceRecordQuery{$fullyQualifiedName, type: ${ResourceRecordType.toDebugString(resourceRecordType)}, isMulticast: $isMulticast}';
171171
}
172172

173173
/// Base implementation of DNS resource records (RRs).

packages/multicast_dns/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: multicast_dns
22
description: Dart package for performing mDNS queries (e.g. Bonjour, Avahi).
33
repository: https://github.com/flutter/packages/tree/main/packages/multicast_dns
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+multicast_dns%22
5-
version: 0.3.2+2
5+
version: 0.3.2+3
66

77
environment:
88
sdk: ">=2.17.0 <3.0.0"

packages/rfw/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 1.0.8
22

3+
* Removes use of `runtimeType.toString()`.
34
* Updates code to fix strict-cast violations.
45

56
## 1.0.7

packages/rfw/lib/src/flutter/content.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import 'dart:async';
88
import 'dart:convert';
99

10+
import 'package:flutter/foundation.dart' show objectRuntimeType;
11+
1012
import '../dart/model.dart';
1113

1214
/// Signature for the callback passed to [DynamicContent.subscribe].
@@ -188,7 +190,7 @@ class DynamicContent {
188190
}
189191

190192
@override
191-
String toString() => '$runtimeType($_root)';
193+
String toString() => '${objectRuntimeType(this, 'DynamicContent')}($_root)';
192194
}
193195

194196
// Node in the [DynamicContent] tree. This should contain no [BlobNode]s.

packages/rfw/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: rfw
22
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
33
repository: https://github.com/flutter/packages/tree/main/packages/rfw
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22
5-
version: 1.0.7
5+
version: 1.0.8
66

77
environment:
88
sdk: ">=2.13.0 <3.0.0"

0 commit comments

Comments
 (0)