diff --git a/analysis_options.yaml b/analysis_options.yaml index 0a517d6..14c4740 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -20,7 +20,6 @@ linter: - always_declare_return_types - always_put_control_body_on_new_line - always_put_required_named_parameters_first - - always_specify_types - always_use_package_imports - annotate_overrides - annotate_redeclares @@ -117,7 +116,7 @@ linter: - null_check_on_nullable_type_parameter - null_closures - one_member_abstracts - - only_throw_errors +# - only_throw_errors - overridden_fields - package_api_docs - package_names @@ -132,14 +131,12 @@ linter: - prefer_const_constructors_in_immutables - prefer_const_declarations - prefer_const_literals_to_create_immutables - - prefer_constructors_over_static_methods - prefer_contains - prefer_double_quotes - - prefer_expression_function_bodies - prefer_final_fields - prefer_final_in_for_each - - prefer_final_locals - - prefer_final_parameters +# - prefer_final_locals +# - prefer_final_parameters - prefer_for_elements_to_map_fromIterable - prefer_foreach - prefer_function_declarations_over_variables diff --git a/lib/messages.dart b/lib/messages.dart index 31eadad..7317e3d 100644 --- a/lib/messages.dart +++ b/lib/messages.dart @@ -1 +1 @@ -export 'src/messages/hello.dart' show Hello; +export "src/messages/hello.dart" show Hello; diff --git a/lib/serializers.dart b/lib/serializers.dart index 2c1b8bc..517b850 100644 --- a/lib/serializers.dart +++ b/lib/serializers.dart @@ -1 +1 @@ -export 'src/serializers/json.dart' show JsonSerializer; +export "src/serializers/json.dart" show JsonSerializer; diff --git a/lib/src/messages/hello.dart b/lib/src/messages/hello.dart index 60cad0b..349d0b4 100644 --- a/lib/src/messages/hello.dart +++ b/lib/src/messages/hello.dart @@ -1,6 +1,8 @@ -import 'message.dart'; +import "package:wampproto/src/messages/message.dart"; class Hello implements Message { + + Hello(this.realm, this.roles, this.authID, this.authMethods); static const int id = 1; final String realm; @@ -8,9 +10,7 @@ class Hello implements Message { final String authID; final List authMethods; - Hello(this.realm, this.roles, this.authID, this.authMethods); - - static Hello parse(List message) { + static Hello parse(final List message) { if (message.length < 2) { throw ArgumentError("invalid hello message"); } @@ -22,7 +22,7 @@ class Hello implements Message { if (type != Hello.id) { throw ArgumentError( - "invalid message type: must be ${Hello.id}, was $type"); + "invalid message type: must be ${Hello.id}, was $type",); } final realm = message[1]; @@ -44,7 +44,5 @@ class Hello implements Message { } @override - int messageType() { - return id; - } + int messageType() => id; } diff --git a/lib/src/serializers/json.dart b/lib/src/serializers/json.dart index b7acb31..68f16d9 100644 --- a/lib/src/serializers/json.dart +++ b/lib/src/serializers/json.dart @@ -1,21 +1,21 @@ -import 'dart:convert'; -import 'dart:typed_data'; +import "dart:convert"; +import "dart:typed_data"; -import 'package:wampproto/src/messages/message.dart'; -import 'package:wampproto/src/serializers/serializer.dart'; +import "package:wampproto/src/messages/message.dart"; +import "package:wampproto/src/serializers/serializer.dart"; class JsonSerializer implements Serializer { @override - Uint8List serialize(Message message) { + Uint8List serialize(final Message message) { var jsonString = jsonEncode(message.marshal()); return Uint8List.fromList(jsonString.codeUnits); } @override - Message deserialize(Uint8List message) { - String s = String.fromCharCodes(message); + Message deserialize(final Uint8List message) { + final String s = String.fromCharCodes(message); - List wampMessage = jsonDecode(s); + final List wampMessage = jsonDecode(s); return toMessage(wampMessage); } } diff --git a/lib/src/serializers/serializer.dart b/lib/src/serializers/serializer.dart index b04f396..c322535 100644 --- a/lib/src/serializers/serializer.dart +++ b/lib/src/serializers/serializer.dart @@ -1,8 +1,8 @@ -import 'dart:typed_data'; +import "dart:typed_data"; -import 'package:wampproto/messages.dart'; +import "package:wampproto/messages.dart"; -import '../messages/message.dart'; +import "package:wampproto/src/messages/message.dart"; Message toMessage(List message) { var messageType = message[0]; @@ -21,6 +21,6 @@ Message toMessage(List message) { } abstract class Serializer { - Message deserialize(Uint8List message); - Uint8List serialize(Message message); + Message deserialize(final Uint8List message); + Uint8List serialize(final Message message); } diff --git a/test/messages/hello_test.dart b/test/messages/hello_test.dart index 1aeff59..c6b0e09 100644 --- a/test/messages/hello_test.dart +++ b/test/messages/hello_test.dart @@ -1,5 +1,5 @@ -import 'package:wampproto/messages.dart'; -import 'package:test/test.dart'; +import "package:test/test.dart"; +import "package:wampproto/messages.dart"; void main() { test("test parse", testParse); diff --git a/test/serializers/json_test.dart b/test/serializers/json_test.dart index d761f93..3a86128 100644 --- a/test/serializers/json_test.dart +++ b/test/serializers/json_test.dart @@ -1,6 +1,6 @@ -import 'package:wampproto/messages.dart'; -import 'package:wampproto/serializers.dart'; -import 'package:test/test.dart'; +import "package:test/test.dart"; +import "package:wampproto/messages.dart"; +import "package:wampproto/serializers.dart"; void main() { test("test serialize and deserialize", testJson);