Skip to content

Commit 041f74e

Browse files
committed
Migrate to language 3.7, reformat, upgrade
1 parent a7fb7f2 commit 041f74e

File tree

354 files changed

+10667
-10861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

354 files changed

+10667
-10861
lines changed

analysis_options.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ linter:
2424
- no_runtimeType_toString
2525
- prefer_const_declarations
2626
- prefer_final_locals
27-
- require_trailing_commas
2827
- unawaited_futures
2928
- unreachable_from_main
3029
- use_enums

bin/dependency_services.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class _DependencyServicesCommandRunner extends CommandRunner<int>
4444
}
4545

4646
_DependencyServicesCommandRunner()
47-
: super(
48-
'dependency_services',
49-
'Support for automatic upgrades',
50-
usageLineLength: lineLength,
51-
) {
47+
: super(
48+
'dependency_services',
49+
'Support for automatic upgrades',
50+
usageLineLength: lineLength,
51+
) {
5252
argParser.addFlag(
5353
'verbose',
5454
abbr: 'v',

lib/src/ascii_tree.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ String fromFiles(
8282
}
8383
var directory = root;
8484
for (var part in parts) {
85-
directory = directory.putIfAbsent(part, () => <String, Map>{})
86-
as Map<String, Map>;
85+
directory =
86+
directory.putIfAbsent(part, () => <String, Map>{})
87+
as Map<String, Map>;
8788
}
8889
}
8990

lib/src/authentication/client.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ class _AuthenticatedClient extends http.BaseClient {
6969
if (response.headers.containsKey(HttpHeaders.wwwAuthenticateHeader)) {
7070
try {
7171
final header = response.headers[HttpHeaders.wwwAuthenticateHeader]!;
72-
final challenge =
73-
AuthenticationChallenge.parseHeader(header).firstWhereOrNull(
72+
final challenge = AuthenticationChallenge.parseHeader(
73+
header,
74+
).firstWhereOrNull(
7475
(challenge) =>
7576
challenge.scheme == 'bearer' &&
7677
challenge.parameters['realm'] == 'pub' &&

lib/src/authentication/credential.dart

+8-6
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ class Credential {
4646

4747
/// Create credential that stores clear text token.
4848
Credential.token(this.url, this.token)
49-
: env = null,
50-
unknownFields = const <String, dynamic>{};
49+
: env = null,
50+
unknownFields = const <String, dynamic>{};
5151

5252
/// Create credential that stores environment variable name that stores token
5353
/// value.
5454
Credential.env(this.url, this.env)
55-
: token = null,
56-
unknownFields = const <String, dynamic>{};
55+
: token = null,
56+
unknownFields = const <String, dynamic>{};
5757

5858
/// Deserialize [json] into [Credential] type.
5959
///
@@ -146,8 +146,10 @@ class Credential {
146146
tokenValue = token!;
147147
}
148148
if (!isValidBearerToken(tokenValue)) {
149-
dataError('Credential token for $url is not a valid Bearer token. '
150-
'It should match `^[a-zA-Z0-9._~+/=-]+\$`');
149+
dataError(
150+
'Credential token for $url is not a valid Bearer token. '
151+
'It should match `^[a-zA-Z0-9._~+/=-]+\$`',
152+
);
151153
}
152154

153155
return Future.value('Bearer $tokenValue');

lib/src/command.dart

+15-10
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ abstract class PubCommand extends Command<int> {
160160
/// Short description of how the arguments should be provided in `invocation`.
161161
///
162162
/// Override for giving a more detailed description.
163-
String get argumentsDescription => subcommands.isEmpty
164-
? '<subcommand> [arguments...]'
165-
: (takesArguments ? '[arguments...]' : '');
163+
String get argumentsDescription =>
164+
subcommands.isEmpty
165+
? '<subcommand> [arguments...]'
166+
: (takesArguments ? '[arguments...]' : '');
166167

167168
/// If not `null` this overrides the default exit-code [exit_codes.SUCCESS]
168169
/// when exiting successfully.
@@ -316,17 +317,20 @@ and attaching the relevant parts of that log file.
316317
if (!argResults.wasParsed('color')) {
317318
forceColors = ForceColorOption.auto;
318319
} else {
319-
forceColors = argResults.flag('color')
320-
? ForceColorOption.always
321-
: ForceColorOption.never;
320+
forceColors =
321+
argResults.flag('color')
322+
? ForceColorOption.always
323+
: ForceColorOption.never;
322324
}
323325
}
324326

325327
static void _computeCommand(ArgResults argResults) {
326328
final list = <String?>[];
327-
for (var command = argResults.command;
328-
command != null;
329-
command = command.command) {
329+
for (
330+
var command = argResults.command;
331+
command != null;
332+
command = command.command
333+
) {
330334
var commandName = command.name;
331335

332336
if (list.isEmpty) {
@@ -356,7 +360,8 @@ abstract class PubTopLevel {
356360
static void addColorFlag(ArgParser argParser) {
357361
argParser.addFlag(
358362
'color',
359-
help: 'Use colors in terminal output.\n'
363+
help:
364+
'Use colors in terminal output.\n'
360365
'Defaults to color when connected to a '
361366
'terminal, and no-color otherwise.',
362367
);

lib/src/command/add.dart

+66-54
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ For example (follow the same format including spaces):
106106
// To avoid breaking changes we keep supporting them, but hide them from
107107
// --help to discourage further use. Combining these with new syntax will
108108
// fail.
109-
argParser.addOption(
110-
'git-url',
111-
help: 'Git URL of the package',
112-
hide: true,
113-
);
109+
argParser.addOption('git-url', help: 'Git URL of the package', hide: true);
114110
argParser.addOption(
115111
'git-ref',
116112
help: 'Git branch or commit to be retrieved',
@@ -218,8 +214,10 @@ Specify multiple sdk packages with descriptors.''');
218214
);
219215
} on GitException {
220216
final name = updates.first.ref.name;
221-
dataError('Unable to resolve package "$name" with the given '
222-
'git parameters.');
217+
dataError(
218+
'Unable to resolve package "$name" with the given '
219+
'git parameters.',
220+
);
223221
} on SolveFailure catch (e) {
224222
dataError(e.message);
225223
} on WrappedException catch (e) {
@@ -231,18 +229,21 @@ Specify multiple sdk packages with descriptors.''');
231229
for (final update in updates) {
232230
final ref = update.ref;
233231
final name = ref.name;
234-
final resultPackage = solveResult.packages
235-
.firstWhere((packageId) => packageId.name == name);
232+
final resultPackage = solveResult.packages.firstWhere(
233+
(packageId) => packageId.name == name,
234+
);
236235

237236
/// Assert that [resultPackage] is within the original user's
238237
/// expectations.
239238
final constraint = update.constraint;
240239
if (constraint != null && !constraint.allows(resultPackage.version)) {
241240
final dependencyOverrides = resolutionPubspec.dependencyOverrides;
242241
if (dependencyOverrides.isNotEmpty) {
243-
dataError('"$name" resolved to "${resultPackage.version}" which '
244-
'does not satisfy constraint "$constraint". This could be '
245-
'caused by "dependency_overrides".');
242+
dataError(
243+
'"$name" resolved to "${resultPackage.version}" which '
244+
'does not satisfy constraint "$constraint". This could be '
245+
'caused by "dependency_overrides".',
246+
);
246247
}
247248
}
248249
}
@@ -294,8 +295,10 @@ Specify multiple sdk packages with descriptors.''');
294295
}
295296

296297
if (isOffline) {
297-
log.warning('Warning: Packages added when offline may not resolve to '
298-
'the latest compatible version available.');
298+
log.warning(
299+
'Warning: Packages added when offline may not resolve to '
300+
'the latest compatible version available.',
301+
);
299302
}
300303
}
301304

@@ -311,17 +314,21 @@ Specify multiple sdk packages with descriptors.''');
311314
final dependencyOverrides = [...original.dependencyOverrides.values];
312315

313316
final dependencyNames = dependencies.map((dependency) => dependency.name);
314-
final devDependencyNames =
315-
devDependencies.map((devDependency) => devDependency.name);
316-
final range =
317-
package.ref.withConstraint(package.constraint ?? VersionConstraint.any);
317+
final devDependencyNames = devDependencies.map(
318+
(devDependency) => devDependency.name,
319+
);
320+
final range = package.ref.withConstraint(
321+
package.constraint ?? VersionConstraint.any,
322+
);
318323

319324
if (package.isOverride) {
320325
dependencyOverrides.add(range);
321326
} else if (package.isDev) {
322327
if (devDependencyNames.contains(name)) {
323-
log.message('"$name" is already in "dev_dependencies". '
324-
'Will try to update the constraint.');
328+
log.message(
329+
'"$name" is already in "dev_dependencies". '
330+
'Will try to update the constraint.',
331+
);
325332
devDependencies.removeWhere((element) => element.name == name);
326333
}
327334

@@ -330,9 +337,11 @@ Specify multiple sdk packages with descriptors.''');
330337
/// remove the package from dependencies, since it might cause the user's
331338
/// code to break.
332339
if (dependencyNames.contains(name)) {
333-
dataError('"$name" is already in "dependencies". '
334-
'Use "pub remove $name" to remove it before adding it '
335-
'to "dev_dependencies"');
340+
dataError(
341+
'"$name" is already in "dependencies". '
342+
'Use "pub remove $name" to remove it before adding it '
343+
'to "dev_dependencies"',
344+
);
336345
}
337346

338347
devDependencies.add(range);
@@ -349,8 +358,10 @@ Specify multiple sdk packages with descriptors.''');
349358
/// dependencies, we remove the package from dev_dependencies, since it is
350359
/// now redundant.
351360
if (devDependencyNames.contains(name)) {
352-
log.message('"$name" was found in dev_dependencies. '
353-
'Removing "$name" and adding it to dependencies instead.');
361+
log.message(
362+
'"$name" was found in dev_dependencies. '
363+
'Removing "$name" and adding it to dependencies instead.',
364+
);
354365
devDependencies.removeWhere((element) => element.name == name);
355366
}
356367

@@ -394,9 +405,10 @@ Specify multiple sdk packages with descriptors.''');
394405
'The only allowed prefixes are "dev:" and "override:"',
395406
);
396407
} else {
397-
final packageName = match2.namedGroup('descriptor') == null
398-
? match2.namedGroup('prefix')
399-
: match2.namedGroup('name');
408+
final packageName =
409+
match2.namedGroup('descriptor') == null
410+
? match2.namedGroup('prefix')
411+
: match2.namedGroup('name');
400412
usageException('Not a valid package name: "$packageName"');
401413
}
402414
}
@@ -481,16 +493,18 @@ Specify multiple sdk packages with descriptors.''');
481493
['sdk'],
482494
];
483495

484-
for (final flag
485-
in conflictingFlagSets.expand((s) => s).where(argResults.wasParsed)) {
496+
for (final flag in conflictingFlagSets
497+
.expand((s) => s)
498+
.where(argResults.wasParsed)) {
486499
final conflictingFlag = conflictingFlagSets
487500
.where((s) => !s.contains(flag))
488501
.expand((s) => s)
489502
.firstWhereOrNull(argResults.wasParsed);
490503
if (conflictingFlag != null) {
491504
usageException(
492-
'Packages can only have one source, "pub add" flags "--$flag" and '
493-
'"--$conflictingFlag" are conflicting.');
505+
'Packages can only have one source, "pub add" flags "--$flag" and '
506+
'"--$conflictingFlag" are conflicting.',
507+
);
494508
}
495509
}
496510

@@ -632,12 +646,8 @@ Specify multiple sdk packages with descriptors.''');
632646
try {
633647
dummyPubspec = Pubspec.fromMap(
634648
{
635-
'dependencies': {
636-
packageName: parsedDescriptor,
637-
},
638-
'environment': {
639-
'sdk': sdk.version.toString(),
640-
},
649+
'dependencies': {packageName: parsedDescriptor},
650+
'environment': {'sdk': sdk.version.toString()},
641651
},
642652
cache.sources,
643653
// Resolve relative paths relative to current, not where the
@@ -654,7 +664,8 @@ Specify multiple sdk packages with descriptors.''');
654664
} else {
655665
ref = range.toRef();
656666
}
657-
final hasExplicitConstraint = parsedDescriptor is String ||
667+
final hasExplicitConstraint =
668+
parsedDescriptor is String ||
658669
(parsedDescriptor is Map &&
659670
parsedDescriptor.containsKey('version'));
660671
// If the descriptor has an explicit constraint, use that. Otherwise we
@@ -682,15 +693,17 @@ Specify multiple sdk packages with descriptors.''');
682693
List<PackageId> resultPackages,
683694
List<_ParseResult> updates,
684695
) {
685-
final yamlEditor =
686-
YamlEditor(readTextFile(entrypoint.workPackage.pubspecPath));
696+
final yamlEditor = YamlEditor(
697+
readTextFile(entrypoint.workPackage.pubspecPath),
698+
);
687699
log.io('Reading ${entrypoint.workPackage.pubspecPath}.');
688700
log.fine('Contents:\n$yamlEditor');
689701

690702
for (final update in updates) {
691-
final dependencyKey = update.isDev
692-
? 'dev_dependencies'
693-
: (update.isOverride ? 'dependency_overrides' : 'dependencies');
703+
final dependencyKey =
704+
update.isDev
705+
? 'dev_dependencies'
706+
: (update.isOverride ? 'dependency_overrides' : 'dependencies');
694707
final constraint = update.constraint;
695708
final ref = update.ref;
696709
final name = ref.name;
@@ -707,19 +720,17 @@ Specify multiple sdk packages with descriptors.''');
707720
entrypoint.workPackage,
708721
);
709722

710-
if (yamlEditor.parseAt(
711-
[dependencyKey],
712-
orElse: () => YamlScalar.wrap(null),
713-
).value ==
723+
if (yamlEditor.parseAt([
724+
dependencyKey,
725+
], orElse: () => YamlScalar.wrap(null)).value ==
714726
null) {
715727
// Handle the case where [dependencyKey] does not already exist.
716728
// We ensure it is in Block-style by default.
717729
yamlEditor.update(
718730
[dependencyKey],
719-
wrapAsYamlNode(
720-
{name: description},
721-
collectionStyle: CollectionStyle.BLOCK,
722-
),
731+
wrapAsYamlNode({
732+
name: description,
733+
}, collectionStyle: CollectionStyle.BLOCK),
723734
);
724735
} else {
725736
final packagePath = [dependencyKey, name];
@@ -731,8 +742,9 @@ Specify multiple sdk packages with descriptors.''');
731742
/// dependencies. Refer to [_addPackageToPubspec] for additional
732743
/// discussion.
733744
if (!update.isDev && !update.isOverride) {
734-
final devDependenciesNode = yamlEditor
735-
.parseAt(['dev_dependencies'], orElse: () => YamlScalar.wrap(null));
745+
final devDependenciesNode = yamlEditor.parseAt([
746+
'dev_dependencies',
747+
], orElse: () => YamlScalar.wrap(null));
736748

737749
if (devDependenciesNode is YamlMap &&
738750
devDependenciesNode.containsKey(name)) {

0 commit comments

Comments
 (0)