Skip to content

Commit bac715b

Browse files
LinusUkevmoo
authored andcommitted
Fix linting warnings (#256)
* Use = to separate a named parameter from its default value * Avoid return types on setters * Mark unused Future results with unawaited * Add pedantic analysis_options.yaml
1 parent 0c00db0 commit bac715b

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:pedantic/analysis_options.yaml

lib/src/base_response.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ abstract class BaseResponse {
3939
BaseResponse(this.statusCode,
4040
{this.contentLength,
4141
this.request,
42-
this.headers: const {},
43-
this.isRedirect: false,
44-
this.persistentConnection: true,
42+
this.headers = const {},
43+
this.isRedirect = false,
44+
this.persistentConnection = true,
4545
this.reasonPhrase}) {
4646
if (statusCode < 100) {
4747
throw new ArgumentError("Invalid status code $statusCode.");

lib/src/browser_client.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'dart:async';
66
import 'dart:html';
77
import 'dart:typed_data';
88

9+
import 'package:pedantic/pedantic.dart' show unawaited;
10+
911
import 'base_client.dart';
1012
import 'base_request.dart';
1113
import 'byte_stream.dart';
@@ -49,7 +51,7 @@ class BrowserClient extends BaseClient {
4951
request.headers.forEach(xhr.setRequestHeader);
5052

5153
var completer = new Completer<StreamedResponse>();
52-
xhr.onLoad.first.then((_) {
54+
unawaited(xhr.onLoad.first.then((_) {
5355
// TODO(nweiz): Set the response type to "arraybuffer" when issue 18542
5456
// is fixed.
5557
var blob = xhr.response == null ? new Blob([]) : xhr.response;
@@ -72,15 +74,15 @@ class BrowserClient extends BaseClient {
7274
});
7375

7476
reader.readAsArrayBuffer(blob);
75-
});
77+
}));
7678

77-
xhr.onError.first.then((_) {
79+
unawaited(xhr.onError.first.then((_) {
7880
// Unfortunately, the underlying XMLHttpRequest API doesn't expose any
7981
// specific information about the error itself.
8082
completer.completeError(
8183
new ClientException("XMLHttpRequest error.", request.url),
8284
StackTrace.current);
83-
});
85+
}));
8486

8587
xhr.send(bytes);
8688

lib/src/multipart_request.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MultipartRequest extends BaseRequest {
7979
return length + "--".length + _BOUNDARY_LENGTH + "--\r\n".length;
8080
}
8181

82-
void set contentLength(int value) {
82+
set contentLength(int value) {
8383
throw new UnsupportedError("Cannot set the contentLength property of "
8484
"multipart requests.");
8585
}

lib/src/response.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class Response extends BaseResponse {
2929
/// Creates a new HTTP response with a string body.
3030
Response(String body, int statusCode,
3131
{BaseRequest request,
32-
Map<String, String> headers: const {},
33-
bool isRedirect: false,
34-
bool persistentConnection: true,
32+
Map<String, String> headers = const {},
33+
bool isRedirect = false,
34+
bool persistentConnection = true,
3535
String reasonPhrase})
3636
: this.bytes(_encodingForHeaders(headers).encode(body), statusCode,
3737
request: request,
@@ -43,9 +43,9 @@ class Response extends BaseResponse {
4343
/// Create a new HTTP response with a byte array body.
4444
Response.bytes(List<int> bodyBytes, int statusCode,
4545
{BaseRequest request,
46-
Map<String, String> headers: const {},
47-
bool isRedirect: false,
48-
bool persistentConnection: true,
46+
Map<String, String> headers = const {},
47+
bool isRedirect = false,
48+
bool persistentConnection = true,
4949
String reasonPhrase})
5050
: bodyBytes = toUint8List(bodyBytes),
5151
super(statusCode,

lib/src/streamed_response.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class StreamedResponse extends BaseResponse {
2121
StreamedResponse(Stream<List<int>> stream, int statusCode,
2222
{int contentLength,
2323
BaseRequest request,
24-
Map<String, String> headers: const {},
25-
bool isRedirect: false,
26-
bool persistentConnection: true,
24+
Map<String, String> headers = const {},
25+
bool isRedirect = false,
26+
bool persistentConnection = true,
2727
String reasonPhrase})
2828
: this.stream = toByteStream(stream),
2929
super(statusCode,

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies:
1111
async: ">=1.10.0 <3.0.0"
1212
http_parser: ">=0.0.1 <4.0.0"
1313
path: ">=0.9.0 <2.0.0"
14+
pedantic: "^1.0.0"
1415

1516
dev_dependencies:
1617
test: ^1.3.0

0 commit comments

Comments
 (0)