Move from pedantic to lints package (#208)
Fix existing violations of lints:
- `prefer_initializing_formals`
- `unnecessary_string_interpolations`
- `prefer_function_declarations_over_variables`
Ignore one case of `prefer_void_to_null` to work around
https://github.com/dart-lang/linter/issues/2792
diff --git a/analysis_options.yaml b/analysis_options.yaml
index b7dcb08..585446f 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,4 +1,4 @@
-include: package:pedantic/analysis_options.yaml
+include: package:lints/recommended.yaml
linter:
rules:
- avoid_null_checks_in_equality_operators
diff --git a/lib/command_runner.dart b/lib/command_runner.dart
index 79fa282..007c597 100644
--- a/lib/command_runner.dart
+++ b/lib/command_runner.dart
@@ -478,7 +478,7 @@
if (category != '') {
buffer.writeln();
buffer.writeln();
- buffer.write('$category');
+ buffer.write(category);
}
for (var command in commandsByCategory[category]!) {
var lines = wrapTextAsLines(command.summary,
diff --git a/lib/src/arg_parser.dart b/lib/src/arg_parser.dart
index 42af6bf..ef91b80 100644
--- a/lib/src/arg_parser.dart
+++ b/lib/src/arg_parser.dart
@@ -70,12 +70,11 @@
ArgParser._(Map<String, Option> options, Map<String, ArgParser> commands,
this._aliases,
- {bool allowTrailingOptions = true, this.usageLineLength})
+ {this.allowTrailingOptions = true, this.usageLineLength})
: _options = options,
options = UnmodifiableMapView(options),
_commands = commands,
- commands = UnmodifiableMapView(commands),
- allowTrailingOptions = allowTrailingOptions;
+ commands = UnmodifiableMapView(commands);
/// Defines a command.
///
diff --git a/lib/src/help_command.dart b/lib/src/help_command.dart
index d598cfd..9e2f5a3 100644
--- a/lib/src/help_command.dart
+++ b/lib/src/help_command.dart
@@ -22,6 +22,8 @@
bool get hidden => true;
@override
+ // TODO: Remove when https://github.com/dart-lang/linter/issues/2792 is fixed.
+ // ignore: prefer_void_to_null
Null run() {
// Show the default help if no command was specified.
if (argResults!.rest.isEmpty) {
diff --git a/lib/src/option.dart b/lib/src/option.dart
index a7c6ab8..09e5d20 100644
--- a/lib/src/option.dart
+++ b/lib/src/option.dart
@@ -103,7 +103,7 @@
Map<String, String>? allowedHelp,
this.defaultsTo,
this.callback,
- OptionType type,
+ this.type,
{this.negatable,
bool? splitCommas,
this.mandatory = false,
@@ -112,7 +112,6 @@
: allowed = allowed == null ? null : List.unmodifiable(allowed),
allowedHelp =
allowedHelp == null ? null : Map.unmodifiable(allowedHelp),
- type = type,
// If the user doesn't specify [splitCommas], it defaults to true for
// multiple options.
splitCommas = splitCommas ?? type == OptionType.multiple {
diff --git a/pubspec.yaml b/pubspec.yaml
index b2994c7..c5d81a3 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -9,5 +9,5 @@
sdk: '>=2.12.0 <3.0.0'
dev_dependencies:
- pedantic: ^1.10.0
+ lints: ^1.0.0
test: ^1.16.0
diff --git a/test/command_runner_test.dart b/test/command_runner_test.dart
index 3f152b0..cbf35cc 100644
--- a/test/command_runner_test.dart
+++ b/test/command_runner_test.dart
@@ -561,7 +561,7 @@
expect(
runner.run(['--asdf']),
throwsUsageException(
- 'Could not find an option named "asdf".', '$_defaultUsage'));
+ 'Could not find an option named "asdf".', _defaultUsage));
});
test('for a command throws the command usage', () {
diff --git a/test/parse_performance_test.dart b/test/parse_performance_test.dart
index 881fbfe..210f853 100644
--- a/test/parse_performance_test.dart
+++ b/test/parse_performance_test.dart
@@ -43,8 +43,8 @@
var multiplier = 10;
var largeList = List<String>.generate(baseSize * multiplier, (_) => string);
- var baseAction = () => parser.parse(baseList);
- var largeAction = () => parser.parse(largeList);
+ ArgResults baseAction() => parser.parse(baseList);
+ ArgResults largeAction() => parser.parse(largeList);
// Warm up JIT.
baseAction();