refactor: Enable more lints
This commit is contained in:
parent
846c96e90d
commit
d667f63675
|
|
@ -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
|
include: package:pedantic/analysis_options.yaml
|
||||||
|
|
||||||
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
|
linter:
|
||||||
# Uncomment to specify additional rules.
|
rules:
|
||||||
# linter:
|
- camel_case_types
|
||||||
# rules:
|
- avoid_print
|
||||||
# - camel_case_types
|
- prefer_final_locals
|
||||||
|
- prefer_final_in_for_each
|
||||||
|
|
||||||
analyzer:
|
analyzer:
|
||||||
# exclude:
|
errors:
|
||||||
# - path/to/excluded/files/**
|
todo: ignore
|
||||||
|
exclude:
|
||||||
|
- example/matrix_api_lite_example.dart
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ class MatrixApi {
|
||||||
final url = homeserver
|
final url = homeserver
|
||||||
.resolveUri(Uri(path: '_matrix$action', queryParameters: query));
|
.resolveUri(Uri(path: '_matrix$action', queryParameters: query));
|
||||||
|
|
||||||
var headers = <String, String>{};
|
final headers = <String, String>{};
|
||||||
if (type == RequestType.PUT || type == RequestType.POST) {
|
if (type == RequestType.PUT || type == RequestType.POST) {
|
||||||
headers['Content-Type'] = contentType;
|
headers['Content-Type'] = contentType;
|
||||||
}
|
}
|
||||||
|
|
@ -1291,7 +1291,7 @@ class MatrixApi {
|
||||||
{String contentType}) async {
|
{String contentType}) async {
|
||||||
fileName = fileName.split('/').last;
|
fileName = fileName.split('/').last;
|
||||||
final length = file.length;
|
final length = file.length;
|
||||||
var headers = <String, String>{};
|
final headers = <String, String>{};
|
||||||
headers['Authorization'] = 'Bearer $accessToken';
|
headers['Authorization'] = 'Bearer $accessToken';
|
||||||
headers['Content-Type'] =
|
headers['Content-Type'] =
|
||||||
contentType ?? lookupMimeType(fileName, headerBytes: file);
|
contentType ?? lookupMimeType(fileName, headerBytes: file);
|
||||||
|
|
@ -1306,8 +1306,8 @@ class MatrixApi {
|
||||||
streamedRequest.contentLength = length;
|
streamedRequest.contentLength = length;
|
||||||
streamedRequest.sink.add(file);
|
streamedRequest.sink.add(file);
|
||||||
streamedRequest.sink.close();
|
streamedRequest.sink.close();
|
||||||
var streamedResponse = _testMode ? null : await streamedRequest.send();
|
final streamedResponse = _testMode ? null : await streamedRequest.send();
|
||||||
Map<String, dynamic> jsonResponse = json.decode(
|
final Map<String, dynamic> jsonResponse = json.decode(
|
||||||
String.fromCharCodes(_testMode
|
String.fromCharCodes(_testMode
|
||||||
? ((fileName == 'file.jpeg')
|
? ((fileName == 'file.jpeg')
|
||||||
? '{"content_uri": "mxc://example.com/AQwafuaFswefuhsfAFAgsw"}'
|
? '{"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.
|
/// 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
|
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-preview-url
|
||||||
Future<OpenGraphData> requestOpenGraphDataForUrl(Uri url, {int ts}) async {
|
Future<OpenGraphData> requestOpenGraphDataForUrl(Uri url, {int ts}) async {
|
||||||
var action = homeserver
|
final action = homeserver
|
||||||
.resolveUri(Uri(path: '_matrix/media/r0/preview_url', queryParameters: {
|
.resolveUri(Uri(path: '_matrix/media/r0/preview_url', queryParameters: {
|
||||||
'url': url.toString(),
|
'url': url.toString(),
|
||||||
if (ts != null) 'ts': ts.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.
|
/// 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
|
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-media-r0-config
|
||||||
Future<int> requestMaxUploadSize() async {
|
Future<int> 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 response = await httpClient.get(action);
|
||||||
final rawJson = json.decode(response.body.isEmpty ? '{}' : response.body);
|
final rawJson = json.decode(response.body.isEmpty ? '{}' : response.body);
|
||||||
return rawJson['m.upload.size'];
|
return rawJson['m.upload.size'];
|
||||||
|
|
@ -1553,7 +1553,7 @@ class MatrixApi {
|
||||||
/// values in the JSON body.
|
/// values in the JSON body.
|
||||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
|
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
|
||||||
Future<void> setPusher(Pusher pusher, {bool append}) async {
|
Future<void> setPusher(Pusher pusher, {bool append}) async {
|
||||||
var data = pusher.toJson();
|
final data = pusher.toJson();
|
||||||
if (append != null) {
|
if (append != null) {
|
||||||
data['append'] = append;
|
data['append'] = append;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue