Skip to content

Commit

Permalink
Merge branch 'master' into misc/remove-pair-class
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Aug 14, 2023
2 parents 5f8ca25 + 923cb7b commit 6d76fe9
Show file tree
Hide file tree
Showing 55 changed files with 248 additions and 170 deletions.
7 changes: 7 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ analyzer:

linter:
rules:
- always_declare_return_types
- avoid_catching_errors
- avoid_print
- avoid_private_typedef_functions
Expand All @@ -22,10 +23,12 @@ linter:
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- dangling_library_doc_comments
- directives_ordering
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- omit_local_variable_types
- only_throw_errors
- package_api_docs
- prefer_asserts_in_initializer_lists
Expand All @@ -36,8 +39,12 @@ linter:
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- unawaited_futures
- unnecessary_lambdas
- unnecessary_library_directive
- unnecessary_null_aware_assignments
- unnecessary_parenthesis
- unnecessary_statements
- use_enums
- use_super_parameters
2 changes: 2 additions & 0 deletions lib/src/ascii_tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/// A simple library for rendering tree-like structures in Unicode symbols with
/// a fallback to ASCII.
library;

import 'dart:io';

import 'package:path/path.dart' as path;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ abstract class PubTopLevel {
log.Verbosity get verbosity;
bool get trace;

static addColorFlag(ArgParser argParser) {
static void addColorFlag(ArgParser argParser) {
argParser.addFlag(
'color',
help: 'Use colors in terminal output.\n'
Expand Down
2 changes: 1 addition & 1 deletion lib/src/command/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ Specify multiple sdk packages with descriptors.''');
final name = ref.name;
final resultId = resultPackages.firstWhere((id) => id.name == name);

Object? description = pubspecDescription(
final description = pubspecDescription(
ref.withConstraint(
constraint ??
(ref.source is HostedSource
Expand Down
4 changes: 2 additions & 2 deletions lib/src/command/cache_preload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class CachePreloadCommand extends PubCommand {
usageException('No package to preload given.');
}

for (String packagePath in argResults.rest) {
for (final packagePath in argResults.rest) {
if (!fileExists(packagePath)) {
fail('Could not find file $packagePath.');
}
}
for (String archivePath in argResults.rest) {
for (final archivePath in argResults.rest) {
final id = await cache.hosted.preloadPackage(archivePath, cache);
final url = (id.description.description as HostedDescription).url;

Expand Down
4 changes: 3 additions & 1 deletion lib/src/command/dependency_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// This implements support for dependency-bot style automated upgrades.
/// Implements support for dependency-bot style automated upgrades.
/// It is still work in progress - do not rely on the current output.
library;

import 'dart:convert';
import 'dart:io';

Expand Down
4 changes: 3 additions & 1 deletion lib/src/command/deps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ class DepsCommand extends PubCommand {
buffer.writeln('- ${_labelPackage(package)}');

for (var dep in package.dependencies.values) {
buffer.writeln(' - ${log.bold(dep.name)} ${log.gray(dep.constraint)}');
buffer.writeln(
' - ${log.bold(dep.name)} ${log.gray(dep.constraint.toString())}',
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/command/uploader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class UploaderCommand extends PubCommand {

@override
Future<void> runProtected() async {
String packageName = '<packageName>';
var packageName = '<packageName>';
try {
packageName = entrypoint.root.name;
} on Exception catch (_) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class PubCommandRunner extends CommandRunner<int> implements PubTopLevel {

if (depsRev == actualRev) return;
log.warning("${log.yellow('Warning:')} the revision of pub in DEPS is "
'${log.bold(depsRev)},\n'
'${log.bold(depsRev.toString())},\n'
'but ${log.bold(actualRev)} is checked out in '
'${p.relative(pubRoot)}.\n\n');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

/// A library for compiling Dart code and manipulating analyzer parse trees.
library;

import 'dart:async';
import 'dart:io';

Expand Down
24 changes: 11 additions & 13 deletions lib/src/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ApplicationException implements Exception {
/// A subclass of [ApplicationException] that occurs when running a subprocess
/// has failed.
class RunProcessException extends ApplicationException {
RunProcessException(String message) : super(message);
RunProcessException(super.message);
}

/// An exception class for exceptions that are intended to be seen by the user
Expand All @@ -56,9 +56,8 @@ class WrappedException extends ApplicationException {
/// The stack chain for [innerError] if it exists.
final Chain? innerChain;

WrappedException(String message, this.innerError, [StackTrace? innerTrace])
: innerChain = innerTrace == null ? null : Chain.forTrace(innerTrace),
super(message);
WrappedException(super.message, this.innerError, [StackTrace? innerTrace])
: innerChain = innerTrace == null ? null : Chain.forTrace(innerTrace);
}

/// A class for exceptions that shouldn't be printed at the top level.
Expand All @@ -74,14 +73,14 @@ class SilentException extends WrappedException {
///
/// This corresponds to the `data` exit code.
class DataException extends ApplicationException {
DataException(String message) : super(message);
DataException(super.message);
}

/// An exception indicating that the users configuration is invalid.
///
/// This corresponds to the `config` exit code;
class ConfigException extends ApplicationException {
ConfigException(String message) : super(message);
ConfigException(super.message);
}

/// An class for exceptions where a package could not be found in a [Source].
Expand All @@ -108,14 +107,13 @@ class PackageNotFoundException extends WrappedException {

/// A class for exceptions where a package's checksum could not be validated.
class PackageIntegrityException extends PubHttpException {
PackageIntegrityException(String message)
: super(message, isIntermittent: true);
PackageIntegrityException(super.message) : super(isIntermittent: true);
}

/// Returns whether [error] is a user-facing error object.
///
/// This includes both [ApplicationException] and any dart:io errors.
bool isUserFacingException(error) {
bool isUserFacingException(Object error) {
return error is ApplicationException ||
error is AnalyzerErrorGroup ||
error is IsolateSpawnException ||
Expand All @@ -141,14 +139,14 @@ class SourceSpanApplicationException extends SourceSpanFormatException
final String? hint;

SourceSpanApplicationException(
String message,
SourceSpan? span, {
super.message,
super.span, {
this.hint,
this.explanation,
}) : super(message, span);
});

@override
String toString({color}) {
String toString({Object? color}) {
return [
if (explanation != null) explanation,
span == null
Expand Down
2 changes: 1 addition & 1 deletion lib/src/flutter_releases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ class FlutterRelease {
required this.channel,
});
@override
toString() =>
String toString() =>
'FlutterRelease(flutter=$flutterVersion, dart=$dartVersion, channel=$channel)';
}
2 changes: 2 additions & 0 deletions lib/src/git.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

/// Helper functionality for invoking Git.
library;

import 'dart:async';

import 'package:collection/collection.dart';
Expand Down
10 changes: 5 additions & 5 deletions lib/src/global_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class GlobalPackages {
bool silent = false,
}) async {
final name = dep.name;
LockFile? originalLockFile = _describeActive(name, cache);
final originalLockFile = _describeActive(name, cache);

// Create a dummy package with just [dep] so we can do resolution on it.
var root = Package.inMemory(
Expand Down Expand Up @@ -251,7 +251,7 @@ class GlobalPackages {
final sameVersions =
originalLockFile != null && originalLockFile.samePackageIds(lockFile);

final PackageId id = lockFile.packages[name]!;
final id = lockFile.packages[name]!;
if (sameVersions) {
log.message('''
The package $name is already activated at newest available version.
Expand Down Expand Up @@ -331,7 +331,7 @@ To recompile executables, first run `$topLevelProgram pub global deactivate $nam
'"${description.path}".');
} else {
log.message('Package ${log.bold(name)} is currently active at version '
'${log.bold(id.version)}.');
'${log.bold(id.version.toString())}.');
}
return lockFile;
}
Expand Down Expand Up @@ -725,10 +725,10 @@ try:
for (var command in ordered(collided.keys)) {
if (overwriteBinStubs) {
log.warning('Replaced ${log.bold(command)} previously installed from '
'${log.bold(collided[command])}.');
'${log.bold(collided[command].toString())}.');
} else {
log.warning('Executable ${log.bold(command)} was already installed '
'from ${log.bold(collided[command])}.');
'from ${log.bold(collided[command].toString())}.');
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/src/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

/// Helpers for dealing with HTTP.
library;

import 'dart:async';
import 'dart:convert';
import 'dart:io';
Expand Down
2 changes: 2 additions & 0 deletions lib/src/ignore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
/// [Ignore.listFiles].
///
/// [1]: https://git-scm.com/docs/gitignore
library;

import 'package:meta/meta.dart';

/// A set of ignore rules representing a single ignore file.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

/// Helper functionality to make working with IO easier.
library;

import 'dart:async';
import 'dart:collection';
import 'dart:convert';
Expand Down
4 changes: 3 additions & 1 deletion lib/src/isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// BSD-style license that can be found in the LICENSE file.

/// A library for utility functions for dealing with isolates.
library;

import 'dart:async';
import 'dart:io';
import 'dart:isolate';

/// Like [Isolate.spanwUri], except that this only returns once the Isolate has
/// Like [Isolate.spawnUri], except that this only returns once the Isolate has
/// exited.
///
/// If the isolate produces an unhandled exception, it's printed to stderr and
Expand Down
Loading

0 comments on commit 6d76fe9

Please sign in to comment.