Enable and fix a number of lints (#21)
Bump min sdk
tiny tweak to pubspec
diff --git a/.travis.yml b/.travis.yml
index 8d6eeea..684344f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
language: dart
dart:
- - 2.0.0
+ - 2.2.0
- dev
dart_task:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b45182d..8121061 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+## 1.0.4-dev
+ * Require Dart 2.2.0.
+
## 1.0.3
* Require Dart 2.0.0.
* Fixed Tuple7's operator==.
diff --git a/analysis_options.yaml b/analysis_options.yaml
index ee63c14..9ac56b5 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,23 +1,22 @@
include: package:pedantic/analysis_options.yaml
+
analyzer:
strong-mode:
implicit-casts: false
- errors:
- dead_code: error
- override_on_non_overriding_method: error
- unused_element: error
- unused_import: error
- unused_local_variable: error
+
linter:
rules:
- always_declare_return_types
- annotate_overrides
- avoid_bool_literals_in_conditional_expressions
+ - avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_empty_else
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
+ - avoid_private_typedef_functions
+ - avoid_redundant_argument_values
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
@@ -29,6 +28,7 @@
- avoid_single_cascade_in_expression_statements
- avoid_types_as_parameter_names
- avoid_unused_constructor_parameters
+ - avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
@@ -48,10 +48,13 @@
- join_return_with_assignment
- library_names
- library_prefixes
+ - lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
+ - missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_duplicate_case_values
+ - no_runtimeType_toString
- non_constant_identifier_names
- null_closures
- omit_local_variable_types
@@ -61,24 +64,36 @@
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
+ - prefer_asserts_in_initializer_lists
- prefer_collection_literals
- prefer_conditional_assignment
+ - prefer_const_constructors
+ - prefer_const_declarations
- prefer_contains
- prefer_equal_for_default_values
+ - prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_locals
+ - prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_initializing_formals
+ - prefer_inlined_adds
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
+ - prefer_is_not_operator
- prefer_null_aware_operators
+ - prefer_relative_imports
- prefer_single_quotes
- prefer_typing_uninitialized_variables
+ - prefer_void_to_null
+ - provide_deprecation_message
- recursive_getters
- slash_for_doc_comments
+ - sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
+ - type_annotate_public_apis
- type_init_formals
- unawaited_futures
- unnecessary_await_in_return
@@ -88,11 +103,15 @@
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
+ - unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
+ - unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- use_function_type_syntax_for_parameters
+ - use_is_even_rather_than_modulo
- use_rethrow_when_possible
+ - use_string_buffers
- valid_regexps
- void_checks
diff --git a/lib/tuple.dart b/lib/tuple.dart
index 5321f7c..7ca10f0 100644
--- a/lib/tuple.dart
+++ b/lib/tuple.dart
@@ -45,14 +45,10 @@
}
/// Returns a tuple with the first item set to the specified value.
- Tuple2<T1, T2> withItem1(T1 v) {
- return Tuple2<T1, T2>(v, item2);
- }
+ Tuple2<T1, T2> withItem1(T1 v) => Tuple2<T1, T2>(v, item2);
/// Returns a tuple with the second item set to the specified value.
- Tuple2<T1, T2> withItem2(T2 v) {
- return Tuple2<T1, T2>(item1, v);
- }
+ Tuple2<T1, T2> withItem2(T2 v) => Tuple2<T1, T2>(item1, v);
/// Creates a [List] containing the items of this [Tuple2].
///
@@ -65,7 +61,7 @@
String toString() => '[$item1, $item2]';
@override
- bool operator ==(other) =>
+ bool operator ==(Object other) =>
other is Tuple2 && other.item1 == item1 && other.item2 == item2;
@override
@@ -96,19 +92,13 @@
}
/// Returns a tuple with the first item set to the specified value.
- Tuple3<T1, T2, T3> withItem1(T1 v) {
- return Tuple3<T1, T2, T3>(v, item2, item3);
- }
+ Tuple3<T1, T2, T3> withItem1(T1 v) => Tuple3<T1, T2, T3>(v, item2, item3);
/// Returns a tuple with the second item set to the specified value.
- Tuple3<T1, T2, T3> withItem2(T2 v) {
- return Tuple3<T1, T2, T3>(item1, v, item3);
- }
+ Tuple3<T1, T2, T3> withItem2(T2 v) => Tuple3<T1, T2, T3>(item1, v, item3);
/// Returns a tuple with the third item set to the specified value.
- Tuple3<T1, T2, T3> withItem3(T3 v) {
- return Tuple3<T1, T2, T3>(item1, item2, v);
- }
+ Tuple3<T1, T2, T3> withItem3(T3 v) => Tuple3<T1, T2, T3>(item1, item2, v);
/// Creates a [List] containing the items of this [Tuple3].
///
@@ -121,7 +111,7 @@
String toString() => '[$item1, $item2, $item3]';
@override
- bool operator ==(other) =>
+ bool operator ==(Object other) =>
other is Tuple3 &&
other.item1 == item1 &&
other.item2 == item2 &&
@@ -159,24 +149,20 @@
}
/// Returns a tuple with the first item set to the specified value.
- Tuple4<T1, T2, T3, T4> withItem1(T1 v) {
- return Tuple4<T1, T2, T3, T4>(v, item2, item3, item4);
- }
+ Tuple4<T1, T2, T3, T4> withItem1(T1 v) =>
+ Tuple4<T1, T2, T3, T4>(v, item2, item3, item4);
/// Returns a tuple with the second item set to the specified value.
- Tuple4<T1, T2, T3, T4> withItem2(T2 v) {
- return Tuple4<T1, T2, T3, T4>(item1, v, item3, item4);
- }
+ Tuple4<T1, T2, T3, T4> withItem2(T2 v) =>
+ Tuple4<T1, T2, T3, T4>(item1, v, item3, item4);
/// Returns a tuple with the third item set to the specified value.
- Tuple4<T1, T2, T3, T4> withItem3(T3 v) {
- return Tuple4<T1, T2, T3, T4>(item1, item2, v, item4);
- }
+ Tuple4<T1, T2, T3, T4> withItem3(T3 v) =>
+ Tuple4<T1, T2, T3, T4>(item1, item2, v, item4);
/// Returns a tuple with the fourth item set to the specified value.
- Tuple4<T1, T2, T3, T4> withItem4(T4 v) {
- return Tuple4<T1, T2, T3, T4>(item1, item2, item3, v);
- }
+ Tuple4<T1, T2, T3, T4> withItem4(T4 v) =>
+ Tuple4<T1, T2, T3, T4>(item1, item2, item3, v);
/// Creates a [List] containing the items of this [Tuple4].
///
@@ -189,7 +175,7 @@
String toString() => '[$item1, $item2, $item3, $item4]';
@override
- bool operator ==(other) =>
+ bool operator ==(Object other) =>
other is Tuple4 &&
other.item1 == item1 &&
other.item2 == item2 &&
@@ -232,29 +218,24 @@
}
/// Returns a tuple with the first item set to the specified value.
- Tuple5<T1, T2, T3, T4, T5> withItem1(T1 v) {
- return Tuple5<T1, T2, T3, T4, T5>(v, item2, item3, item4, item5);
- }
+ Tuple5<T1, T2, T3, T4, T5> withItem1(T1 v) =>
+ Tuple5<T1, T2, T3, T4, T5>(v, item2, item3, item4, item5);
/// Returns a tuple with the second item set to the specified value.
- Tuple5<T1, T2, T3, T4, T5> withItem2(T2 v) {
- return Tuple5<T1, T2, T3, T4, T5>(item1, v, item3, item4, item5);
- }
+ Tuple5<T1, T2, T3, T4, T5> withItem2(T2 v) =>
+ Tuple5<T1, T2, T3, T4, T5>(item1, v, item3, item4, item5);
/// Returns a tuple with the third item set to the specified value.
- Tuple5<T1, T2, T3, T4, T5> withItem3(T3 v) {
- return Tuple5<T1, T2, T3, T4, T5>(item1, item2, v, item4, item5);
- }
+ Tuple5<T1, T2, T3, T4, T5> withItem3(T3 v) =>
+ Tuple5<T1, T2, T3, T4, T5>(item1, item2, v, item4, item5);
/// Returns a tuple with the fourth item set to the specified value.
- Tuple5<T1, T2, T3, T4, T5> withItem4(T4 v) {
- return Tuple5<T1, T2, T3, T4, T5>(item1, item2, item3, v, item5);
- }
+ Tuple5<T1, T2, T3, T4, T5> withItem4(T4 v) =>
+ Tuple5<T1, T2, T3, T4, T5>(item1, item2, item3, v, item5);
/// Returns a tuple with the fifth item set to the specified value.
- Tuple5<T1, T2, T3, T4, T5> withItem5(T5 v) {
- return Tuple5<T1, T2, T3, T4, T5>(item1, item2, item3, item4, v);
- }
+ Tuple5<T1, T2, T3, T4, T5> withItem5(T5 v) =>
+ Tuple5<T1, T2, T3, T4, T5>(item1, item2, item3, item4, v);
/// Creates a [List] containing the items of this [Tuple5].
///
@@ -267,7 +248,7 @@
String toString() => '[$item1, $item2, $item3, $item4, $item5]';
@override
- bool operator ==(other) =>
+ bool operator ==(Object other) =>
other is Tuple5 &&
other.item1 == item1 &&
other.item2 == item2 &&
@@ -320,34 +301,28 @@
}
/// Returns a tuple with the first item set to the specified value.
- Tuple6<T1, T2, T3, T4, T5, T6> withItem1(T1 v) {
- return Tuple6<T1, T2, T3, T4, T5, T6>(v, item2, item3, item4, item5, item6);
- }
+ Tuple6<T1, T2, T3, T4, T5, T6> withItem1(T1 v) =>
+ Tuple6<T1, T2, T3, T4, T5, T6>(v, item2, item3, item4, item5, item6);
/// Returns a tuple with the second item set to the specified value.
- Tuple6<T1, T2, T3, T4, T5, T6> withItem2(T2 v) {
- return Tuple6<T1, T2, T3, T4, T5, T6>(item1, v, item3, item4, item5, item6);
- }
+ Tuple6<T1, T2, T3, T4, T5, T6> withItem2(T2 v) =>
+ Tuple6<T1, T2, T3, T4, T5, T6>(item1, v, item3, item4, item5, item6);
/// Returns a tuple with the third item set to the specified value.
- Tuple6<T1, T2, T3, T4, T5, T6> withItem3(T3 v) {
- return Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, v, item4, item5, item6);
- }
+ Tuple6<T1, T2, T3, T4, T5, T6> withItem3(T3 v) =>
+ Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, v, item4, item5, item6);
/// Returns a tuple with the fourth item set to the specified value.
- Tuple6<T1, T2, T3, T4, T5, T6> withItem4(T4 v) {
- return Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, item3, v, item5, item6);
- }
+ Tuple6<T1, T2, T3, T4, T5, T6> withItem4(T4 v) =>
+ Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, item3, v, item5, item6);
/// Returns a tuple with the fifth item set to the specified value.
- Tuple6<T1, T2, T3, T4, T5, T6> withItem5(T5 v) {
- return Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, item3, item4, v, item6);
- }
+ Tuple6<T1, T2, T3, T4, T5, T6> withItem5(T5 v) =>
+ Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, item3, item4, v, item6);
/// Returns a tuple with the sixth item set to the specified value.
- Tuple6<T1, T2, T3, T4, T5, T6> withItem6(T6 v) {
- return Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, item3, item4, item5, v);
- }
+ Tuple6<T1, T2, T3, T4, T5, T6> withItem6(T6 v) =>
+ Tuple6<T1, T2, T3, T4, T5, T6>(item1, item2, item3, item4, item5, v);
/// Creates a [List] containing the items of this [Tuple5].
///
@@ -360,7 +335,7 @@
String toString() => '[$item1, $item2, $item3, $item4, $item5, $item6]';
@override
- bool operator ==(other) =>
+ bool operator ==(Object other) =>
other is Tuple6 &&
other.item1 == item1 &&
other.item2 == item2 &&
@@ -424,46 +399,39 @@
}
/// Returns a tuple with the first item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem1(T1 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- v, item2, item3, item4, item5, item6, item7);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem1(T1 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ v, item2, item3, item4, item5, item6, item7);
/// Returns a tuple with the second item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem2(T2 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- item1, v, item3, item4, item5, item6, item7);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem2(T2 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ item1, v, item3, item4, item5, item6, item7);
/// Returns a tuple with the third item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem3(T3 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- item1, item2, v, item4, item5, item6, item7);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem3(T3 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ item1, item2, v, item4, item5, item6, item7);
/// Returns a tuple with the fourth item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem4(T4 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- item1, item2, item3, v, item5, item6, item7);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem4(T4 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ item1, item2, item3, v, item5, item6, item7);
/// Returns a tuple with the fifth item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem5(T5 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- item1, item2, item3, item4, v, item6, item7);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem5(T5 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ item1, item2, item3, item4, v, item6, item7);
/// Returns a tuple with the sixth item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem6(T6 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- item1, item2, item3, item4, item5, v, item7);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem6(T6 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ item1, item2, item3, item4, item5, v, item7);
/// Returns a tuple with the seventh item set to the specified value.
- Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem7(T7 v) {
- return Tuple7<T1, T2, T3, T4, T5, T6, T7>(
- item1, item2, item3, item4, item5, item6, v);
- }
+ Tuple7<T1, T2, T3, T4, T5, T6, T7> withItem7(T7 v) =>
+ Tuple7<T1, T2, T3, T4, T5, T6, T7>(
+ item1, item2, item3, item4, item5, item6, v);
/// Creates a [List] containing the items of this [Tuple5].
///
@@ -478,7 +446,7 @@
'[$item1, $item2, $item3, $item4, $item5, $item6, $item7]';
@override
- bool operator ==(other) =>
+ bool operator ==(Object other) =>
other is Tuple7 &&
other.item1 == item1 &&
other.item2 == item2 &&
diff --git a/pubspec.yaml b/pubspec.yaml
index 92ed9e6..f950a62 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -5,11 +5,11 @@
homepage: https://github.com/google/tuple.dart
environment:
- sdk: '>=2.0.0 <3.0.0'
+ sdk: '>=2.2.0 <3.0.0'
dependencies:
quiver: '>=0.22.0 <3.0.0'
dev_dependencies:
pedantic: ^1.2.0
- test: '>=1.0.0 <2.0.0'
+ test: ^1.0.0
diff --git a/test/tuple_test.dart b/test/tuple_test.dart
index 657451d..006cdc4 100644
--- a/test/tuple_test.dart
+++ b/test/tuple_test.dart
@@ -2,6 +2,8 @@
// file for details. All rights reserved. Use of this source code is governed
// by a BSD-style license that can be found in the LICENSE file.
+// ignore_for_file: prefer_const_constructors
+
import 'package:test/test.dart';
import 'package:tuple/tuple.dart';
@@ -54,7 +56,7 @@
test('returns fixed list by default', () {
final list = t.toList();
expect(list, orderedEquals([1, 'a']));
- expect(() => list.add(1), throwsA(TypeMatcher<UnsupportedError>()));
+ expect(() => list.add(1), throwsA(isA<UnsupportedError>()));
});
test('returns growable list when told so', () {
@@ -165,7 +167,7 @@
test('returns fixed list by default', () {
final list = t.toList();
expect(list, orderedEquals([1, 'a', 10]));
- expect(() => list.add(1), throwsA(TypeMatcher<UnsupportedError>()));
+ expect(() => list.add(1), throwsA(isA<UnsupportedError>()));
});
test('returns growable list when told so', () {
@@ -298,7 +300,7 @@
test('returns fixed list by default', () {
final list = t.toList();
expect(list, orderedEquals([1, 'a', 10, 'b']));
- expect(() => list.add(1), throwsA(TypeMatcher<UnsupportedError>()));
+ expect(() => list.add(1), throwsA(isA<UnsupportedError>()));
});
test('returns growable list when told so', () {
@@ -463,7 +465,7 @@
test('returns fixed list by default', () {
final list = t.toList();
expect(list, orderedEquals([1, 'a', 10, 'b', 100]));
- expect(() => list.add(1), throwsA(TypeMatcher<UnsupportedError>()));
+ expect(() => list.add(1), throwsA(isA<UnsupportedError>()));
});
test('returns growable list when told so', () {
@@ -672,7 +674,7 @@
test('returns fixed list by default', () {
final list = t.toList();
expect(list, orderedEquals([1, 'a', 10, 'b', 100, 'c']));
- expect(() => list.add(1), throwsA(TypeMatcher<UnsupportedError>()));
+ expect(() => list.add(1), throwsA(isA<UnsupportedError>()));
});
test('returns growable list when told so', () {
@@ -916,7 +918,7 @@
test('returns fixed list by default', () {
final list = t.toList();
expect(list, orderedEquals([1, 'a', 10, 'b', 100, 'c', 1000]));
- expect(() => list.add(1), throwsA(TypeMatcher<UnsupportedError>()));
+ expect(() => list.add(1), throwsA(isA<UnsupportedError>()));
});
test('returns growable list when told so', () {