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: linter:
rules: rules:
- camel_case_types camel_case_types: true
- avoid_print avoid_print: true
- prefer_final_locals constant_identifier_names: false
- prefer_final_in_for_each prefer_final_locals: true
prefer_final_in_for_each: true
analyzer: analyzer:
errors: errors:

View File

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

View File

@ -45,11 +45,11 @@ class MatrixApi extends Api {
set accessToken(String? token) => bearerToken = token; set accessToken(String? token) => bearerToken = token;
@override @override
Never unexpectedResponse(http.BaseResponse response, Uint8List responseBody) { Never unexpectedResponse(http.BaseResponse response, Uint8List body) {
if (response.statusCode >= 400 && response.statusCode < 500) { 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({ MatrixApi({
@ -90,7 +90,7 @@ class MatrixApi extends Api {
throw ('No homeserver specified.'); throw ('No homeserver specified.');
} }
dynamic json; 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; if (data is List<int> || action.startsWith('/media/v3/upload')) json = data;
final url = homeserver! final url = homeserver!
@ -132,7 +132,7 @@ class MatrixApi extends Api {
} }
var jsonString = String.fromCharCodes(respBody.runes); var jsonString = String.fromCharCodes(respBody.runes);
if (jsonString.startsWith('[') && jsonString.endsWith(']')) { if (jsonString.startsWith('[') && jsonString.endsWith(']')) {
jsonString = '\{"chunk":$jsonString\}'; jsonString = '{"chunk":$jsonString}';
} }
jsonResp = jsonDecode(jsonString) jsonResp = jsonDecode(jsonString)
as Map<String, dynamic>?; // May throw FormatException 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 /// to authenticate itself. Each flow comprises a series of stages. If this request
/// doesn't need additional authentication, then this is null. /// doesn't need additional authentication, then this is null.
List<AuthenticationFlow>? get authenticationFlows { 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) return (raw['flows'] as List)
.map((flow) => flow['stages']) .map((flow) => flow['stages'])
.whereType<List>() .whereType<List>()

View File

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

View File

@ -5,7 +5,7 @@ extension PrintLogs on LogEvent {
void printOut() { void printOut() {
var logsStr = '[Matrix] $title'; var logsStr = '[Matrix] $title';
if (exception != null) { if (exception != null) {
logsStr += ' - ' + exception.toString(); logsStr += ' - ${exception.toString()}';
} }
if (stackTrace != null) { if (stackTrace != null) {
logsStr += '\n${stackTrace.toString()}'; 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 issues: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/-/issues
environment: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"
dependencies: dependencies:
enhanced_enum: ^0.1.1 enhanced_enum: ^0.1.1
@ -16,5 +16,5 @@ dependencies:
dev_dependencies: dev_dependencies:
build_runner: ^2.1.8 build_runner: ^2.1.8
enhanced_enum_generator: ^0.1.1 enhanced_enum_generator: ^0.1.1
pedantic: ^1.11.0 lints: ^2.0.0
test: ^1.14.4 test: ^1.14.4