Skip to content

Commit 475ffb9

Browse files
srawlinscommit-bot@chromium.org
authored andcommitted
Migrator: Use pedantic 1.9.0
Change-Id: Ia53e84ac6b2f3ab0679710c14453fd65c8f9c00d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163161 Reviewed-by: Mike Fairhurst <[email protected]> Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent ec4ccb7 commit 475ffb9

29 files changed

+3011
-2998
lines changed

pkg/nnbd_migration/analysis_options.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
include: package:pedantic/analysis_options.1.9.0.yaml
2+
13
analyzer:
4+
errors:
5+
# There are currently 175 violations.
6+
always_declare_return_types: ignore
7+
# There are currently 60 violations.
8+
annotate_overrides: ignore
9+
# There are currently 200 violations.
10+
omit_local_variable_types: ignore
11+
# There are currently 20 violations.
12+
unawaited_futures: ignore
13+
214
strong-mode:
315
implicit-casts: false
16+
417
linter:
518
rules:
619
- empty_constructor_bodies

pkg/nnbd_migration/lib/fix_reason_target.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:analyzer/src/generated/utilities_general.dart';
1010
/// is associated with each reason.
1111
abstract class FixReasonTarget {
1212
/// Fix reason target representing the full type, rather than a part of it.
13-
static const FixReasonTarget root = const _FixReasonTarget_Root();
13+
static const FixReasonTarget root = _FixReasonTarget_Root();
1414

1515
const FixReasonTarget._();
1616

pkg/nnbd_migration/lib/migration_cli.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ class MigrationCliRunner {
544544
NonNullableFix createNonNullableFix(
545545
DartFixListener listener,
546546
ResourceProvider resourceProvider,
547-
LineInfo getLineInfo(String path),
547+
LineInfo Function(String path) getLineInfo,
548548
Object bindAddress,
549549
{List<String> included = const <String>[],
550550
int preferredPort,

pkg/nnbd_migration/lib/src/decorated_type.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ class DecoratedType implements DecoratedTypeInfo {
158158
return DecoratedType(type, nullabilityNode, typeArguments: typeArguments);
159159
} else if (type is FunctionType) {
160160
if (typeArguments != null) {
161-
throw "Not supported: implicit function type with explicit type arguments";
161+
throw 'Not supported: implicit function type with explicit type '
162+
'arguments';
162163
}
163164
return DecoratedType.forImplicitFunction(
164165
typeProvider, type, nullabilityNode, graph, target);
@@ -184,7 +185,7 @@ class DecoratedType implements DecoratedTypeInfo {
184185
// [_decoratedTypeParameterBounds] so the type parameter needs to have an
185186
// enclosing element of `null`.
186187
assert(parameter.enclosingElement == null,
187-
"$parameter should not have parent ${parameter.enclosingElement}");
188+
'$parameter should not have parent ${parameter.enclosingElement}');
188189
}
189190

190191
/// If `this` represents an interface type, returns the substitution necessary
@@ -219,8 +220,8 @@ class DecoratedType implements DecoratedTypeInfo {
219220
@override
220221
bool operator ==(Object other) {
221222
if (other is DecoratedType) {
222-
if (!identical(this.node, other.node)) return false;
223-
var thisType = this.type;
223+
if (!identical(node, other.node)) return false;
224+
var thisType = type;
224225
var otherType = other.type;
225226
if (thisType is FunctionType && otherType is FunctionType) {
226227
if (thisType.normalParameterTypes.length !=
@@ -244,7 +245,7 @@ class DecoratedType implements DecoratedTypeInfo {
244245
return true;
245246
} else if (thisType is InterfaceType && otherType is InterfaceType) {
246247
if (thisType.element != otherType.element) return false;
247-
if (!_compareLists(this.typeArguments, other.typeArguments)) {
248+
if (!_compareLists(typeArguments, other.typeArguments)) {
248249
return false;
249250
}
250251
return true;

pkg/nnbd_migration/lib/src/edge_builder.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
211211

212212
final Set<PromotableElement> _lateHintedLocals = {};
213213

214-
Map<Token, HintComment> _nullCheckHints = {};
214+
final Map<Token, HintComment> _nullCheckHints = {};
215215

216216
EdgeBuilder(this.typeProvider, this._typeSystem, this._variables, this._graph,
217217
this.source, this.listener, this._decoratedClassHierarchy,
@@ -484,7 +484,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
484484
} else {
485485
var calleeType =
486486
getOrComputeElementType(callee, targetType: targetType);
487-
assert(calleeType.positionalParameters.length > 0); // TODO(paulberry)
487+
assert(calleeType.positionalParameters.isNotEmpty); // TODO(paulberry)
488488
_handleAssignment(rightOperand,
489489
destinationType: calleeType.positionalParameters[0]);
490490
return _fixNumericTypes(calleeType.returnType, node.staticType);
@@ -1728,7 +1728,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
17281728
var instantiatedType =
17291729
_variables.decoratedTypeAnnotation(source, typeName);
17301730
if (instantiatedType == null) {
1731-
throw new StateError('No type annotation for type name '
1731+
throw StateError('No type annotation for type name '
17321732
'${typeName.toSource()}, offset=${typeName.offset}');
17331733
}
17341734
var origin = InstantiateToBoundsOrigin(source, typeName);
@@ -2238,7 +2238,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
22382238
DecoratedType compoundOperatorType = getOrComputeElementType(
22392239
compoundOperatorMethod,
22402240
targetType: destinationType);
2241-
assert(compoundOperatorType.positionalParameters.length > 0);
2241+
assert(compoundOperatorType.positionalParameters.isNotEmpty);
22422242
_checkAssignment(edgeOrigin, FixReasonTarget.root,
22432243
source: sourceType,
22442244
destination: compoundOperatorType.positionalParameters[0],
@@ -2757,7 +2757,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
27572757
}
27582758
}
27592759
int i = 0;
2760-
var suppliedNamedParameters = Set<String>();
2760+
var suppliedNamedParameters = <String>{};
27612761
for (var argument in arguments) {
27622762
String name;
27632763
Expression expression;

pkg/nnbd_migration/lib/src/edit_plan.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class AtomicEdit {
9090
/// Optional argument [info] contains information about why the change was
9191
/// made.
9292
const AtomicEdit.insert(this.replacement,
93-
{this.info, this.isInformative: false})
93+
{this.info, this.isInformative = false})
9494
: assert(replacement.length > 0),
9595
assert(isInformative is bool),
9696
length = 0;
@@ -105,13 +105,13 @@ class AtomicEdit {
105105
isInformative = false;
106106

107107
/// Return `true` if this edit is a deletion (no characters added).
108-
bool get isDeletion => replacement.length == 0;
108+
bool get isDeletion => replacement.isEmpty;
109109

110110
/// Return `true` if this edit is an insertion (no characters removed).
111111
bool get isInsertion => length == 0;
112112

113113
/// Return `true` if this edit is a replacement.
114-
bool get isReplacement => length > 0 && replacement.length > 0;
114+
bool get isReplacement => length > 0 && replacement.isNotEmpty;
115115

116116
@override
117117
String toString() {

pkg/nnbd_migration/lib/src/front_end/info_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class InfoBuilder {
238238
var description = 'Non-nullability reason${target.suffix}';
239239
var step = node.whyNotNullable;
240240
if (step == null) {
241-
if (node != this.info.never) {
241+
if (node != info.never) {
242242
// 'never' indicates we're describing an edge to never, such as a `!`.
243243
traces.add(TraceInfo(description, [
244244
_nodeToTraceEntry(node,

0 commit comments

Comments
 (0)