Skip to content

Commit 92cf21c

Browse files
authored
Enable and fix lint annotate_overrides (#305)
1 parent bccc9ab commit 92cf21c

12 files changed

+33
-1
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include: package:pedantic/analysis_options.yaml
22
linter:
33
rules:
4+
- annotate_overrides
45
- prefer_generic_function_type_aliases
56
- unnecessary_const
67
- unnecessary_new

lib/src/base_client.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ abstract class BaseClient implements Client {
2121
/// can be a [Uri] or a [String].
2222
///
2323
/// For more fine-grained control over the request, use [send] instead.
24+
@override
2425
Future<Response> head(url, {Map<String, String> headers}) =>
2526
_sendUnstreamed("HEAD", url, headers);
2627

2728
/// Sends an HTTP GET request with the given headers to the given URL, which
2829
/// can be a [Uri] or a [String].
2930
///
3031
/// For more fine-grained control over the request, use [send] instead.
32+
@override
3133
Future<Response> get(url, {Map<String, String> headers}) =>
3234
_sendUnstreamed("GET", url, headers);
3335

@@ -49,6 +51,7 @@ abstract class BaseClient implements Client {
4951
/// [encoding] defaults to UTF-8.
5052
///
5153
/// For more fine-grained control over the request, use [send] instead.
54+
@override
5255
Future<Response> post(url,
5356
{Map<String, String> headers, body, Encoding encoding}) =>
5457
_sendUnstreamed("POST", url, headers, body, encoding);
@@ -71,6 +74,7 @@ abstract class BaseClient implements Client {
7174
/// [encoding] defaults to UTF-8.
7275
///
7376
/// For more fine-grained control over the request, use [send] instead.
77+
@override
7478
Future<Response> put(url,
7579
{Map<String, String> headers, body, Encoding encoding}) =>
7680
_sendUnstreamed("PUT", url, headers, body, encoding);
@@ -93,6 +97,7 @@ abstract class BaseClient implements Client {
9397
/// [encoding] defaults to UTF-8.
9498
///
9599
/// For more fine-grained control over the request, use [send] instead.
100+
@override
96101
Future<Response> patch(url,
97102
{Map<String, String> headers, body, Encoding encoding}) =>
98103
_sendUnstreamed("PATCH", url, headers, body, encoding);
@@ -101,6 +106,7 @@ abstract class BaseClient implements Client {
101106
/// which can be a [Uri] or a [String].
102107
///
103108
/// For more fine-grained control over the request, use [send] instead.
109+
@override
104110
Future<Response> delete(url, {Map<String, String> headers}) =>
105111
_sendUnstreamed("DELETE", url, headers);
106112

@@ -113,6 +119,7 @@ abstract class BaseClient implements Client {
113119
///
114120
/// For more fine-grained control over the request and response, use [send] or
115121
/// [get] instead.
122+
@override
116123
Future<String> read(url, {Map<String, String> headers}) {
117124
return get(url, headers: headers).then((response) {
118125
_checkResponseSuccess(url, response);
@@ -129,6 +136,7 @@ abstract class BaseClient implements Client {
129136
///
130137
/// For more fine-grained control over the request and response, use [send] or
131138
/// [get] instead.
139+
@override
132140
Future<Uint8List> readBytes(url, {Map<String, String> headers}) {
133141
return get(url, headers: headers).then((response) {
134142
_checkResponseSuccess(url, response);
@@ -143,6 +151,7 @@ abstract class BaseClient implements Client {
143151
/// state of the stream; it could have data written to it asynchronously at a
144152
/// later point, or it could already be closed when it's returned. Any
145153
/// internal HTTP errors should be wrapped as [ClientException]s.
154+
@override
146155
Future<StreamedResponse> send(BaseRequest request);
147156

148157
/// Sends a non-streaming [Request] and returns a non-streaming [Response].
@@ -183,5 +192,6 @@ abstract class BaseClient implements Client {
183192
/// Closes the client and cleans up any resources associated with it. It's
184193
/// important to close each client when it's done being used; failing to do so
185194
/// can cause the Dart process to hang.
195+
@override
186196
void close() {}
187197
}

lib/src/base_request.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,6 @@ abstract class BaseRequest {
134134
throw StateError("Can't modify a finalized Request.");
135135
}
136136

137-
String toString() => "$method $url";
137+
@override
138+
String toString() => '$method $url';
138139
}

lib/src/browser_client.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class BrowserClient extends BaseClient {
4141
bool withCredentials = false;
4242

4343
/// Sends an HTTP request and asynchronously returns the response.
44+
@override
4445
Future<StreamedResponse> send(BaseRequest request) async {
4546
var bytes = await request.finalize().toBytes();
4647
var xhr = HttpRequest();
@@ -101,6 +102,7 @@ class BrowserClient extends BaseClient {
101102
/// Closes the client.
102103
///
103104
/// This terminates all active requests.
105+
@override
104106
void close() {
105107
for (var xhr in _xhrs) {
106108
xhr.abort();

lib/src/exception.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ class ClientException implements Exception {
1111

1212
ClientException(this.message, [this.uri]);
1313

14+
@override
1415
String toString() => message;
1516
}

lib/src/io_client.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class IOClient extends BaseClient {
2626
IOClient([HttpClient inner]) : _inner = inner ?? HttpClient();
2727

2828
/// Sends an HTTP request and asynchronously returns the response.
29+
@override
2930
Future<StreamedResponse> send(BaseRequest request) async {
3031
var stream = request.finalize();
3132

@@ -68,6 +69,7 @@ class IOClient extends BaseClient {
6869

6970
/// Closes the client. This terminates all active connections. If a client
7071
/// remains unclosed, the Dart process may not terminate.
72+
@override
7173
void close() {
7274
if (_inner != null) _inner.close(force: true);
7375
_inner = null;

lib/src/mock_client.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class MockClient extends BaseClient {
6767
});
6868

6969
/// Sends a request.
70+
@override
7071
Future<StreamedResponse> send(BaseRequest request) async {
7172
var bodyStream = request.finalize();
7273
return await _handler(request, bodyStream);

lib/src/multipart_request.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class MultipartRequest extends BaseRequest {
5353
/// The total length of the request body, in bytes.
5454
///
5555
/// This is calculated from [fields] and [files] and cannot be set manually.
56+
@override
5657
int get contentLength {
5758
var length = 0;
5859

@@ -77,13 +78,15 @@ class MultipartRequest extends BaseRequest {
7778
return length + "--".length + _boundaryLength + "--\r\n".length;
7879
}
7980

81+
@override
8082
set contentLength(int value) {
8183
throw UnsupportedError("Cannot set the contentLength property of "
8284
"multipart requests.");
8385
}
8486

8587
/// Freezes all mutable fields and returns a single-subscription [ByteStream]
8688
/// that will emit the request body.
89+
@override
8790
ByteStream finalize() {
8891
// TODO(nweiz): freeze fields and files
8992
var boundary = _boundaryString();

lib/src/request.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ class Request extends BaseRequest {
1818
///
1919
/// The content length cannot be set for [Request], since it's automatically
2020
/// calculated from [bodyBytes].
21+
@override
2122
int get contentLength => bodyBytes.length;
2223

24+
@override
2325
set contentLength(int value) {
2426
throw UnsupportedError("Cannot set the contentLength property of "
2527
"non-streaming Request objects.");
@@ -136,6 +138,7 @@ class Request extends BaseRequest {
136138

137139
/// Freezes all mutable fields and returns a single-subscription [ByteStream]
138140
/// containing the request body.
141+
@override
139142
ByteStream finalize() {
140143
super.finalize();
141144
return ByteStream.fromBytes(bodyBytes);

lib/src/streamed_request.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class StreamedRequest extends BaseRequest {
3434
/// Freezes all mutable fields other than [stream] and returns a
3535
/// single-subscription [ByteStream] that emits the data being written to
3636
/// [sink].
37+
@override
3738
ByteStream finalize() {
3839
super.finalize();
3940
return ByteStream(_controller.stream);

0 commit comments

Comments
 (0)