Skip to content

Commit a8efbef

Browse files
authored
Enabled and fix a number of lints (#478)
1 parent fbaf266 commit a8efbef

File tree

6 files changed

+44
-22
lines changed

6 files changed

+44
-22
lines changed

analysis_options.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ linter:
1010
rules:
1111
- annotate_overrides
1212
- avoid_bool_literals_in_conditional_expressions
13+
- avoid_catching_errors
1314
- avoid_classes_with_only_static_members
1415
- avoid_empty_else
1516
- avoid_function_literals_in_foreach_calls
1617
- avoid_init_to_null
1718
- avoid_null_checks_in_equality_operators
19+
- avoid_private_typedef_functions
20+
- avoid_redundant_argument_values
1821
- avoid_relative_lib_imports
1922
- avoid_renaming_method_parameters
2023
- avoid_return_types_on_setters
@@ -28,6 +31,7 @@ linter:
2831
- camel_case_types
2932
- cascade_invocations
3033
# comment_references
34+
- constant_identifier_names
3135
- control_flow_in_finally
3236
- curly_braces_in_flow_control_structures
3337
- directives_ordering
@@ -36,13 +40,18 @@ linter:
3640
- empty_statements
3741
- file_names
3842
- hash_and_equals
43+
- implementation_imports
3944
- invariant_booleans
4045
- iterable_contains_unrelated_type
46+
- join_return_with_assignment
4147
- library_names
4248
- library_prefixes
49+
- lines_longer_than_80_chars
4350
- list_remove_unrelated_type
51+
- missing_whitespace_between_adjacent_strings
4452
- no_adjacent_strings_in_list
4553
- no_duplicate_case_values
54+
- no_runtimeType_toString
4655
- non_constant_identifier_names
4756
- null_closures
4857
- omit_local_variable_types
@@ -51,22 +60,36 @@ linter:
5160
- package_names
5261
- package_prefixed_library_names
5362
- prefer_adjacent_string_concatenation
63+
- prefer_asserts_in_initializer_lists
64+
- prefer_collection_literals
5465
- prefer_conditional_assignment
66+
- prefer_const_constructors
67+
- prefer_const_declarations
5568
- prefer_contains
5669
- prefer_equal_for_default_values
70+
- prefer_expression_function_bodies
5771
- prefer_final_fields
58-
- prefer_collection_literals
72+
#- prefer_final_locals
73+
- prefer_function_declarations_over_variables
5974
- prefer_generic_function_type_aliases
6075
- prefer_initializing_formals
76+
- prefer_inlined_adds
77+
- prefer_interpolation_to_compose_strings
6178
- prefer_is_empty
6279
- prefer_is_not_empty
80+
- prefer_is_not_operator
6381
- prefer_null_aware_operators
82+
- prefer_relative_imports
6483
- prefer_single_quotes
6584
- prefer_typing_uninitialized_variables
85+
- prefer_void_to_null
86+
- provide_deprecation_message
6687
- recursive_getters
6788
- slash_for_doc_comments
89+
- sort_pub_dependencies
6890
- test_types_in_equals
6991
- throw_in_finally
92+
- type_annotate_public_apis
7093
- type_init_formals
7194
- unawaited_futures
7295
- unnecessary_brace_in_string_interps
@@ -79,8 +102,11 @@ linter:
79102
- unnecessary_overrides
80103
- unnecessary_parenthesis
81104
- unnecessary_statements
105+
- unnecessary_string_interpolations
82106
- unnecessary_this
83107
- unrelated_type_equality_checks
108+
- use_is_even_rather_than_modulo
84109
- use_rethrow_when_possible
110+
- use_string_buffers
85111
- valid_regexps
86112
- void_checks

lib/src/boundary_characters.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
///
1111
/// [RFC 2046]: http://tools.ietf.org/html/rfc2046#section-5.1.1.
1212
/// [RFC 1521]: https://tools.ietf.org/html/rfc1521#section-4
13-
const List<int> BOUNDARY_CHARACTERS = <int>[
13+
const List<int> boundaryCharacters = <int>[
1414
43,
1515
95,
1616
45,

lib/src/multipart_request.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,21 @@ class MultipartRequest extends BaseRequest {
141141
}
142142

143143
/// Encode [value] in the same way browsers do.
144-
String _browserEncode(String value) {
145-
// http://tools.ietf.org/html/rfc2388 mandates some complex encodings for
146-
// field names and file names, but in practice user agents seem not to
147-
// follow this at all. Instead, they URL-encode `\r`, `\n`, and `\r\n` as
148-
// `\r\n`; URL-encode `"`; and do nothing else (even for `%` or non-ASCII
149-
// characters). We follow their behavior.
150-
return value.replaceAll(_newlineRegExp, '%0D%0A').replaceAll('"', '%22');
151-
}
144+
String _browserEncode(String value) =>
145+
// http://tools.ietf.org/html/rfc2388 mandates some complex encodings for
146+
// field names and file names, but in practice user agents seem not to
147+
// follow this at all. Instead, they URL-encode `\r`, `\n`, and `\r\n` as
148+
// `\r\n`; URL-encode `"`; and do nothing else (even for `%` or non-ASCII
149+
// characters). We follow their behavior.
150+
value.replaceAll(_newlineRegExp, '%0D%0A').replaceAll('"', '%22');
152151

153152
/// Returns a randomly-generated multipart boundary string
154153
String _boundaryString() {
155154
var prefix = 'dart-http-boundary-';
156155
var list = List<int>.generate(
157156
_boundaryLength - prefix.length,
158157
(index) =>
159-
BOUNDARY_CHARACTERS[_random.nextInt(BOUNDARY_CHARACTERS.length)],
158+
boundaryCharacters[_random.nextInt(boundaryCharacters.length)],
160159
growable: false);
161160
return '$prefix${String.fromCharCodes(list)}';
162161
}

test/io/utils.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ void stopServer() {
115115
}
116116

117117
/// A matcher for functions that throw HttpException.
118-
Matcher get throwsClientException => throwsA(TypeMatcher<ClientException>());
118+
Matcher get throwsClientException =>
119+
throwsA(const TypeMatcher<ClientException>());
119120

120121
/// A matcher for functions that throw SocketException.
121122
final Matcher throwsSocketException =

test/multipart_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void main() {
2020
});
2121

2222
test('boundary characters', () {
23-
var testBoundary = String.fromCharCodes(BOUNDARY_CHARACTERS);
23+
var testBoundary = String.fromCharCodes(boundaryCharacters);
2424
var contentType = MediaType.parse('text/plain; boundary=$testBoundary');
2525
var boundary = contentType.parameters['boundary'];
2626
expect(boundary, testBoundary);

test/utils.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ class _Parse extends Matcher {
6363
}
6464

6565
@override
66-
Description describe(Description description) {
67-
return description
68-
.add('parses to a value that ')
69-
.addDescriptionOf(_matcher);
70-
}
66+
Description describe(Description description) =>
67+
description.add('parses to a value that ').addDescriptionOf(_matcher);
7168
}
7269

7370
/// A matcher that validates the body of a multipart request after finalization.
@@ -105,14 +102,13 @@ class _BodyMatches extends Matcher {
105102
}
106103

107104
@override
108-
Description describe(Description description) {
109-
return description.add('has a body that matches "$_pattern"');
110-
}
105+
Description describe(Description description) =>
106+
description.add('has a body that matches "$_pattern"');
111107
}
112108

113109
/// A matcher that matches function or future that throws a
114110
/// [http.ClientException] with the given [message].
115111
///
116112
/// [message] can be a String or a [Matcher].
117-
Matcher throwsClientException(message) => throwsA(
113+
Matcher throwsClientException(String message) => throwsA(
118114
isA<http.ClientException>().having((e) => e.message, 'message', message));

0 commit comments

Comments
 (0)