Skip to content

Commit

Permalink
Adhere to lines_longer_than_80_chars lint (#4340)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Aug 28, 2024
1 parent 8a3d088 commit d86e3c9
Show file tree
Hide file tree
Showing 108 changed files with 657 additions and 438 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
errors:
lines_longer_than_80_chars: ignore # TODO(mosum): fix the offending lines
todo: ignore
exclude:
- lib/src/third_party/**
Expand Down
4 changes: 2 additions & 2 deletions lib/src/authentication/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class _AuthenticatedClient extends http.BaseClient {
/// Constructs Http client wrapper that injects `authorization` header to
/// requests and handles authentication errors.
///
/// [_credential] might be `null`. In that case `authorization` header will not
/// be injected to requests.
/// [_credential] might be `null`. In that case `authorization` header will
/// not be injected to requests.
_AuthenticatedClient(this._inner, this._credential);

final http.BaseClient _inner;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/authentication/credential.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ class Credential {
/// Environment variable name that stores token value
final String? env;

/// Unknown fields found in pub-tokens.json. The fields might be created by the
/// future version of pub tool. We don't want to override them when using the
/// old SDK.
/// Unknown fields found in pub-tokens.json. The fields might be created by
/// the future version of pub tool. We don't want to override them when using
/// the old SDK.
final Map<String, dynamic> unknownFields;

/// Serializes [Credential] into json format.
Expand Down
3 changes: 2 additions & 1 deletion lib/src/command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ and attaching the relevant parts of that log file.
}
log.dumpTranscriptToFile(
transcriptPath,
'dart pub ${_topCommand.argResults!.arguments.map(protectArgument).join(' ')}',
'dart pub '
'${_topCommand.argResults!.arguments.map(protectArgument).join(' ')}',
e,
);

Expand Down
24 changes: 16 additions & 8 deletions lib/src/command/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ For example:
hide: true,
);

// Following options are hidden/deprecated in favor of the new syntax: [dev:]<package>[:descriptor] ...
// To avoid breaking changes we keep supporting them, but hide them from --help to discourage
// further use. Combining these with new syntax will fail.
// Following options are hidden/deprecated in favor of the new syntax:
// [dev:]<package>[:descriptor] ...
//
// To avoid breaking changes we keep supporting them, but hide them from
// --help to discourage further use. Combining these with new syntax will
// fail.
argParser.addOption(
'git-url',
help: 'Git URL of the package',
Expand Down Expand Up @@ -229,7 +232,8 @@ Specify multiple sdk packages with descriptors.''');
final resultPackage = solveResult.packages
.firstWhere((packageId) => packageId.name == name);

/// Assert that [resultPackage] is within the original user's expectations.
/// Assert that [resultPackage] is within the original user's
/// expectations.
final constraint = update.constraint;
if (constraint != null && !constraint.allows(resultPackage.version)) {
final dependencyOverrides = resolutionPubspec.dependencyOverrides;
Expand Down Expand Up @@ -333,7 +337,8 @@ Specify multiple sdk packages with descriptors.''');
} else {
if (dependencyNames.contains(name)) {
log.message(
'"$name" is already in "dependencies". Will try to update the constraint.',
'"$name" is already in "dependencies". '
'Will try to update the constraint.',
);
dependencies.removeWhere((element) => element.name == name);
}
Expand Down Expand Up @@ -503,7 +508,8 @@ Specify multiple sdk packages with descriptors.''');
}
if (couldParseAsNewStyle) {
usageException(
'--dev, --path, --sdk, --git-url, --git-path and --git-ref cannot be combined with a descriptor.',
'--dev, --path, --sdk, --git-url, --git-path and --git-ref '
'cannot be combined with a descriptor.',
);
} else {
usageException('Invalid version constraint: ${e.message}');
Expand Down Expand Up @@ -630,7 +636,8 @@ Specify multiple sdk packages with descriptors.''');
},
},
cache.sources,
// Resolve relative paths relative to current, not where the pubspec.yaml is.
// Resolve relative paths relative to current, not where the
// pubspec.yaml is.
containingDescription: RootDescription(p.current),
);
} on FormatException catch (e) {
Expand Down Expand Up @@ -717,7 +724,8 @@ Specify multiple sdk packages with descriptors.''');
}

/// Remove the package from dev_dependencies if we are adding it to
/// dependencies. Refer to [_addPackageToPubspec] for additional discussion.
/// dependencies. Refer to [_addPackageToPubspec] for additional
/// discussion.
if (!update.isDev && !update.isOverride) {
final devDependenciesNode = yamlEditor
.parseAt(['dev_dependencies'], orElse: () => YamlScalar.wrap(null));
Expand Down
5 changes: 3 additions & 2 deletions lib/src/command/cache_preload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class CachePreloadCommand extends PubCommand {
@override
String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-cache';

/// The `cache preload` command is hidden by default, because it's really only intended for
/// `flutter` to use when pre-loading `PUB_CACHE` after being installed from `zip` archive.
/// The `cache preload` command is hidden by default, because it's really only
/// intended for `flutter` to use when pre-loading `PUB_CACHE` after being
/// installed from `zip` archive.
@override
bool get hidden => true;

Expand Down
9 changes: 6 additions & 3 deletions lib/src/command/cache_repair.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class CacheRepairCommand extends PubCommand {
if (failures.isNotEmpty) {
final packages = pluralize('package', failures.length);
final buffer = StringBuffer(
'Failed to reinstall ${log.red(failures.length.toString())} $packages:\n',
'Failed to reinstall '
'${log.red(failures.length.toString())} $packages:\n',
);

for (var failure in failures) {
Expand All @@ -65,14 +66,16 @@ class CacheRepairCommand extends PubCommand {
if (repairSuccesses.isNotEmpty) {
final packages = pluralize('package', repairSuccesses.length);
log.message(
'Reactivated ${log.green(repairSuccesses.length.toString())} $packages.',
'Reactivated '
'${log.green(repairSuccesses.length.toString())} $packages.',
);
}

if (repairFailures.isNotEmpty) {
final packages = pluralize('package', repairFailures.length);
log.message(
'Failed to reactivate ${log.red(repairFailures.length.toString())} $packages:',
'Failed to reactivate '
'${log.red(repairFailures.length.toString())} $packages:',
);
log.message(
repairFailures.map((name) => '- ${log.bold(name)}').join('\n'),
Expand Down
25 changes: 16 additions & 9 deletions lib/src/command/dependency_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class DependencyServicesReportCommand extends PubCommand {
@override
String get name => 'report';
@override
String get description =>
'Output a machine-digestible report of the upgrade options for each dependency.';
String get description => 'Output a machine-digestible '
'report of the upgrade options for each dependency.';
@override
String get argumentsDescription => '[options]';

Expand Down Expand Up @@ -344,7 +344,8 @@ class DependencyServicesApplyCommand extends PubCommand {
);
} else {
fail(
'The dependency $targetPackage does not have a map or string as a description',
'The dependency $targetPackage does not have a '
'map or string as a description',
);
}
} else if (targetVersion != null) {
Expand Down Expand Up @@ -409,7 +410,8 @@ class DependencyServicesApplyCommand extends PubCommand {
final versions = await cache.getVersions(updatedRef);
if (versions.isEmpty) {
dataError(
'Found no versions of $targetPackage with git revision `$targetRevision`.',
'Found no versions of $targetPackage '
'with git revision `$targetRevision`.',
);
}
// GitSource can only return a single version.
Expand All @@ -427,7 +429,8 @@ class DependencyServicesApplyCommand extends PubCommand {
targetRevision == null &&
!(lockFileYaml['packages'] as Map).containsKey(targetPackage)) {
dataError(
'Trying to remove non-existing transitive dependency $targetPackage.',
'Trying to remove non-existing '
'transitive dependency $targetPackage.',
);
}
}
Expand Down Expand Up @@ -472,7 +475,8 @@ class DependencyServicesApplyCommand extends PubCommand {
);
}
}
// Only if we originally had a lock-file we write the resulting lockfile back.
// Only if we originally had a lock-file we write the resulting lockfile
// back.
if (updatedLockfile != null) {
final updatedPackages = <PackageId>[];
for (var package in solveResult.packages) {
Expand Down Expand Up @@ -595,7 +599,8 @@ Map<String, PackageRange>? _dependencySetOfPackage(

/// Return a constraint compatible with [newVersion].
///
/// By convention if the original constraint is pinned we return [newVersion]. Otherwise use [VersionConstraint.compatibleWith].
/// By convention if the original constraint is pinned we return [newVersion].
/// Otherwise use [VersionConstraint.compatibleWith].
VersionConstraint _bumpConstraint(
VersionConstraint original,
Version newVersion,
Expand All @@ -614,9 +619,11 @@ VersionConstraint _bumpConstraint(
);
}

/// Return a constraint compatible with [newVersion], but including [original] as well.
/// Return a constraint compatible with [newVersion], but including [original]
/// as well.
///
/// By convention if the original constraint is pinned, we don't widen the constraint but return [newVersion] instead.
/// By convention if the original constraint is pinned, we don't widen the
/// constraint but return [newVersion] instead.
VersionConstraint _widenConstraint(
VersionConstraint original,
Version newVersion,
Expand Down
9 changes: 6 additions & 3 deletions lib/src/command/deps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ class DepsCommand extends PubCommand {
if (argResults.flag('json')) {
if (argResults.wasParsed('dev')) {
usageException(
'Cannot combine --json and --dev.\nThe json output contains the dependency type in the output.',
'Cannot combine --json and --dev.\n'
'The json output contains the dependency type in the output.',
);
}
if (argResults.wasParsed('executables')) {
usageException(
'Cannot combine --json and --executables.\nThe json output always lists available executables.',
'Cannot combine --json and --executables.\n'
'The json output always lists available executables.',
);
}
if (argResults.wasParsed('style')) {
Expand Down Expand Up @@ -369,7 +371,8 @@ class DepsCommand extends PubCommand {
String _labelPackage(Package package) =>
'${log.bold(package.name)} ${package.version}';

/// Gets the names of the non-immediate dependencies of the workspace packages.
/// Gets the names of the non-immediate dependencies of the workspace
/// packages.
Future<Set<String>> _getTransitiveDependencies() async {
final transitive = await _getAllDependencies();
for (final root in entrypoint.workspaceRoot.transitiveWorkspace) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/command/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class GetCommand extends PubCommand {
argParser.addFlag(
'enforce-lockfile',
negatable: false,
help:
'Enforce pubspec.lock. Fail resolution if pubspec.lock does not satisfy pubspec.yaml',
help: 'Enforce pubspec.lock. '
'Fail resolution if pubspec.lock does not satisfy pubspec.yaml',
);

argParser.addFlag(
Expand Down
10 changes: 6 additions & 4 deletions lib/src/command/global_activate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class GlobalActivateCommand extends PubCommand {
argParser.addOption(
'hosted-url',
abbr: 'u',
help:
'A custom pub server URL for the package. Only applies when using the `hosted` source.',
help: 'A custom pub server URL for the package. '
'Only applies when using the `hosted` source.',
);
}

Expand Down Expand Up @@ -115,7 +115,8 @@ class GlobalActivateCommand extends PubCommand {
(argResults.option('git-path') != null ||
argResults.option('git-ref') != null)) {
usageException(
'Options `--git-path` and `--git-ref` can only be used with --source=git.',
'Options `--git-path` and `--git-ref` '
'can only be used with --source=git.',
);
}

Expand Down Expand Up @@ -156,7 +157,8 @@ class GlobalActivateCommand extends PubCommand {

if (!packageNameRegExp.hasMatch(package)) {
final suggestion = dirExists(package)
? '\n\nDid you mean `$topLevelProgram pub global activate --source path ${escapeShellArgument(package)}`?'
? '\n\nDid you mean `$topLevelProgram pub global activate '
'--source path ${escapeShellArgument(package)}`?'
: '';

usageException('Not a valid package name: "$package"$suggestion');
Expand Down
29 changes: 17 additions & 12 deletions lib/src/command/lish.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class LishCommand extends PubCommand {
argParser.addFlag(
'skip-validation',
negatable: false,
help:
'Publish without validation and resolution (this will ignore errors).',
help: 'Publish without validation and resolution '
'(this will ignore errors).',
);
argParser.addOption(
'server',
Expand All @@ -110,8 +110,8 @@ class LishCommand extends PubCommand {
);
argParser.addOption(
'from-archive',
help:
'Publish from a .tar.gz archive instead of current folder. Implies `--skip-validation`.',
help: 'Publish from a .tar.gz archive instead of current folder. '
'Implies `--skip-validation`.',
valueHelp: '[archive.tar.gz]',
hide: true,
);
Expand Down Expand Up @@ -328,18 +328,23 @@ the \$PUB_HOSTED_URL environment variable.''',
// Show the package contents so the user can verify they look OK.
final package = entrypoint.workPackage;
final host = computeHost(package.pubspec);
final fileTree = tree.fromFiles(
filesAndEmptyDirs,
baseDir: entrypoint.workPackage.dir,
showFileSizes: true,
);
log.message(
'Publishing ${package.name} ${package.version} to $host:\n'
'${tree.fromFiles(filesAndEmptyDirs, baseDir: entrypoint.workPackage.dir, showFileSizes: true)}',
'Publishing ${package.name} ${package.version} to $host:\n$fileTree',
);

final packageBytes = await createTarGz(
filesAndDirs,
baseDir: entrypoint.workPackage.dir,
).toBytes();

final size = _readableFileSize(packageBytes.length);
log.message(
'\nTotal compressed archive size: ${_readableFileSize(packageBytes.length)}.\n',
'\nTotal compressed archive size: $size.\n',
);

final validationResult =
Expand Down Expand Up @@ -399,10 +404,10 @@ the \$PUB_HOSTED_URL environment variable.''',

/// Validates the package.
///
/// Throws if there are errors and the upload should not
/// proceed.
/// Throws if there are errors and the upload should not proceed.
///
/// Returns a summary of warnings and hints if there are any, otherwise `null`.
/// Returns a summary of warnings and hints if there are any, otherwise
/// `null`.
Future<({int warningsCount, int hintsCount})> _validate(
Uint8List packageBytes,
List<String> files,
Expand Down Expand Up @@ -444,8 +449,8 @@ the \$PUB_HOSTED_URL environment variable.''',
log.message('\nPublishing is forever; packages cannot be unpublished.'
'\nPolicy details are available at https://pub.dev/policy\n');

var message =
'Do you want to publish ${package.pubspec.name} ${package.pubspec.version} to $host';
var message = 'Do you want to publish '
'${package.pubspec.name} ${package.pubspec.version} to $host';
if (package.hintCount != 0 || package.warningCount != 0) {
message = '${package.warningsCountMessage}. $message';
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/command/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ class LoginCommand extends PubCommand {
final userInfo = await _retrieveUserInfo();
if (userInfo == null) {
log.warning('Could not retrieve your user-details.\n'
'You might have to run `$topLevelProgram pub logout` to delete your credentials and try again.');
'You might have to run `$topLevelProgram pub logout` '
'to delete your credentials and try again.');
} else {
log.message('You are now logged in as $userInfo');
}
} else {
final userInfo = await _retrieveUserInfo();
if (userInfo == null) {
log.warning('Your credentials seems broken.\n'
'Run `$topLevelProgram pub logout` to delete your credentials and try again.');
'Run `$topLevelProgram pub logout` '
'to delete your credentials and try again.');
}
log.warning('You are already logged in as $userInfo\n'
'Run `$topLevelProgram pub logout` to log out and try again.');
Expand Down
Loading

0 comments on commit d86e3c9

Please sign in to comment.