Skip to content

Commit

Permalink
Enable lints to use new language features (#3987)
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough authored Aug 14, 2023
1 parent 78a39b0 commit 923cb7b
Show file tree
Hide file tree
Showing 29 changed files with 104 additions and 80 deletions.
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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
Expand All @@ -41,6 +42,9 @@ linter:
- 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
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
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
20 changes: 9 additions & 11 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,8 +107,7 @@ 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.
Expand Down Expand Up @@ -141,11 +139,11 @@ 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({Object? color}) {
Expand Down
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
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
58 changes: 30 additions & 28 deletions lib/src/log.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.

/// Message logging.
library;

import 'dart:async';
import 'dart:convert';
import 'dart:io';
Expand Down Expand Up @@ -60,36 +62,36 @@ final _bold = getAnsi('\u001b[1m');
/// An enum type for defining the different logging levels a given message can
/// be associated with.
///
/// By default, [error] and [warning] messages are printed to sterr. [message]
/// messages are printed to stdout, and others are ignored.
class Level {
/// By default, [error] and [warning] messages are printed to stderr.
/// [message] messages are printed to stdout, and others are ignored.
enum Level {
/// An error occurred and an operation could not be completed.
///
/// Usually shown to the user on stderr.
static const error = Level._('ERR ');
error('ERR '),

/// Something unexpected happened, but the program was able to continue,
/// though possibly in a degraded fashion.
static const warning = Level._('WARN');
warning('WARN'),

/// A message intended specifically to be shown to the user.
static const message = Level._('MSG ');
message('MSG '),

/// Some interaction with the external world occurred, such as a network
/// operation, process spawning, or file IO.
static const io = Level._('IO ');
io('IO '),

/// Incremental output during pub's version constraint solver.
static const solver = Level._('SLVR');
solver('SLVR'),

/// Fine-grained and verbose additional information.
///
/// Used to provide program state context for other logs (such as what pub
/// was doing when an IO operation occurred) or just more detail for an
/// operation.
static const fine = Level._('FINE');
fine('FINE');

const Level._(this.name);
const Level(this.name);

final String name;

Expand All @@ -99,79 +101,79 @@ class Level {

/// An enum type to control which log levels are displayed and how they are
/// displayed.
class Verbosity {
enum Verbosity {
/// Silence all logging.
static const none = Verbosity._('none', {
none('none', {
Level.error: null,
Level.warning: null,
Level.message: null,
Level.io: null,
Level.solver: null,
Level.fine: null,
});
}),

/// Shows only errors.
static const error = Verbosity._('error', {
error('error', {
Level.error: _logToStderr,
Level.warning: null,
Level.message: null,
Level.io: null,
Level.solver: null,
Level.fine: null,
});
}),

/// Shows only errors and warnings.
static const warning = Verbosity._('warning', {
warning('warning', {
Level.error: _logToStderr,
Level.warning: _logToStderr,
Level.message: null,
Level.io: null,
Level.solver: null,
Level.fine: null,
});
}),

/// The default verbosity which shows errors, warnings, and messages.
static const normal = Verbosity._('normal', {
normal('normal', {
Level.error: _logToStderr,
Level.warning: _logToStderr,
Level.message: _logToStdout,
Level.io: null,
Level.solver: null,
Level.fine: null,
});
}),

/// Shows errors, warnings, messages, and IO event logs.
static const io = Verbosity._('io', {
io('io', {
Level.error: _logToStderrWithLabel,
Level.warning: _logToStderrWithLabel,
Level.message: _logToStdoutWithLabel,
Level.io: _logToStderrWithLabel,
Level.solver: null,
Level.fine: null,
});
}),

/// Shows errors, warnings, messages, and version solver logs.
static const solver = Verbosity._('solver', {
solver('solver', {
Level.error: _logToStderr,
Level.warning: _logToStderr,
Level.message: _logToStdout,
Level.io: null,
Level.solver: _logToStdout,
Level.fine: null,
});
}),

/// Shows all logs.
static const all = Verbosity._('all', {
all('all', {
Level.error: _logToStderrWithLabel,
Level.warning: _logToStderrWithLabel,
Level.message: _logToStdoutWithLabel,
Level.io: _logToStderrWithLabel,
Level.solver: _logToStderrWithLabel,
Level.fine: _logToStderrWithLabel,
});
}),

/// Shows all logs.
static const testing = Verbosity._('testing', {
testing('testing', {
Level.error: _logToStderrWithLabel,
Level.warning: _logToStderrWithLabel,
Level.message: _logToStdoutWithLabel,
Expand All @@ -180,7 +182,7 @@ class Verbosity {
Level.fine: _logToStderrWithLabel,
});

const Verbosity._(this.name, this._loggers);
const Verbosity(this.name, this._loggers);

final String name;
final Map<Level, void Function(_Entry entry)?> _loggers;
Expand Down Expand Up @@ -409,7 +411,7 @@ Platform: ${Platform.operatingSystem}

/// Filter out normal pub output when not attached to a terminal
///
/// Unless the user has overriden the verbosity,
/// Unless the user has overridden the verbosity,
///
/// This is useful to not pollute stdout when the output is piped somewhere.
Future<T> errorsOnlyUnlessTerminal<T>(FutureOr<T> Function() callback) async {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/solver/assignment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class Assignment extends Term {
/// Creates a derivation: an assignment that's automatically propagated from
/// incompatibilities.
Assignment.derivation(
PackageRange package,
bool isPositive,
super.package,
super.isPositive,
this.cause,
this.decisionLevel,
this.index,
) : super(package, isPositive);
);
}
10 changes: 5 additions & 5 deletions lib/src/solver/set_relation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
// BSD-style license that can be found in the LICENSE file.

/// An enum of possible relationships between two sets.
class SetRelation {
enum SetRelation {
/// The second set contains all elements of the first, as well as possibly
/// more.
static const subset = SetRelation._('subset');
subset('subset'),

/// Neither set contains any elements of the other.
static const disjoint = SetRelation._('disjoint');
disjoint('disjoint'),

/// The sets have elements in common, but the first is not a superset of the
/// second.
///
/// This is also used when the first set is a superset of the first, but in
/// practice we don't need to distinguish that from overlapping sets.
static const overlapping = SetRelation._('overlapping');
overlapping('overlapping');

final String _name;

const SetRelation._(this._name);
const SetRelation(this._name);

@override
String toString() => _name;
Expand Down
Loading

0 comments on commit 923cb7b

Please sign in to comment.