Skip to content

Commit

Permalink
Require Dart 3.0, update lints (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jun 7, 2023
1 parent ca06779 commit 3f03da8
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [dev, 2.18.0]
sdk: [dev, 3.0.0]
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand All @@ -47,7 +47,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [dev, 2.18.0]
sdk: [dev, 3.0.0]
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.5-wip

* Require Dart 3.0.

## 1.0.4

* Updates to the readme.
Expand Down
39 changes: 39 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
# https://dart.dev/guides/language/analysis-options
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_classes_with_only_static_members
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_this
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- comment_references
- join_return_with_assignment
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_const_constructors
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- prefer_relative_imports
- test_types_in_equals
- unnecessary_await_in_return
- unnecessary_breaks
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
- use_super_parameters
4 changes: 1 addition & 3 deletions lib/src/ansi_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:io' as io;

const _ansiEscapeLiteral = '\x1B';
const _ansiEscapeForScript = '\\033';
const _ansiEscapeForScript = r'\033';

/// Whether formatted ANSI output is enabled for [wrapWith] and [AnsiCode.wrap].
///
Expand Down Expand Up @@ -136,14 +136,12 @@ String? wrapWith(String? value, Iterable<AnsiCode> codes,
throw ArgumentError.value(codes, 'codes',
'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.');
}
break;
case AnsiCodeType.reset:
throw ArgumentError.value(
codes, 'codes', 'Cannot contain reset codes.');
Expand Down
19 changes: 7 additions & 12 deletions lib/src/permissions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ bool _hasPermission(
return (stat.mode & (1 << index)) != 0;
}

int _permissionBitIndex(_FilePermission permission, _FilePermissionRole role) {
switch (permission) {
case _FilePermission.setUid:
return 11;
case _FilePermission.setGid:
return 10;
case _FilePermission.sticky:
return 9;
default:
return (role.index * 3) + permission.index;
}
}
int _permissionBitIndex(_FilePermission permission, _FilePermissionRole role) =>
switch (permission) {
_FilePermission.setUid => 11,
_FilePermission.setGid => 10,
_FilePermission.sticky => 9,
_ => (role.index * 3) + permission.index
};

/// Returns whether [path] is considered an executable file on this OS.
///
Expand Down
28 changes: 10 additions & 18 deletions lib/src/process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ class _ForwardingSpawn extends Spawn {
}

_ForwardingSpawn._delegate(
io.Process delegate,
super.delegate,
this._stdInSub,
this._stdOutSub,
this._stdErrSub,
this._stdOut,
this._stdErr,
) : super._(delegate);
) : super._();

@override
void _onClosed() {
Expand All @@ -240,24 +240,16 @@ class _ForwardingSpawn extends Spawn {

class _UnixProcessManager extends ProcessManager {
const _UnixProcessManager(
Stream<List<int>> stdin,
io.IOSink stdout,
io.IOSink stderr,
) : super._(
stdin,
stdout,
stderr,
);
super.stdin,
super.stdout,
super.stderr,
) : super._();
}

class _WindowsProcessManager extends ProcessManager {
const _WindowsProcessManager(
Stream<List<int>> stdin,
io.IOSink stdout,
io.IOSink stderr,
) : super._(
stdin,
stdout,
stderr,
);
super.stdin,
super.stdout,
super.stderr,
) : super._();
}
5 changes: 0 additions & 5 deletions lib/src/shell_words.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ List<String> shellSplit(String command) {

hasToken = true;
token.writeCharCode(scanner.readChar());
break;

case $singleQuote:
hasToken = true;
Expand All @@ -59,7 +58,6 @@ List<String> shellSplit(String command) {
_checkUnmatchedQuote(scanner, firstQuote);
token.writeCharCode(scanner.readChar());
}
break;

case $doubleQuote:
hasToken = true;
Expand Down Expand Up @@ -99,7 +97,6 @@ List<String> shellSplit(String command) {
token.writeCharCode(scanner.readChar());
}
}
break;

case $hash:
// Section 2.3: If the current character is a '#' [and the previous
Expand All @@ -115,7 +112,6 @@ List<String> shellSplit(String command) {
while (!scanner.isDone && scanner.peekChar() != $lf) {
scanner.readChar();
}
break;

case $space:
case $tab:
Expand All @@ -124,7 +120,6 @@ List<String> shellSplit(String command) {
if (hasToken) results.add(token.toString());
hasToken = false;
token.clear();
break;

default:
hasToken = true;
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ name: io
description: >-
Utilities for the Dart VM Runtime including support for ANSI colors, file
copying, and standard exit code values.
version: 1.0.4
version: 1.0.5-wip
repository: https://github.com/dart-lang/io

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ^3.0.0

dependencies:
meta: ^1.3.0
path: ^1.8.0
string_scanner: ^1.1.0

dev_dependencies:
dart_flutter_team_lints: ^0.1.0
dart_flutter_team_lints: ^1.0.0
test: ^1.16.0
test_descriptor: ^2.0.0
5 changes: 4 additions & 1 deletion test/ansi_code_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
// BSD-style license that can be found in the LICENSE file.

@TestOn('vm')
library;

import 'dart:io';

import 'package:io/ansi.dart';
import 'package:test/test.dart';

const _ansiEscapeLiteral = '\x1B';
const _ansiEscapeForScript = '\\033';
const _ansiEscapeForScript = r'\033';
const sampleInput = 'sample input';

void main() {
Expand Down
2 changes: 2 additions & 0 deletions test/copy_path_test.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.

@TestOn('vm')
library;

import 'package:io/io.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
Expand Down
2 changes: 2 additions & 0 deletions test/permissions_test.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.

@TestOn('vm')
library;

import 'package:io/io.dart';
import 'package:test/test.dart';

Expand Down
4 changes: 2 additions & 2 deletions test/shell_words_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void main() {
});

test('that contain escaped characters', () {
expect(shellSplit(r'"\$\`\"\\"'), equals(['\$`"\\']));
expect(shellSplit(r'"\$\`\"\\"'), equals([r'$`"\']));
});

test('that contain an escaped newline', () {
Expand All @@ -178,7 +178,7 @@ void main() {

test('without a closing quote', () {
expect(() => shellSplit('"foo bar'), throwsFormatException);
expect(() => shellSplit('"foo bar\\'), throwsFormatException);
expect(() => shellSplit(r'"foo bar\'), throwsFormatException);
});
});
});
Expand Down

0 comments on commit 3f03da8

Please sign in to comment.