chore: upgrade from pedantic to lints

This commit is contained in:
Nicolas Werner 2022-08-19 11:37:22 +02:00
parent cb743e8df0
commit ff66e1c208
7 changed files with 18 additions and 18 deletions

View File

@ -1,11 +1,12 @@
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml
linter:
rules:
- camel_case_types
- avoid_print
- prefer_final_locals
- prefer_final_in_for_each
camel_case_types: true
avoid_print: true
constant_identifier_names: false
prefer_final_locals: true
prefer_final_in_for_each: true
analyzer:
errors:

View File

@ -49,9 +49,8 @@ class FakeMatrixApi extends MockClient {
// Collect data from Request
var action = request.url.path;
if (request.url.path.contains('/_matrix')) {
action = request.url.path.split('/_matrix').last +
'?' +
request.url.query;
action =
'${request.url.path.split('/_matrix').last}?${request.url.query}';
}
if (action.endsWith('?')) {

View File

@ -45,11 +45,11 @@ class MatrixApi extends Api {
set accessToken(String? token) => bearerToken = token;
@override
Never unexpectedResponse(http.BaseResponse response, Uint8List responseBody) {
Never unexpectedResponse(http.BaseResponse response, Uint8List body) {
if (response.statusCode >= 400 && response.statusCode < 500) {
throw MatrixException.fromJson(json.decode(utf8.decode(responseBody)));
throw MatrixException.fromJson(json.decode(utf8.decode(body)));
}
super.unexpectedResponse(response, responseBody);
super.unexpectedResponse(response, body);
}
MatrixApi({
@ -90,7 +90,7 @@ class MatrixApi extends Api {
throw ('No homeserver specified.');
}
dynamic json;
(!(data is String)) ? json = jsonEncode(data) : json = data;
(data is! String) ? json = jsonEncode(data) : json = data;
if (data is List<int> || action.startsWith('/media/v3/upload')) json = data;
final url = homeserver!
@ -132,7 +132,7 @@ class MatrixApi extends Api {
}
var jsonString = String.fromCharCodes(respBody.runes);
if (jsonString.startsWith('[') && jsonString.endsWith(']')) {
jsonString = '\{"chunk":$jsonString\}';
jsonString = '{"chunk":$jsonString}';
}
jsonResp = jsonDecode(jsonString)
as Map<String, dynamic>?; // May throw FormatException

View File

@ -106,7 +106,7 @@ class MatrixException implements Exception {
/// to authenticate itself. Each flow comprises a series of stages. If this request
/// doesn't need additional authentication, then this is null.
List<AuthenticationFlow>? get authenticationFlows {
if (!raw.containsKey('flows') || !(raw['flows'] is List)) return null;
if (!raw.containsKey('flows') || raw['flows'] is! List) return null;
return (raw['flows'] as List)
.map((flow) => flow['stages'])
.whereType<List>()

View File

@ -4,7 +4,7 @@ extension PrintLogs on LogEvent {
void printOut() {
var logsStr = title;
if (exception != null) {
logsStr += ' - ' + exception.toString();
logsStr += ' - ${exception.toString()}';
}
if (stackTrace != null) {
logsStr += '\n${stackTrace.toString()}';

View File

@ -5,7 +5,7 @@ extension PrintLogs on LogEvent {
void printOut() {
var logsStr = '[Matrix] $title';
if (exception != null) {
logsStr += ' - ' + exception.toString();
logsStr += ' - ${exception.toString()}';
}
if (stackTrace != null) {
logsStr += '\n${stackTrace.toString()}';

View File

@ -6,7 +6,7 @@ repository: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lit
issues: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/-/issues
environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.17.0 <3.0.0"
dependencies:
enhanced_enum: ^0.1.1
@ -16,5 +16,5 @@ dependencies:
dev_dependencies:
build_runner: ^2.1.8
enhanced_enum_generator: ^0.1.1
pedantic: ^1.11.0
lints: ^2.0.0
test: ^1.14.4