From d667f636756706e5dca222a38ba29d6d2ec6e977 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 5 May 2021 12:24:49 +0200 Subject: [PATCH] refactor: Enable more lints --- analysis_options.yaml | 20 ++++++++++---------- lib/src/matrix_api.dart | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index a686c1b4..7efcbfc1 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,14 +1,14 @@ -# Defines a default set of lint rules enforced for -# projects at Google. For details and rationale, -# see https://github.com/dart-lang/pedantic#enabled-lints. include: package:pedantic/analysis_options.yaml -# For lint rules and documentation, see http://dart-lang.github.io/linter/lints. -# Uncomment to specify additional rules. -# linter: -# rules: -# - camel_case_types +linter: + rules: + - camel_case_types + - avoid_print + - prefer_final_locals + - prefer_final_in_for_each analyzer: -# exclude: -# - path/to/excluded/files/** + errors: + todo: ignore + exclude: + - example/matrix_api_lite_example.dart diff --git a/lib/src/matrix_api.dart b/lib/src/matrix_api.dart index 4d623a0e..07d59273 100644 --- a/lib/src/matrix_api.dart +++ b/lib/src/matrix_api.dart @@ -152,7 +152,7 @@ class MatrixApi { final url = homeserver .resolveUri(Uri(path: '_matrix$action', queryParameters: query)); - var headers = {}; + final headers = {}; if (type == RequestType.PUT || type == RequestType.POST) { headers['Content-Type'] = contentType; } @@ -1291,7 +1291,7 @@ class MatrixApi { {String contentType}) async { fileName = fileName.split('/').last; final length = file.length; - var headers = {}; + final headers = {}; headers['Authorization'] = 'Bearer $accessToken'; headers['Content-Type'] = contentType ?? lookupMimeType(fileName, headerBytes: file); @@ -1306,8 +1306,8 @@ class MatrixApi { streamedRequest.contentLength = length; streamedRequest.sink.add(file); streamedRequest.sink.close(); - var streamedResponse = _testMode ? null : await streamedRequest.send(); - Map jsonResponse = json.decode( + final streamedResponse = _testMode ? null : await streamedRequest.send(); + final Map jsonResponse = json.decode( String.fromCharCodes(_testMode ? ((fileName == 'file.jpeg') ? '{"content_uri": "mxc://example.com/AQwafuaFswefuhsfAFAgsw"}' @@ -1325,7 +1325,7 @@ class MatrixApi { /// URL in a message and wants to render a preview for the user. /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-preview-url Future requestOpenGraphDataForUrl(Uri url, {int ts}) async { - var action = homeserver + final action = homeserver .resolveUri(Uri(path: '_matrix/media/r0/preview_url', queryParameters: { 'url': url.toString(), if (ts != null) 'ts': ts.toString(), @@ -1338,7 +1338,7 @@ class MatrixApi { /// This endpoint allows clients to retrieve the configuration of the content repository, such as upload limitations. /// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config Future requestMaxUploadSize() async { - var action = homeserver.resolve('_matrix/media/r0/config'); + final action = homeserver.resolve('_matrix/media/r0/config'); final response = await httpClient.get(action); final rawJson = json.decode(response.body.isEmpty ? '{}' : response.body); return rawJson['m.upload.size']; @@ -1553,7 +1553,7 @@ class MatrixApi { /// values in the JSON body. /// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set Future setPusher(Pusher pusher, {bool append}) async { - var data = pusher.toJson(); + final data = pusher.toJson(); if (append != null) { data['append'] = append; }