cleanup and fix lints (#143)
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 9f2325c..e608f4c 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -11,12 +11,7 @@
dead_code: error
linter:
rules:
- #- annotate_overrides
- #- avoid_function_literals_in_foreach_calls
- - avoid_empty_else
- - avoid_init_to_null
- - avoid_null_checks_in_equality_operators
- - avoid_relative_lib_imports
+ - avoid_function_literals_in_foreach_calls
- avoid_returning_null
- avoid_unused_constructor_parameters
- await_only_futures
@@ -27,49 +22,28 @@
#- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- - empty_catches
- - empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
#- invariant_booleans
- iterable_contains_unrelated_type
- - library_names
- - library_prefixes
- list_remove_unrelated_type
- no_adjacent_strings_in_list
- non_constant_identifier_names
- #- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- - prefer_adjacent_string_concatenation
- #- prefer_collection_literals
- #- prefer_conditional_assignment
- prefer_const_constructors
- - prefer_equal_for_default_values
- - prefer_final_fields
- prefer_final_locals
- prefer_initializing_formals
- #- prefer_interpolation_to_compose_strings
- #- prefer_single_quotes
- #- prefer_typing_uninitialized_variables
- - prefer_generic_function_type_aliases
- - prefer_is_not_empty
- - slash_for_doc_comments
+ - prefer_interpolation_to_compose_strings
+ - prefer_typing_uninitialized_variables
- test_types_in_equals
- throw_in_finally
- - type_init_formals
- #- unnecessary_brace_in_string_interps
- unnecessary_brace_in_string_interps
- - unnecessary_const
- unnecessary_getters_setters
- unnecessary_lambdas
- - unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_statements
- - unnecessary_this
- - unrelated_type_equality_checks
- - valid_regexps
diff --git a/lib/src/css_class_set.dart b/lib/src/css_class_set.dart
index 3f98a33..e57c487 100644
--- a/lib/src/css_class_set.dart
+++ b/lib/src/css_class_set.dart
@@ -186,7 +186,9 @@
/// [iterable] from the element.
@override
void toggleAll(Iterable<String> iterable, [bool shouldAdd]) {
- iterable.forEach((e) => toggle(e, shouldAdd));
+ for (var e in iterable) {
+ toggle(e, shouldAdd);
+ }
}
/// Helper method used to modify the set of css classes on this element.
diff --git a/test/selectors/level1_lib.dart b/test/selectors/level1_lib.dart
index 388ae00..e22f9c4 100644
--- a/test/selectors/level1_lib.dart
+++ b/test/selectors/level1_lib.dart
@@ -72,13 +72,13 @@
void interfaceCheck(String type, obj) {
runTest(() {
final q = obj.querySelector is Function;
- assertTrue(q, type + ' supports querySelector.');
- }, type + ' supports querySelector');
+ assertTrue(q, '$type supports querySelector.');
+ }, '$type supports querySelector');
runTest(() {
final qa = obj.querySelectorAll is Function;
- assertTrue(qa, type + ' supports querySelectorAll.');
- }, type + ' supports querySelectorAll');
+ assertTrue(qa, '$type supports querySelectorAll.');
+ }, '$type supports querySelectorAll');
runTest(() {
final list = obj.querySelectorAll('div');
@@ -86,18 +86,20 @@
// ElementList which has extra properties. Needed for dart:html compat.
assertTrue(list is List<Element>,
'The result should be an instance of a NodeList');
- }, type + '.querySelectorAll returns NodeList instance');
+ }, '$type.querySelectorAll returns NodeList instance');
}
/*
* Verify that the NodeList returned by querySelectorAll is static and and that a new list is created after
* each call. A static list should not be affected by subsequent changes to the DOM.
*/
-void verifyStaticList(String type, root) {
- var pre, post, preLength;
+void verifyStaticList(String type, dynamic root) {
+ List pre;
+ List post;
+ int preLength;
runTest(() {
- pre = root.querySelectorAll('div');
+ pre = root.querySelectorAll('div') as List;
preLength = pre.length;
final div = doc.createElement('div');
@@ -105,13 +107,13 @@
assertEquals(
pre.length, preLength, 'The length of the NodeList should not change.');
- }, type + ': static NodeList');
+ }, '$type: static NodeList');
runTest(() {
- post = root.querySelectorAll('div');
+ post = root.querySelectorAll('div') as List;
assertEquals(post.length, preLength + 1,
'The length of the new NodeList should be 1 more than the previous list.');
- }, type + ': new NodeList');
+ }, '$type: new NodeList');
}
/*
@@ -125,20 +127,20 @@
// 1
assertEquals(root.querySelectorAll('null').length, 1,
"This should find one element with the tag name 'NULL'.");
- }, type + '.querySelectorAll null');
+ }, '$type.querySelectorAll null');
runTest(() {
// 2
assertEquals(root.querySelectorAll('undefined').length, 1,
"This should find one element with the tag name 'UNDEFINED'.");
- }, type + '.querySelectorAll undefined');
+ }, '$type.querySelectorAll undefined');
runTest(() {
// 3
assertThrows((e) => e is NoSuchMethodError, () {
root.querySelectorAll();
}, 'This should throw a TypeError.');
- }, type + '.querySelectorAll no parameter');
+ }, '$type.querySelectorAll no parameter');
runTest(() {
// 4
@@ -147,7 +149,7 @@
// TODO(jmesserly): change "localName" back to "tagName" once implemented.
assertEquals(
elm.localName.toUpperCase(), 'NULL', "The tag name should be 'NULL'.");
- }, type + '.querySelector null');
+ }, '$type.querySelector null');
runTest(() {
// 5
@@ -156,14 +158,14 @@
// TODO(jmesserly): change "localName" back to "tagName" once implemented.
assertEquals(elm.localName.toUpperCase(), 'UNDEFINED',
"The tag name should be 'UNDEFINED'.");
- }, type + '.querySelector undefined');
+ }, '$type.querySelector undefined');
runTest(() {
// 6
assertThrows((e) => e is NoSuchMethodError, () {
root.querySelector();
}, 'This should throw a TypeError.');
- }, type + '.querySelector no parameter');
+ }, '$type.querySelector no parameter');
runTest(() {
// 7
@@ -176,7 +178,7 @@
i++;
}
});
- }, type + '.querySelectorAll tree order');
+ }, '$type.querySelectorAll tree order');
}
/// Tests containing this string fail for an unknown reason
@@ -239,7 +241,7 @@
assertFalse(foundall[i].attributes.containsKey('data-clone'),
'This should not be a cloned element.');
}
- }, type + '.querySelectorAll: ' + n + ': ' + q, skip: skip);
+ }, '$type.querySelectorAll: $n:$q', skip: skip);
runTest(() {
found = root.querySelector(q) as Element;
@@ -255,7 +257,7 @@
} else {
assertEquals(found, null, 'The method should not match anything.');
}
- }, type + '.querySelector: ' + n + ': ' + q, skip: skip);
+ }, '$type.querySelector: $n : $q', skip: skip);
} else {
//console.log("Excluding for " + nodeType + ": " + s["testType"] + "&" + testType + "=" + (s["testType"] & testType) + ": " + JSON.stringify(s))
}
@@ -277,13 +279,13 @@
assertThrows((e) => e is FormatException, () {
root.querySelector(q);
});
- }, type + '.querySelector: ' + n + ': ' + q);
+ }, '$type.querySelector: $n:$q');
runTest(() {
assertThrows((e) => e is FormatException, () {
root.querySelectorAll(q);
});
- }, type + '.querySelectorAll: ' + n + ': ' + q);
+ }, '$type.querySelectorAll: $n:$q');
}
}