misc: enable pkg:pendancy lints (dart-lang/io#43)
Also removed implicit new/const
diff --git a/pkgs/io/analysis_options.yaml b/pkgs/io/analysis_options.yaml
index cf2c891..a0cc074 100644
--- a/pkgs/io/analysis_options.yaml
+++ b/pkgs/io/analysis_options.yaml
@@ -1,3 +1,4 @@
+include: package:pedantic/analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
@@ -50,5 +51,7 @@
- recursive_getters
- slash_for_doc_comments
- type_init_formals
+ - unnecessary_const
- unnecessary_brace_in_string_interps
+ - unnecessary_new
- unnecessary_this
diff --git a/pkgs/io/example/spawn_process.dart b/pkgs/io/example/spawn_process.dart
index 7654110..0529bf3 100644
--- a/pkgs/io/example/spawn_process.dart
+++ b/pkgs/io/example/spawn_process.dart
@@ -8,7 +8,7 @@
/// Runs `dartfmt` commands and `pub publish`.
Future<Null> main() async {
- final manager = new ProcessManager();
+ final manager = ProcessManager();
// Runs dartfmt --version and outputs the result via stdout.
print('Running dartfmt --version');
diff --git a/pkgs/io/lib/src/ansi_code.dart b/pkgs/io/lib/src/ansi_code.dart
index 8b9c3a1..dc02174 100644
--- a/pkgs/io/lib/src/ansi_code.dart
+++ b/pkgs/io/lib/src/ansi_code.dart
@@ -38,16 +38,16 @@
final String _name;
/// A foreground color.
- static const AnsiCodeType foreground = const AnsiCodeType._('foreground');
+ static const AnsiCodeType foreground = AnsiCodeType._('foreground');
/// A style.
- static const AnsiCodeType style = const AnsiCodeType._('style');
+ static const AnsiCodeType style = AnsiCodeType._('style');
/// A background color.
- static const AnsiCodeType background = const AnsiCodeType._('background');
+ static const AnsiCodeType background = AnsiCodeType._('background');
/// A reset value.
- static const AnsiCodeType reset = const AnsiCodeType._('reset');
+ static const AnsiCodeType reset = AnsiCodeType._('reset');
const AnsiCodeType._(this._name);
@@ -81,7 +81,7 @@
/// Represents the value as an unescaped literal suitable for scripts.
String get escapeForScript => "$_ansiEscapeForScript[${code}m";
- String _escapeValue({bool forScript: false}) {
+ String _escapeValue({bool forScript = false}) {
forScript ??= false;
return forScript ? escapeForScript : escape;
}
@@ -96,7 +96,7 @@
/// * [value] is `null` or empty
/// * both [ansiOutputEnabled] and [forScript] are `false`.
/// * [type] is [AnsiCodeType.reset]
- String wrap(String value, {bool forScript: false}) =>
+ String wrap(String value, {bool forScript = false}) =>
_isNoop(type == AnsiCodeType.reset, value, forScript)
? value
: "${_escapeValue(forScript: forScript)}$value"
@@ -121,7 +121,7 @@
/// * [codes] contains more than one value of type [AnsiCodeType.background].
/// * [codes] contains any value of type [AnsiCodeType.reset].
String wrapWith(String value, Iterable<AnsiCode> codes,
- {bool forScript: false}) {
+ {bool forScript = false}) {
forScript ??= false;
// Eliminate duplicates
final myCodes = codes.toSet();
@@ -136,19 +136,19 @@
case AnsiCodeType.foreground:
foreground++;
if (foreground > 1) {
- throw new ArgumentError.value(codes, 'codes',
+ throw ArgumentError.value(codes, 'codes',
"Cannot contain more than one foreground color code.");
}
break;
case AnsiCodeType.background:
background++;
if (background > 1) {
- throw new ArgumentError.value(codes, 'codes',
+ throw ArgumentError.value(codes, 'codes',
"Cannot contain more than one foreground color code.");
}
break;
case AnsiCodeType.reset:
- throw new ArgumentError.value(
+ throw ArgumentError.value(
codes, 'codes', "Cannot contain reset codes.");
break;
}
@@ -165,117 +165,107 @@
// Style values
//
-const styleBold = const AnsiCode._('bold', AnsiCodeType.style, 1, resetBold);
-const styleDim = const AnsiCode._('dim', AnsiCodeType.style, 2, resetDim);
-const styleItalic =
- const AnsiCode._('italic', AnsiCodeType.style, 3, resetItalic);
+const styleBold = AnsiCode._('bold', AnsiCodeType.style, 1, resetBold);
+const styleDim = AnsiCode._('dim', AnsiCodeType.style, 2, resetDim);
+const styleItalic = AnsiCode._('italic', AnsiCodeType.style, 3, resetItalic);
const styleUnderlined =
- const AnsiCode._('underlined', AnsiCodeType.style, 4, resetUnderlined);
-const styleBlink = const AnsiCode._('blink', AnsiCodeType.style, 5, resetBlink);
-const styleReverse =
- const AnsiCode._('reverse', AnsiCodeType.style, 7, resetReverse);
+ AnsiCode._('underlined', AnsiCodeType.style, 4, resetUnderlined);
+const styleBlink = AnsiCode._('blink', AnsiCodeType.style, 5, resetBlink);
+const styleReverse = AnsiCode._('reverse', AnsiCodeType.style, 7, resetReverse);
/// Not widely supported.
-const styleHidden =
- const AnsiCode._('hidden', AnsiCodeType.style, 8, resetHidden);
+const styleHidden = AnsiCode._('hidden', AnsiCodeType.style, 8, resetHidden);
/// Not widely supported.
const styleCrossedOut =
- const AnsiCode._('crossed out', AnsiCodeType.style, 9, resetCrossedOut);
+ AnsiCode._('crossed out', AnsiCodeType.style, 9, resetCrossedOut);
//
// Reset values
//
-const resetAll = const AnsiCode._('all', AnsiCodeType.reset, 0, null);
+const resetAll = AnsiCode._('all', AnsiCodeType.reset, 0, null);
// NOTE: bold is weird. The reset code seems to be 22 sometimes – not 21
// See https://gitlab.com/gnachman/iterm2/issues/3208
-const resetBold = const AnsiCode._('bold', AnsiCodeType.reset, 22, null);
-const resetDim = const AnsiCode._('dim', AnsiCodeType.reset, 22, null);
-const resetItalic = const AnsiCode._('italic', AnsiCodeType.reset, 23, null);
-const resetUnderlined =
- const AnsiCode._('underlined', AnsiCodeType.reset, 24, null);
-const resetBlink = const AnsiCode._('blink', AnsiCodeType.reset, 25, null);
-const resetReverse = const AnsiCode._('reverse', AnsiCodeType.reset, 27, null);
-const resetHidden = const AnsiCode._('hidden', AnsiCodeType.reset, 28, null);
-const resetCrossedOut =
- const AnsiCode._('crossed out', AnsiCodeType.reset, 29, null);
+const resetBold = AnsiCode._('bold', AnsiCodeType.reset, 22, null);
+const resetDim = AnsiCode._('dim', AnsiCodeType.reset, 22, null);
+const resetItalic = AnsiCode._('italic', AnsiCodeType.reset, 23, null);
+const resetUnderlined = AnsiCode._('underlined', AnsiCodeType.reset, 24, null);
+const resetBlink = AnsiCode._('blink', AnsiCodeType.reset, 25, null);
+const resetReverse = AnsiCode._('reverse', AnsiCodeType.reset, 27, null);
+const resetHidden = AnsiCode._('hidden', AnsiCodeType.reset, 28, null);
+const resetCrossedOut = AnsiCode._('crossed out', AnsiCodeType.reset, 29, null);
//
// Foreground values
//
-const black = const AnsiCode._('black', AnsiCodeType.foreground, 30, resetAll);
-const red = const AnsiCode._('red', AnsiCodeType.foreground, 31, resetAll);
-const green = const AnsiCode._('green', AnsiCodeType.foreground, 32, resetAll);
-const yellow =
- const AnsiCode._('yellow', AnsiCodeType.foreground, 33, resetAll);
-const blue = const AnsiCode._('blue', AnsiCodeType.foreground, 34, resetAll);
-const magenta =
- const AnsiCode._('magenta', AnsiCodeType.foreground, 35, resetAll);
-const cyan = const AnsiCode._('cyan', AnsiCodeType.foreground, 36, resetAll);
+const black = AnsiCode._('black', AnsiCodeType.foreground, 30, resetAll);
+const red = AnsiCode._('red', AnsiCodeType.foreground, 31, resetAll);
+const green = AnsiCode._('green', AnsiCodeType.foreground, 32, resetAll);
+const yellow = AnsiCode._('yellow', AnsiCodeType.foreground, 33, resetAll);
+const blue = AnsiCode._('blue', AnsiCodeType.foreground, 34, resetAll);
+const magenta = AnsiCode._('magenta', AnsiCodeType.foreground, 35, resetAll);
+const cyan = AnsiCode._('cyan', AnsiCodeType.foreground, 36, resetAll);
const lightGray =
- const AnsiCode._('light gray', AnsiCodeType.foreground, 37, resetAll);
+ AnsiCode._('light gray', AnsiCodeType.foreground, 37, resetAll);
const defaultForeground =
- const AnsiCode._('default', AnsiCodeType.foreground, 39, resetAll);
-const darkGray =
- const AnsiCode._('dark gray', AnsiCodeType.foreground, 90, resetAll);
-const lightRed =
- const AnsiCode._('light red', AnsiCodeType.foreground, 91, resetAll);
+ AnsiCode._('default', AnsiCodeType.foreground, 39, resetAll);
+const darkGray = AnsiCode._('dark gray', AnsiCodeType.foreground, 90, resetAll);
+const lightRed = AnsiCode._('light red', AnsiCodeType.foreground, 91, resetAll);
const lightGreen =
- const AnsiCode._('light green', AnsiCodeType.foreground, 92, resetAll);
+ AnsiCode._('light green', AnsiCodeType.foreground, 92, resetAll);
const lightYellow =
- const AnsiCode._('light yellow', AnsiCodeType.foreground, 93, resetAll);
+ AnsiCode._('light yellow', AnsiCodeType.foreground, 93, resetAll);
const lightBlue =
- const AnsiCode._('light blue', AnsiCodeType.foreground, 94, resetAll);
+ AnsiCode._('light blue', AnsiCodeType.foreground, 94, resetAll);
const lightMagenta =
- const AnsiCode._('light magenta', AnsiCodeType.foreground, 95, resetAll);
+ AnsiCode._('light magenta', AnsiCodeType.foreground, 95, resetAll);
const lightCyan =
- const AnsiCode._('light cyan', AnsiCodeType.foreground, 96, resetAll);
-const white = const AnsiCode._('white', AnsiCodeType.foreground, 97, resetAll);
+ AnsiCode._('light cyan', AnsiCodeType.foreground, 96, resetAll);
+const white = AnsiCode._('white', AnsiCodeType.foreground, 97, resetAll);
//
// Background values
//
const backgroundBlack =
- const AnsiCode._('black', AnsiCodeType.background, 40, resetAll);
-const backgroundRed =
- const AnsiCode._('red', AnsiCodeType.background, 41, resetAll);
+ AnsiCode._('black', AnsiCodeType.background, 40, resetAll);
+const backgroundRed = AnsiCode._('red', AnsiCodeType.background, 41, resetAll);
const backgroundGreen =
- const AnsiCode._('green', AnsiCodeType.background, 42, resetAll);
+ AnsiCode._('green', AnsiCodeType.background, 42, resetAll);
const backgroundYellow =
- const AnsiCode._('yellow', AnsiCodeType.background, 43, resetAll);
+ AnsiCode._('yellow', AnsiCodeType.background, 43, resetAll);
const backgroundBlue =
- const AnsiCode._('blue', AnsiCodeType.background, 44, resetAll);
+ AnsiCode._('blue', AnsiCodeType.background, 44, resetAll);
const backgroundMagenta =
- const AnsiCode._('magenta', AnsiCodeType.background, 45, resetAll);
+ AnsiCode._('magenta', AnsiCodeType.background, 45, resetAll);
const backgroundCyan =
- const AnsiCode._('cyan', AnsiCodeType.background, 46, resetAll);
+ AnsiCode._('cyan', AnsiCodeType.background, 46, resetAll);
const backgroundLightGray =
- const AnsiCode._('light gray', AnsiCodeType.background, 47, resetAll);
+ AnsiCode._('light gray', AnsiCodeType.background, 47, resetAll);
const backgroundDefault =
- const AnsiCode._('default', AnsiCodeType.background, 49, resetAll);
+ AnsiCode._('default', AnsiCodeType.background, 49, resetAll);
const backgroundDarkGray =
- const AnsiCode._('dark gray', AnsiCodeType.background, 100, resetAll);
+ AnsiCode._('dark gray', AnsiCodeType.background, 100, resetAll);
const backgroundLightRed =
- const AnsiCode._('light red', AnsiCodeType.background, 101, resetAll);
+ AnsiCode._('light red', AnsiCodeType.background, 101, resetAll);
const backgroundLightGreen =
- const AnsiCode._('light green', AnsiCodeType.background, 102, resetAll);
+ AnsiCode._('light green', AnsiCodeType.background, 102, resetAll);
const backgroundLightYellow =
- const AnsiCode._('light yellow', AnsiCodeType.background, 103, resetAll);
+ AnsiCode._('light yellow', AnsiCodeType.background, 103, resetAll);
const backgroundLightBlue =
- const AnsiCode._('light blue', AnsiCodeType.background, 104, resetAll);
+ AnsiCode._('light blue', AnsiCodeType.background, 104, resetAll);
const backgroundLightMagenta =
- const AnsiCode._('light magenta', AnsiCodeType.background, 105, resetAll);
+ AnsiCode._('light magenta', AnsiCodeType.background, 105, resetAll);
const backgroundLightCyan =
- const AnsiCode._('light cyan', AnsiCodeType.background, 106, resetAll);
+ AnsiCode._('light cyan', AnsiCodeType.background, 106, resetAll);
const backgroundWhite =
- const AnsiCode._('white', AnsiCodeType.background, 107, resetAll);
+ AnsiCode._('white', AnsiCodeType.background, 107, resetAll);
/// All of the [AnsiCode] values that represent [AnsiCodeType.style].
-const List<AnsiCode> styles = const [
+const List<AnsiCode> styles = [
styleBold,
styleDim,
styleItalic,
@@ -287,7 +277,7 @@
];
/// All of the [AnsiCode] values that represent [AnsiCodeType.foreground].
-const List<AnsiCode> foregroundColors = const [
+const List<AnsiCode> foregroundColors = [
black,
red,
green,
@@ -308,7 +298,7 @@
];
/// All of the [AnsiCode] values that represent [AnsiCodeType.background].
-const List<AnsiCode> backgroundColors = const [
+const List<AnsiCode> backgroundColors = [
backgroundBlack,
backgroundRed,
backgroundGreen,
diff --git a/pkgs/io/lib/src/copy_path.dart b/pkgs/io/lib/src/copy_path.dart
index ed790ed..3b2f6cf 100644
--- a/pkgs/io/lib/src/copy_path.dart
+++ b/pkgs/io/lib/src/copy_path.dart
@@ -12,7 +12,7 @@
return true;
}
if (p.isWithin(from, to)) {
- throw new ArgumentError('Cannot copy from $from to $to');
+ throw ArgumentError('Cannot copy from $from to $to');
}
return false;
}
@@ -30,15 +30,15 @@
if (_doNothing(from, to)) {
return;
}
- await new Directory(to).create(recursive: true);
- await for (final file in new Directory(from).list(recursive: true)) {
+ await Directory(to).create(recursive: true);
+ await for (final file in Directory(from).list(recursive: true)) {
final copyTo = p.join(to, p.relative(file.path, from: from));
if (file is Directory) {
- await new Directory(copyTo).create(recursive: true);
+ await Directory(copyTo).create(recursive: true);
} else if (file is File) {
- await new File(file.path).copy(copyTo);
+ await File(file.path).copy(copyTo);
} else if (file is Link) {
- await new Link(copyTo).create(await file.target(), recursive: true);
+ await Link(copyTo).create(await file.target(), recursive: true);
}
}
}
@@ -56,15 +56,15 @@
if (_doNothing(from, to)) {
return;
}
- new Directory(to).createSync(recursive: true);
- for (final file in new Directory(from).listSync(recursive: true)) {
+ Directory(to).createSync(recursive: true);
+ for (final file in Directory(from).listSync(recursive: true)) {
final copyTo = p.join(to, p.relative(file.path, from: from));
if (file is Directory) {
- new Directory(copyTo).createSync(recursive: true);
+ Directory(copyTo).createSync(recursive: true);
} else if (file is File) {
- new File(file.path).copySync(copyTo);
+ File(file.path).copySync(copyTo);
} else if (file is Link) {
- new Link(copyTo).createSync(file.targetSync(), recursive: true);
+ Link(copyTo).createSync(file.targetSync(), recursive: true);
}
}
}
diff --git a/pkgs/io/lib/src/exit_code.dart b/pkgs/io/lib/src/exit_code.dart
index 50d7f7e..e6334af 100644
--- a/pkgs/io/lib/src/exit_code.dart
+++ b/pkgs/io/lib/src/exit_code.dart
@@ -7,67 +7,67 @@
/// [Source](https://www.freebsd.org/cgi/man.cgi?query=sysexits).
class ExitCode {
/// Command completed successfully.
- static const success = const ExitCode._(0, 'success');
+ static const success = ExitCode._(0, 'success');
/// Command was used incorrectly.
///
/// This may occur if the wrong number of arguments was used, a bad flag, or
/// bad syntax in a parameter.
- static const usage = const ExitCode._(64, 'usage');
+ static const usage = ExitCode._(64, 'usage');
/// Input data was used incorrectly.
///
/// This should occur only for user data (not system files).
- static const data = const ExitCode._(65, 'data');
+ static const data = ExitCode._(65, 'data');
/// An input file (not a system file) did not exist or was not readable.
- static const noInput = const ExitCode._(66, 'noInput');
+ static const noInput = ExitCode._(66, 'noInput');
/// User specified did not exist.
- static const noUser = const ExitCode._(67, 'noUser');
+ static const noUser = ExitCode._(67, 'noUser');
/// Host specified did not exist.
- static const noHost = const ExitCode._(68, 'noHost');
+ static const noHost = ExitCode._(68, 'noHost');
/// A service is unavailable.
///
/// This may occur if a support program or file does not exist. This may also
/// be used as a catch-all error when something you wanted to do does not
/// work, but you do not know why.
- static const unavailable = const ExitCode._(69, 'unavailable');
+ static const unavailable = ExitCode._(69, 'unavailable');
/// An internal software error has been detected.
///
/// This should be limited to non-operating system related errors as possible.
- static const software = const ExitCode._(70, 'software');
+ static const software = ExitCode._(70, 'software');
/// An operating system error has been detected.
///
/// This intended to be used for such thing as `cannot fork` or `cannot pipe`.
- static const osError = const ExitCode._(71, 'osError');
+ static const osError = ExitCode._(71, 'osError');
/// Some system file (e.g. `/etc/passwd`) does not exist or could not be read.
- static const osFile = const ExitCode._(72, 'osFile');
+ static const osFile = ExitCode._(72, 'osFile');
/// A (user specified) output file cannot be created.
- static const cantCreate = const ExitCode._(73, 'cantCreate');
+ static const cantCreate = ExitCode._(73, 'cantCreate');
/// An error occurred doing I/O on some file.
- static const ioError = const ExitCode._(74, 'ioError');
+ static const ioError = ExitCode._(74, 'ioError');
/// Temporary failure, indicating something is not really an error.
///
/// In some cases, this can be re-attempted and will succeed later.
- static const tempFail = const ExitCode._(75, 'tempFail');
+ static const tempFail = ExitCode._(75, 'tempFail');
/// You did not have sufficient permissions to perform the operation.
///
/// This is not intended for file system problems, which should use [noInput]
/// or [cantCreate], but rather for higher-level permissions.
- static const noPerm = const ExitCode._(77, 'noPerm');
+ static const noPerm = ExitCode._(77, 'noPerm');
/// Something was found in an unconfigured or misconfigured state.
- static const config = const ExitCode._(78, 'config');
+ static const config = ExitCode._(78, 'config');
/// Exit code value.
final int code;
diff --git a/pkgs/io/lib/src/permissions.dart b/pkgs/io/lib/src/permissions.dart
index 4267ded..0056bbf 100644
--- a/pkgs/io/lib/src/permissions.dart
+++ b/pkgs/io/lib/src/permissions.dart
@@ -26,7 +26,7 @@
bool _hasPermission(
FileStat stat,
_FilePermission permission, {
- _FilePermissionRole role: _FilePermissionRole.world,
+ _FilePermissionRole role = _FilePermissionRole.world,
}) {
final index = _permissionBitIndex(permission, role);
return (stat.mode & (1 << index)) != 0;
@@ -55,7 +55,7 @@
FutureOr<bool> isExecutable(
String path, {
bool isWindows,
- FutureOr<FileStat> getStat(String path): FileStat.stat,
+ FutureOr<FileStat> getStat(String path) = FileStat.stat,
}) {
// Windows has no concept of executable.
if (isWindows ?? Platform.isWindows) return true;
diff --git a/pkgs/io/lib/src/process_manager.dart b/pkgs/io/lib/src/process_manager.dart
index d66790d..28c5743 100644
--- a/pkgs/io/lib/src/process_manager.dart
+++ b/pkgs/io/lib/src/process_manager.dart
@@ -46,9 +46,9 @@
stderr ??= io.stderr;
isWindows ??= io.Platform.isWindows;
if (isWindows) {
- return new _WindowsProcessManager(stdin, stdout, stderr);
+ return _WindowsProcessManager(stdin, stdout, stderr);
}
- return new _UnixProcessManager(stdin, stdout, stderr);
+ return _UnixProcessManager(stdin, stdout, stderr);
}
final Stream<List<int>> _stdin;
@@ -69,9 +69,9 @@
Iterable<String> arguments, {
String workingDirectory,
Map<String, String> environment,
- bool includeParentEnvironment: true,
- bool runInShell: false,
- io.ProcessStartMode mode: io.ProcessStartMode.normal,
+ bool includeParentEnvironment = true,
+ bool runInShell = false,
+ io.ProcessStartMode mode = io.ProcessStartMode.normal,
}) async {
final process = io.Process.start(
executable,
@@ -82,7 +82,7 @@
runInShell: runInShell,
mode: mode,
);
- return new _ForwardingSpawn(await process, _stdin, _stdout, _stderr);
+ return _ForwardingSpawn(await process, _stdin, _stdout, _stderr);
}
/// Spawns a process by invoking [executable] with [arguments].
@@ -97,9 +97,9 @@
Iterable<String> arguments, {
String workingDirectory,
Map<String, String> environment,
- bool includeParentEnvironment: true,
- bool runInShell: false,
- io.ProcessStartMode mode: io.ProcessStartMode.normal,
+ bool includeParentEnvironment = true,
+ bool runInShell = false,
+ io.ProcessStartMode mode = io.ProcessStartMode.normal,
}) async {
final process = io.Process.start(
executable,
@@ -110,7 +110,7 @@
runInShell: runInShell,
mode: mode,
);
- return new _ForwardingSpawn(
+ return _ForwardingSpawn(
await process,
const Stream.empty(),
_stdout,
@@ -128,9 +128,9 @@
Iterable<String> arguments, {
String workingDirectory,
Map<String, String> environment,
- bool includeParentEnvironment: true,
- bool runInShell: false,
- io.ProcessStartMode mode: io.ProcessStartMode.normal,
+ bool includeParentEnvironment = true,
+ bool runInShell = false,
+ io.ProcessStartMode mode = io.ProcessStartMode.normal,
}) async {
return io.Process.start(
executable,
@@ -192,8 +192,8 @@
io.IOSink stdout,
io.IOSink stderr,
) {
- final stdoutSelf = new StreamController<List<int>>();
- final stderrSelf = new StreamController<List<int>>();
+ final stdoutSelf = StreamController<List<int>>();
+ final stderrSelf = StreamController<List<int>>();
final stdInSub = stdin.listen(delegate.stdin.add);
final stdOutSub = delegate.stdout.listen((event) {
stdout.add(event);
@@ -203,7 +203,7 @@
stderr.add(event);
stderrSelf.add(event);
});
- return new _ForwardingSpawn._delegate(
+ return _ForwardingSpawn._delegate(
delegate,
stdInSub,
stdOutSub,
diff --git a/pkgs/io/lib/src/shared_stdin.dart b/pkgs/io/lib/src/shared_stdin.dart
index bd71027..8bd59b1 100644
--- a/pkgs/io/lib/src/shared_stdin.dart
+++ b/pkgs/io/lib/src/shared_stdin.dart
@@ -17,7 +17,7 @@
/// [SharedStdIn.terminate] *must* be invoked in order to close the underlying
/// connection to [stdin], allowing your program to close automatically without
/// hanging.
-final SharedStdIn sharedStdIn = new SharedStdIn(stdin);
+final SharedStdIn sharedStdIn = SharedStdIn(stdin);
/// A singleton wrapper around `stdin` that allows new subscribers.
///
@@ -36,7 +36,7 @@
/// Returns a future that completes with the next line.
///
/// This is similar to the standard [Stdin.readLineSync], but asynchronous.
- Future<String> nextLine({Encoding encoding: systemEncoding}) {
+ Future<String> nextLine({Encoding encoding = systemEncoding}) {
return lines(encoding: encoding).first;
}
@@ -51,7 +51,7 @@
/// ```
///
/// ... but asynchronous.
- Stream<String> lines({Encoding encoding: systemEncoding}) {
+ Stream<String> lines({Encoding encoding = systemEncoding}) {
return transform(utf8.decoder).transform(const LineSplitter());
}
@@ -59,7 +59,7 @@
StreamController<List<int>> _getCurrent() {
if (_current == null) {
- _current = new StreamController<List<int>>(
+ _current = StreamController<List<int>>(
onCancel: () {
_current = null;
},
@@ -76,11 +76,11 @@
bool cancelOnError,
}) {
if (_sub == null) {
- throw new StateError('Stdin has already been terminated.');
+ throw StateError('Stdin has already been terminated.');
}
final controller = _getCurrent();
if (controller.hasListener) {
- throw new StateError(''
+ throw StateError(''
'Subscriber already listening. The existing subscriber must cancel '
'before another may be added.');
}
@@ -95,7 +95,7 @@
/// Terminates the connection to `stdin`, closing all subscription.
Future<Null> terminate() async {
if (_sub == null) {
- throw new StateError('Stdin has already been terminated.');
+ throw StateError('Stdin has already been terminated.');
}
await _sub.cancel();
await _current?.close();
diff --git a/pkgs/io/lib/src/shell_words.dart b/pkgs/io/lib/src/shell_words.dart
index 12e5d7e..279680b 100644
--- a/pkgs/io/lib/src/shell_words.dart
+++ b/pkgs/io/lib/src/shell_words.dart
@@ -22,9 +22,9 @@
///
/// Throws a [FormatException] if [command] isn't a valid shell command.
List<String> shellSplit(String command) {
- final scanner = new StringScanner(command);
+ final scanner = StringScanner(command);
final results = <String>[];
- final token = new StringBuffer();
+ final token = StringBuffer();
// Whether a token is being parsed, as opposed to a separator character. This
// is different than just [token.isEmpty], because empty quoted tokens can
diff --git a/pkgs/io/pubspec.yaml b/pkgs/io/pubspec.yaml
index 8089bb3..c3a8299 100644
--- a/pkgs/io/pubspec.yaml
+++ b/pkgs/io/pubspec.yaml
@@ -1,12 +1,12 @@
name: io
description: >
Utilities for the Dart VM Runtime.
-version: 0.3.3
+version: 0.3.4-dev
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/io
environment:
- sdk: ">=2.0.0-dev.54 <3.0.0"
+ sdk: ">=2.0.0 <3.0.0"
dependencies:
charcode: ^1.0.0
@@ -16,5 +16,6 @@
dev_dependencies:
dart_style: ^1.0.7
+ pedantic: ^1.2.0
test: ^1.0.0
test_descriptor: ^1.0.0
diff --git a/pkgs/io/test/process_manager_test.dart b/pkgs/io/test/process_manager_test.dart
index c80d5e7..d161a9e 100644
--- a/pkgs/io/test/process_manager_test.dart
+++ b/pkgs/io/test/process_manager_test.dart
@@ -21,7 +21,7 @@
test('spawn functions should match the type definition of Process.start', () {
final isStartProcess = const TypeMatcher<StartProcess>();
expect(Process.start, isStartProcess);
- final manager = new ProcessManager();
+ final manager = ProcessManager();
expect(manager.spawn, isStartProcess);
expect(manager.spawnBackground, isStartProcess);
expect(manager.spawnDetached, isStartProcess);
@@ -29,19 +29,19 @@
group('spawn', () {
setUp(() async {
- fakeStdIn = new StreamController<String>(sync: true);
- sharedStdIn = new SharedStdIn(fakeStdIn.stream.map((s) => s.codeUnits));
+ fakeStdIn = StreamController<String>(sync: true);
+ sharedStdIn = SharedStdIn(fakeStdIn.stream.map((s) => s.codeUnits));
stdoutLog = <String>[];
stderrLog = <String>[];
- final stdoutController = new StreamController<List<int>>(sync: true);
+ final stdoutController = StreamController<List<int>>(sync: true);
stdoutController.stream.map(utf8.decode).listen(stdoutLog.add);
- final stdout = new IOSink(stdoutController);
- final stderrController = new StreamController<List<int>>(sync: true);
+ final stdout = IOSink(stdoutController);
+ final stderrController = StreamController<List<int>>(sync: true);
stderrController.stream.map(utf8.decode).listen(stderrLog.add);
- final stderr = new IOSink(stderrController);
+ final stderr = IOSink(stderrController);
- processManager = new ProcessManager(
+ processManager = ProcessManager(
stdin: sharedStdIn,
stdout: stdout,
stderr: stderr,
diff --git a/pkgs/io/test/shared_stdin_test.dart b/pkgs/io/test/shared_stdin_test.dart
index dea13ef..bdb311d 100644
--- a/pkgs/io/test/shared_stdin_test.dart
+++ b/pkgs/io/test/shared_stdin_test.dart
@@ -13,8 +13,8 @@
SharedStdIn sharedStdIn;
setUp(() async {
- fakeStdIn = new StreamController<String>(sync: true);
- sharedStdIn = new SharedStdIn(fakeStdIn.stream.map((s) => s.codeUnits));
+ fakeStdIn = StreamController<String>(sync: true);
+ sharedStdIn = SharedStdIn(fakeStdIn.stream.map((s) => s.codeUnits));
});
test('should allow a single subscriber', () async {
@@ -71,7 +71,7 @@
test('should allow listening for new lines multiple times', () async {
expect(sharedStdIn.nextLine(), completion('Hello World'));
fakeStdIn.add('Hello World\n');
- await new Future<Null>.value();
+ await Future<Null>.value();
expect(sharedStdIn.nextLine(), completion('Hello World'));
fakeStdIn.add('Hello World\n');