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
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..108d105
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1 @@
+include: package:pedantic/analysis_options.yaml
diff --git a/lib/src/base_response.dart b/lib/src/base_response.dart
index 494f1a8..46f72d5 100644
--- a/lib/src/base_response.dart
+++ b/lib/src/base_response.dart
@@ -39,9 +39,9 @@
BaseResponse(this.statusCode,
{this.contentLength,
this.request,
- this.headers: const {},
- this.isRedirect: false,
- this.persistentConnection: true,
+ this.headers = const {},
+ this.isRedirect = false,
+ this.persistentConnection = true,
this.reasonPhrase}) {
if (statusCode < 100) {
throw new ArgumentError("Invalid status code $statusCode.");
diff --git a/lib/src/browser_client.dart b/lib/src/browser_client.dart
index 4f49ec7..08225c2 100644
--- a/lib/src/browser_client.dart
+++ b/lib/src/browser_client.dart
@@ -6,6 +6,8 @@
import 'dart:html';
import 'dart:typed_data';
+import 'package:pedantic/pedantic.dart' show unawaited;
+
import 'base_client.dart';
import 'base_request.dart';
import 'byte_stream.dart';
@@ -49,7 +51,7 @@
request.headers.forEach(xhr.setRequestHeader);
var completer = new Completer<StreamedResponse>();
- xhr.onLoad.first.then((_) {
+ unawaited(xhr.onLoad.first.then((_) {
// TODO(nweiz): Set the response type to "arraybuffer" when issue 18542
// is fixed.
var blob = xhr.response == null ? new Blob([]) : xhr.response;
@@ -72,15 +74,15 @@
});
reader.readAsArrayBuffer(blob);
- });
+ }));
- xhr.onError.first.then((_) {
+ unawaited(xhr.onError.first.then((_) {
// Unfortunately, the underlying XMLHttpRequest API doesn't expose any
// specific information about the error itself.
completer.completeError(
new ClientException("XMLHttpRequest error.", request.url),
StackTrace.current);
- });
+ }));
xhr.send(bytes);
diff --git a/lib/src/multipart_request.dart b/lib/src/multipart_request.dart
index 1268669..00f410f 100644
--- a/lib/src/multipart_request.dart
+++ b/lib/src/multipart_request.dart
@@ -79,7 +79,7 @@
return length + "--".length + _BOUNDARY_LENGTH + "--\r\n".length;
}
- void set contentLength(int value) {
+ set contentLength(int value) {
throw new UnsupportedError("Cannot set the contentLength property of "
"multipart requests.");
}
diff --git a/lib/src/response.dart b/lib/src/response.dart
index 3c0323d..cb43d80 100644
--- a/lib/src/response.dart
+++ b/lib/src/response.dart
@@ -29,9 +29,9 @@
/// Creates a new HTTP response with a string body.
Response(String body, int statusCode,
{BaseRequest request,
- Map<String, String> headers: const {},
- bool isRedirect: false,
- bool persistentConnection: true,
+ Map<String, String> headers = const {},
+ bool isRedirect = false,
+ bool persistentConnection = true,
String reasonPhrase})
: this.bytes(_encodingForHeaders(headers).encode(body), statusCode,
request: request,
@@ -43,9 +43,9 @@
/// Create a new HTTP response with a byte array body.
Response.bytes(List<int> bodyBytes, int statusCode,
{BaseRequest request,
- Map<String, String> headers: const {},
- bool isRedirect: false,
- bool persistentConnection: true,
+ Map<String, String> headers = const {},
+ bool isRedirect = false,
+ bool persistentConnection = true,
String reasonPhrase})
: bodyBytes = toUint8List(bodyBytes),
super(statusCode,
diff --git a/lib/src/streamed_response.dart b/lib/src/streamed_response.dart
index d4cf806..55f055a 100644
--- a/lib/src/streamed_response.dart
+++ b/lib/src/streamed_response.dart
@@ -21,9 +21,9 @@
StreamedResponse(Stream<List<int>> stream, int statusCode,
{int contentLength,
BaseRequest request,
- Map<String, String> headers: const {},
- bool isRedirect: false,
- bool persistentConnection: true,
+ Map<String, String> headers = const {},
+ bool isRedirect = false,
+ bool persistentConnection = true,
String reasonPhrase})
: this.stream = toByteStream(stream),
super(statusCode,
diff --git a/pubspec.yaml b/pubspec.yaml
index 9ef1317..f764311 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -11,6 +11,7 @@
async: ">=1.10.0 <3.0.0"
http_parser: ">=0.0.1 <4.0.0"
path: ">=0.9.0 <2.0.0"
+ pedantic: "^1.0.0"
dev_dependencies:
test: ^1.3.0