fix latest pedantic lints (dart-lang/io#47)
diff --git a/pkgs/io/example/ansi_code_example.dart b/pkgs/io/example/ansi_code_example.dart index e622f03..136dde9 100644 --- a/pkgs/io/example/ansi_code_example.dart +++ b/pkgs/io/example/ansi_code_example.dart
@@ -26,7 +26,7 @@ print(wrapWith('** $name **', [styleBold, styleUnderlined])); for (var code in values) { final header = - "${code.name.padRight(longest)} ${code.code.toString().padLeft(3)}"; + '${code.name.padRight(longest)} ${code.code.toString().padLeft(3)}'; print("$header: ${code.wrap('Sample', forScript: forScript)}"); }
diff --git a/pkgs/io/lib/src/ansi_code.dart b/pkgs/io/lib/src/ansi_code.dart index 10a20fa..7b24284 100644 --- a/pkgs/io/lib/src/ansi_code.dart +++ b/pkgs/io/lib/src/ansi_code.dart
@@ -30,7 +30,7 @@ /// Allows overriding [ansiOutputEnabled] to [enableAnsiOutput] for the code run /// within [body]. -T overrideAnsiOutput<T>(bool enableAnsiOutput, T body()) => +T overrideAnsiOutput<T>(bool enableAnsiOutput, T Function() body) => runZoned(body, zoneValues: <Object, Object>{AnsiCode: enableAnsiOutput}); /// The type of code represented by [AnsiCode]. @@ -76,10 +76,10 @@ const AnsiCode._(this.name, this.type, this.code, this.reset); /// Represents the value escaped for use in terminal output. - String get escape => "$_ansiEscapeLiteral[${code}m"; + String get escape => '$_ansiEscapeLiteral[${code}m'; /// Represents the value as an unescaped literal suitable for scripts. - String get escapeForScript => "$_ansiEscapeForScript[${code}m"; + String get escapeForScript => '$_ansiEscapeForScript[${code}m'; String _escapeValue({bool forScript = false}) { forScript ??= false; @@ -99,11 +99,11 @@ String wrap(String value, {bool forScript = false}) => _isNoop(type == AnsiCodeType.reset, value, forScript) ? value - : "${_escapeValue(forScript: forScript)}$value" - "${reset._escapeValue(forScript: forScript)}"; + : '${_escapeValue(forScript: forScript)}$value' + '${reset._escapeValue(forScript: forScript)}'; @override - String toString() => "$name ${type._name} ($code)"; + String toString() => '$name ${type._name} ($code)'; } /// Returns a [String] formatted with [codes]. @@ -137,19 +137,19 @@ foreground++; if (foreground > 1) { throw ArgumentError.value(codes, 'codes', - "Cannot contain more than one foreground color code."); + 'Cannot contain more than one foreground color code.'); } break; case AnsiCodeType.background: background++; if (background > 1) { throw ArgumentError.value(codes, 'codes', - "Cannot contain more than one foreground color code."); + 'Cannot contain more than one foreground color code.'); } break; case AnsiCodeType.reset: throw ArgumentError.value( - codes, 'codes', "Cannot contain reset codes."); + codes, 'codes', 'Cannot contain reset codes.'); break; } } @@ -158,7 +158,7 @@ final escapeValue = forScript ? _ansiEscapeForScript : _ansiEscapeLiteral; return "$escapeValue[${sortedCodes.join(';')}m$value" - "${resetAll._escapeValue(forScript: forScript)}"; + '${resetAll._escapeValue(forScript: forScript)}'; } //
diff --git a/pkgs/io/lib/src/permissions.dart b/pkgs/io/lib/src/permissions.dart index 0056bbf..789d327 100644 --- a/pkgs/io/lib/src/permissions.dart +++ b/pkgs/io/lib/src/permissions.dart
@@ -55,7 +55,7 @@ FutureOr<bool> isExecutable( String path, { bool isWindows, - FutureOr<FileStat> getStat(String path) = FileStat.stat, + FutureOr<FileStat> Function(String path) getStat = FileStat.stat, }) { // Windows has no concept of executable. if (isWindows ?? Platform.isWindows) return true;
diff --git a/pkgs/io/lib/src/shared_stdin.dart b/pkgs/io/lib/src/shared_stdin.dart index 8bd59b1..fb32829 100644 --- a/pkgs/io/lib/src/shared_stdin.dart +++ b/pkgs/io/lib/src/shared_stdin.dart
@@ -57,22 +57,18 @@ void _onInput(List<int> event) => _getCurrent().add(event); - StreamController<List<int>> _getCurrent() { - if (_current == null) { - _current = StreamController<List<int>>( + StreamController<List<int>> _getCurrent() => + _current ??= StreamController<List<int>>( onCancel: () { _current = null; }, sync: true); - } - return _current; - } @override StreamSubscription<List<int>> listen( - void onData(List<int> event), { + void Function(List<int> event) onData, { Function onError, - void onDone(), + void Function() onDone, bool cancelOnError, }) { if (_sub == null) {
diff --git a/pkgs/io/lib/src/shell_words.dart b/pkgs/io/lib/src/shell_words.dart index 279680b..8e057d7 100644 --- a/pkgs/io/lib/src/shell_words.dart +++ b/pkgs/io/lib/src/shell_words.dart
@@ -139,7 +139,7 @@ void _checkUnmatchedQuote(StringScanner scanner, int openingQuote) { if (!scanner.isDone) return; final type = scanner.substring(openingQuote, openingQuote + 1) == '"' - ? "double" - : "single"; - scanner.error("Unmatched $type quote.", position: openingQuote, length: 1); + ? 'double' + : 'single'; + scanner.error('Unmatched $type quote.', position: openingQuote, length: 1); }
diff --git a/pkgs/io/test/ansi_code_test.dart b/pkgs/io/test/ansi_code_test.dart index 7d411ca..3b11131 100644 --- a/pkgs/io/test/ansi_code_test.dart +++ b/pkgs/io/test/ansi_code_test.dart
@@ -13,18 +13,18 @@ void main() { group('ansiOutputEnabled', () { - test("default value matches dart:io", () { + test('default value matches dart:io', () { expect(ansiOutputEnabled, stdout.supportsAnsiEscapes && stderr.supportsAnsiEscapes); }); - test("override true", () { + test('override true', () { overrideAnsiOutput(true, () { expect(ansiOutputEnabled, isTrue); }); }); - test("override false", () { + test('override false', () { overrideAnsiOutput(false, () { expect(ansiOutputEnabled, isFalse); }); @@ -51,11 +51,11 @@ final foreground = foregroundColors[i]; expect(foreground.type, AnsiCodeType.foreground); expect(foreground.name.toLowerCase(), foreground.name, - reason: "All names should be lower case"); + reason: 'All names should be lower case'); final background = backgroundColors[i]; expect(background.type, AnsiCodeType.background); expect(background.name.toLowerCase(), background.name, - reason: "All names should be lower case"); + reason: 'All names should be lower case'); expect(foreground.name, background.name); @@ -68,7 +68,7 @@ for (var style in styles) { expect(style.type, AnsiCodeType.style); expect(style.name.toLowerCase(), style.name, - reason: "All names should be lower case"); + reason: 'All names should be lower case'); if (style == styleBold) { expect(style.reset, resetBold); } else { @@ -84,25 +84,25 @@ forScript ? _ansiEscapeForScript : _ansiEscapeLiteral; group('wrap', () { - _test("color", () { + _test('color', () { final expected = '$escapeLiteral[34m$sampleInput$escapeLiteral[0m'; expect(blue.wrap(sampleInput, forScript: forScript), expected); }); - _test("style", () { + _test('style', () { final expected = '$escapeLiteral[1m$sampleInput$escapeLiteral[22m'; expect(styleBold.wrap(sampleInput, forScript: forScript), expected); }); - _test("style", () { + _test('style', () { final expected = '$escapeLiteral[34m$sampleInput$escapeLiteral[0m'; expect(blue.wrap(sampleInput, forScript: forScript), expected); }); - test("empty", () { + test('empty', () { expect(blue.wrap('', forScript: forScript), ''); }); @@ -112,27 +112,27 @@ }); group('wrapWith', () { - _test("foreground", () { + _test('foreground', () { final expected = '$escapeLiteral[34m$sampleInput$escapeLiteral[0m'; expect(wrapWith(sampleInput, [blue], forScript: forScript), expected); }); - _test("background", () { + _test('background', () { final expected = '$escapeLiteral[44m$sampleInput$escapeLiteral[0m'; expect(wrapWith(sampleInput, [backgroundBlue], forScript: forScript), expected); }); - _test("style", () { + _test('style', () { final expected = '$escapeLiteral[1m$sampleInput$escapeLiteral[0m'; expect(wrapWith(sampleInput, [styleBold], forScript: forScript), expected); }); - _test("2 styles", () { + _test('2 styles', () { final expected = '$escapeLiteral[1;3m$sampleInput$escapeLiteral[0m'; expect( @@ -141,13 +141,13 @@ expected); }); - _test("2 foregrounds", () { + _test('2 foregrounds', () { expect( () => wrapWith(sampleInput, [blue, white], forScript: forScript), throwsArgumentError); }); - _test("multi", () { + _test('multi', () { final expected = '$escapeLiteral[1;4;34;107m$sampleInput$escapeLiteral[0m'; @@ -162,7 +162,7 @@ expect(wrapWith(sampleInput, []), sampleInput); }); - _test("empty", () { + _test('empty', () { expect( wrapWith('', [blue, backgroundWhite, styleBold], forScript: forScript), @@ -180,5 +180,5 @@ } } -void _test<T>(String name, T body()) => +void _test<T>(String name, T Function() body) => test(name, () => overrideAnsiOutput<T>(true, body));
diff --git a/pkgs/io/test/shell_words_test.dart b/pkgs/io/test/shell_words_test.dart index 610c36d..426680e 100644 --- a/pkgs/io/test/shell_words_test.dart +++ b/pkgs/io/test/shell_words_test.dart
@@ -7,161 +7,161 @@ import 'package:io/io.dart'; void main() { - group("shellSplit()", () { - group("returns an empty list for", () { - test("an empty string", () { - expect(shellSplit(""), isEmpty); + group('shellSplit()', () { + group('returns an empty list for', () { + test('an empty string', () { + expect(shellSplit(''), isEmpty); }); - test("spaces", () { - expect(shellSplit(" "), isEmpty); + test('spaces', () { + expect(shellSplit(' '), isEmpty); }); - test("tabs", () { - expect(shellSplit("\t\t\t"), isEmpty); + test('tabs', () { + expect(shellSplit('\t\t\t'), isEmpty); }); - test("newlines", () { - expect(shellSplit("\n\n\n"), isEmpty); + test('newlines', () { + expect(shellSplit('\n\n\n'), isEmpty); }); - test("a comment", () { - expect(shellSplit("#foo bar baz"), isEmpty); + test('a comment', () { + expect(shellSplit('#foo bar baz'), isEmpty); }); - test("a mix", () { - expect(shellSplit(" \t\n# foo"), isEmpty); + test('a mix', () { + expect(shellSplit(' \t\n# foo'), isEmpty); }); }); - group("parses unquoted", () { - test("a single token", () { - expect(shellSplit("foo"), equals(["foo"])); + group('parses unquoted', () { + test('a single token', () { + expect(shellSplit('foo'), equals(['foo'])); }); - test("multiple tokens", () { - expect(shellSplit("foo bar baz"), equals(["foo", "bar", "baz"])); + test('multiple tokens', () { + expect(shellSplit('foo bar baz'), equals(['foo', 'bar', 'baz'])); }); - test("tokens separated by tabs", () { - expect(shellSplit("foo\tbar\tbaz"), equals(["foo", "bar", "baz"])); + test('tokens separated by tabs', () { + expect(shellSplit('foo\tbar\tbaz'), equals(['foo', 'bar', 'baz'])); }); - test("tokens separated by newlines", () { - expect(shellSplit("foo\nbar\nbaz"), equals(["foo", "bar", "baz"])); + test('tokens separated by newlines', () { + expect(shellSplit('foo\nbar\nbaz'), equals(['foo', 'bar', 'baz'])); }); - test("a token after whitespace", () { - expect(shellSplit(" \t\nfoo"), equals(["foo"])); + test('a token after whitespace', () { + expect(shellSplit(' \t\nfoo'), equals(['foo'])); }); - test("a token before whitespace", () { - expect(shellSplit("foo \t\n"), equals(["foo"])); + test('a token before whitespace', () { + expect(shellSplit('foo \t\n'), equals(['foo'])); }); - test("a token with a hash", () { - expect(shellSplit("foo#bar"), equals(["foo#bar"])); + test('a token with a hash', () { + expect(shellSplit('foo#bar'), equals(['foo#bar'])); }); - test("a token before a comment", () { - expect(shellSplit("foo #bar"), equals(["foo"])); + test('a token before a comment', () { + expect(shellSplit('foo #bar'), equals(['foo'])); }); - test("dynamic shell features", () { + test('dynamic shell features', () { expect( - shellSplit(r"foo $(bar baz)"), equals(["foo", r"$(bar", "baz)"])); - expect(shellSplit("foo `bar baz`"), equals(["foo", "`bar", "baz`"])); - expect(shellSplit(r"foo $bar | baz"), - equals(["foo", r"$bar", "|", "baz"])); + shellSplit(r'foo $(bar baz)'), equals(['foo', r'$(bar', 'baz)'])); + expect(shellSplit('foo `bar baz`'), equals(['foo', '`bar', 'baz`'])); + expect(shellSplit(r'foo $bar | baz'), + equals(['foo', r'$bar', '|', 'baz'])); }); }); - group("parses a backslash", () { - test("before a normal character", () { - expect(shellSplit(r"foo\bar"), equals(["foobar"])); + group('parses a backslash', () { + test('before a normal character', () { + expect(shellSplit(r'foo\bar'), equals(['foobar'])); }); - test("before a dynamic shell feature", () { - expect(shellSplit(r"foo\$bar"), equals([r"foo$bar"])); + test('before a dynamic shell feature', () { + expect(shellSplit(r'foo\$bar'), equals([r'foo$bar'])); }); - test("before a single quote", () { + test('before a single quote', () { expect(shellSplit(r"foo\'bar"), equals(["foo'bar"])); }); - test("before a double quote", () { + test('before a double quote', () { expect(shellSplit(r'foo\"bar'), equals(['foo"bar'])); }); - test("before a space", () { + test('before a space', () { expect(shellSplit(r'foo\ bar'), equals(['foo bar'])); }); - test("at the beginning of a token", () { + test('at the beginning of a token', () { expect(shellSplit(r'\ foo'), equals([' foo'])); }); - test("before whitespace followed by a hash", () { + test('before whitespace followed by a hash', () { expect(shellSplit(r'\ #foo'), equals([' #foo'])); }); - test("before a newline in a token", () { + test('before a newline in a token', () { expect(shellSplit('foo\\\nbar'), equals(['foobar'])); }); - test("before a newline outside a token", () { + test('before a newline outside a token', () { expect(shellSplit('foo \\\n bar'), equals(['foo', 'bar'])); }); - test("before a backslash", () { + test('before a backslash', () { expect(shellSplit(r'foo\\bar'), equals([r'foo\bar'])); }); }); - group("parses single quotes", () { - test("that are empty", () { - expect(shellSplit("''"), equals([""])); + group('parses single quotes', () { + test('that are empty', () { + expect(shellSplit("''"), equals([''])); }); - test("that contain normal characters", () { - expect(shellSplit("'foo'"), equals(["foo"])); + test('that contain normal characters', () { + expect(shellSplit("'foo'"), equals(['foo'])); }); - test("that contain active characters", () { + test('that contain active characters', () { expect(shellSplit("'\" \\#'"), equals([r'" \#'])); }); - test("before a hash", () { + test('before a hash', () { expect(shellSplit("''#foo"), equals([r'#foo'])); }); - test("inside a token", () { + test('inside a token', () { expect(shellSplit("foo'bar baz'qux"), equals([r'foobar bazqux'])); }); - test("without a closing quote", () { + test('without a closing quote', () { expect(() => shellSplit("'foo bar"), throwsFormatException); }); }); - group("parses double quotes", () { - test("that are empty", () { - expect(shellSplit('""'), equals([""])); + group('parses double quotes', () { + test('that are empty', () { + expect(shellSplit('""'), equals([''])); }); - test("that contain normal characters", () { - expect(shellSplit('"foo"'), equals(["foo"])); + test('that contain normal characters', () { + expect(shellSplit('"foo"'), equals(['foo'])); }); - test("that contain otherwise-active characters", () { + test('that contain otherwise-active characters', () { expect(shellSplit('"\' #"'), equals(["' #"])); }); - test("that contain escaped characters", () { + test('that contain escaped characters', () { expect(shellSplit(r'"\$\`\"\\"'), equals(['\$`"\\'])); }); - test("that contain an escaped newline", () { + test('that contain an escaped newline', () { expect(shellSplit('"\\\n"'), equals([''])); }); @@ -169,15 +169,15 @@ expect(shellSplit(r'"f\oo"'), equals([r'f\oo'])); }); - test("before a hash", () { + test('before a hash', () { expect(shellSplit('""#foo'), equals([r'#foo'])); }); - test("inside a token", () { + test('inside a token', () { expect(shellSplit('foo"bar baz"qux'), equals([r'foobar bazqux'])); }); - test("without a closing quote", () { + test('without a closing quote', () { expect(() => shellSplit('"foo bar'), throwsFormatException); expect(() => shellSplit('"foo bar\\'), throwsFormatException); });