Skip to content

Commit

Permalink
Update to latest lints, require Dart 3.3 (dart-archive/args#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored Apr 17, 2024
1 parent de170f5 commit 38b1c25
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkgs/args/.github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Publish

on:
pull_request:
branches: [ master ]
branches: [ main ]
push:
tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]

Expand Down
8 changes: 3 additions & 5 deletions pkgs/args/.github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Dart CI
on:
# Run CI on pushes to the main branch, and on PRs against main.
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
schedule:
- cron: "0 0 * * 0"
env:
Expand Down Expand Up @@ -44,10 +44,8 @@ jobs:
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package
os: [ubuntu-latest]
# Add stable if the package should also be tested on stable
sdk: ['3.0', dev]
sdk: ['3.3', dev]
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30
Expand Down
4 changes: 4 additions & 0 deletions pkgs/args/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.5.1-wip

* Require Dart 3.3

## 2.5.0

* Introduce new typed `ArgResults` `flag(String)`, `option(String)`, and
Expand Down
4 changes: 0 additions & 4 deletions pkgs/args/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ linter:
rules:
- avoid_unused_constructor_parameters
- cancel_subscriptions
- comment_references
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_relative_imports
- test_types_in_equals
- unnecessary_await_in_return
- use_super_parameters
8 changes: 4 additions & 4 deletions pkgs/args/lib/src/arg_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ArgParser {

/// A list of the [Option]s in [options] intermingled with [String]
/// separators.
final _optionsAndSeparators = [];
final _optionsAndSeparators = <Object>[];

/// Whether or not this parser parses options that appear after non-option
/// arguments.
Expand Down Expand Up @@ -142,7 +142,7 @@ class ArgParser {
null,
null,
defaultsTo,
callback == null ? null : (value) => callback(value as bool),
callback == null ? null : (bool value) => callback(value),
OptionType.flag,
negatable: negatable,
hide: hide,
Expand Down Expand Up @@ -264,7 +264,7 @@ class ArgParser {
allowed,
allowedHelp,
defaultsTo?.toList() ?? <String>[],
callback == null ? null : (value) => callback(value as List<String>),
callback == null ? null : (List<String> value) => callback(value),
OptionType.multiple,
splitCommas: splitCommas,
hide: hide,
Expand All @@ -278,7 +278,7 @@ class ArgParser {
String? valueHelp,
Iterable<String>? allowed,
Map<String, String>? allowedHelp,
defaultsTo,
Object? defaultsTo,
Function? callback,
OptionType type,
{bool negatable = false,
Expand Down
2 changes: 1 addition & 1 deletion pkgs/args/lib/src/usage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class _Usage {
String _buildAllowedList(Option option) {
var isDefault = option.defaultsTo is List
? (option.defaultsTo as List).contains
: (value) => value == option.defaultsTo;
: (String value) => value == option.defaultsTo;

var allowedBuffer = StringBuffer();
allowedBuffer.write('[');
Expand Down
6 changes: 3 additions & 3 deletions pkgs/args/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: args
version: 2.5.0
version: 2.5.1-wip
description: >-
Library for defining parsers for parsing raw command-line arguments into a set
of options and values using GNU and POSIX style options.
Expand All @@ -9,8 +9,8 @@ topics:
- cli

environment:
sdk: ^3.0.0
sdk: ^3.3.0

dev_dependencies:
dart_flutter_team_lints: ^1.0.0
dart_flutter_team_lints: ^2.0.0
test: ^1.16.0
3 changes: 2 additions & 1 deletion pkgs/args/test/allow_anything_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void main() {
});

test('works as a subcommand in a CommandRunner', () async {
var commandRunner = CommandRunner('command', 'Description of command');
var commandRunner =
CommandRunner<void>('command', 'Description of command');
var command = AllowAnythingCommand();
commandRunner.addCommand(command);

Expand Down
7 changes: 4 additions & 3 deletions pkgs/args/test/command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:args/command_runner.dart';
import 'package:test/test.dart';

import 'test_utils.dart';

void main() {
Expand All @@ -12,7 +13,7 @@ void main() {
foo = FooCommand();

// Make sure [Command.runner] is set up.
CommandRunner('test', 'A test command runner.').addCommand(foo);
CommandRunner<void>('test', 'A test command runner.').addCommand(foo);
});

group('.invocation has a sane default', () {
Expand Down Expand Up @@ -92,7 +93,7 @@ Run "test help" to see global options.'''));
var wrapping = WrappingCommand();

// Make sure [Command.runner] is set up.
CommandRunner('longtest', 'A long-lined test command runner.')
CommandRunner<void>('longtest', 'A long-lined test command runner.')
.addCommand(wrapping);

wrapping.addSubcommand(LongCommand());
Expand All @@ -118,7 +119,7 @@ options.'''));
var longCommand = LongCommand();

// Make sure [Command.runner] is set up.
CommandRunner('longtest', 'A long-lined test command runner.')
CommandRunner<void>('longtest', 'A long-lined test command runner.')
.addCommand(longCommand);

expect(longCommand.usage, equals('''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/args/test/parse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void main() {

// This reified type is important in strong mode so that people can
// safely write "as List<String>".
expect(a, TypeMatcher<List<String>>());
expect(a, isA<List<String>>());
});

test(
Expand Down
2 changes: 1 addition & 1 deletion pkgs/args/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class AsyncCommand extends Command {
final takesArguments = false;

@override
Future run() => Future.value().then((_) => hasRun = true);
Future run() => Future<void>.value().then((_) => hasRun = true);
}

class AllowAnythingCommand extends Command {
Expand Down

0 comments on commit 38b1c25

Please sign in to comment.