From 5270a7cefe3e63f69b658d4c54d844115d2e00de Mon Sep 17 00:00:00 2001 From: Kees-Schotanus Date: Mon, 28 Oct 2024 11:29:49 +0100 Subject: [PATCH] Resolved compiler warings and formatted the code. --- .../lib/src/case_insensitive_map.dart | 4 +- .../request_information_extensions.dart | 5 ++- .../lib/src/serialization/untyped_node.dart | 41 ++++++++++--------- .../lib/src/serialization/untyped_string.dart | 1 - .../parse_node_factory_registry_test.dart | 11 +++-- ...lization_writer_factory_registry_test.dart | 11 +++-- .../lib/src/form_serialization_writer.dart | 2 +- .../test/form_parse_node_test.dart | 2 +- .../lib/src/json_parse_node.dart | 2 +- .../test/intersection_type_test.dart | 12 ++++-- .../test/json_parse_node_factory_test.dart | 10 +++-- .../test/json_parse_node_test.dart | 6 ++- ...son_serialization_writer_factory_test.dart | 8 ++-- .../test/json_serialization_writer_test.dart | 6 ++- .../test/microsoft_graph_group.dart | 3 +- .../test/second_test_entity.dart | 8 ++-- .../test/union_type_mock.dart | 6 ++- .../test/union_type_test.dart | 6 ++- .../test/text_parse_node_test.dart | 2 +- 19 files changed, 85 insertions(+), 61 deletions(-) diff --git a/packages/kiota_abstractions/lib/src/case_insensitive_map.dart b/packages/kiota_abstractions/lib/src/case_insensitive_map.dart index a55fa69..35b42ce 100644 --- a/packages/kiota_abstractions/lib/src/case_insensitive_map.dart +++ b/packages/kiota_abstractions/lib/src/case_insensitive_map.dart @@ -112,9 +112,9 @@ class CaseInsensitiveMap implements Map { final normalizedKey = normalizeKey(key); return _contents.putIfAbsent(normalizedKey, () { - _originalKeys[normalizedKey] = key; + _originalKeys[normalizedKey] = key; - return ifAbsent(); + return ifAbsent(); }); } diff --git a/packages/kiota_abstractions/lib/src/extensions/request_information_extensions.dart b/packages/kiota_abstractions/lib/src/extensions/request_information_extensions.dart index 4e02dff..615404a 100644 --- a/packages/kiota_abstractions/lib/src/extensions/request_information_extensions.dart +++ b/packages/kiota_abstractions/lib/src/extensions/request_information_extensions.dart @@ -138,8 +138,9 @@ extension RequestInformationExtensions on RequestInformation { } void configure( - void Function(RequestConfiguration)? configurator, - T Function()? createParameters) { + void Function(RequestConfiguration)? configurator, + T Function()? createParameters, + ) { if (configurator == null || createParameters == null) { return; } diff --git a/packages/kiota_abstractions/lib/src/serialization/untyped_node.dart b/packages/kiota_abstractions/lib/src/serialization/untyped_node.dart index 491f347..8c0a0f0 100644 --- a/packages/kiota_abstractions/lib/src/serialization/untyped_node.dart +++ b/packages/kiota_abstractions/lib/src/serialization/untyped_node.dart @@ -2,27 +2,28 @@ part of '../../kiota_abstractions.dart'; /// Base class for untyped node. class UntypedNode implements Parsable { - const UntypedNode(); + const UntypedNode(); - /// Creates a new [UntypedNode] instance. - factory UntypedNode.createFromDiscriminatorValue(ParseNode _) { - return const UntypedNode(); - } - /// The deserialization information for the current model. - /// Returns a map of serializer methods for this object. - @override - Map getFieldDeserializers() { - return {}; - } + /// Creates a new [UntypedNode] instance. + factory UntypedNode.createFromDiscriminatorValue(ParseNode _) { + return const UntypedNode(); + } - /// Serializes the current object - @override - void serialize(SerializationWriter writer) { - // no properties to serialize. This is handled by custom serialization logic. - } + /// The deserialization information for the current model. + /// Returns a map of serializer methods for this object. + @override + Map getFieldDeserializers() { + return {}; + } - /// Gets the value assigned to untyped node. - Object? getValue() { - throw Exception('getValue is implemented for derived types of UntypedNode'); - } + /// Serializes the current object + @override + void serialize(SerializationWriter writer) { + // no properties to serialize. This is handled by custom serialization logic. + } + + /// Gets the value assigned to untyped node. + Object? getValue() { + throw Exception('getValue is implemented for derived types of UntypedNode'); + } } diff --git a/packages/kiota_abstractions/lib/src/serialization/untyped_string.dart b/packages/kiota_abstractions/lib/src/serialization/untyped_string.dart index f8f6813..4dfa6b8 100644 --- a/packages/kiota_abstractions/lib/src/serialization/untyped_string.dart +++ b/packages/kiota_abstractions/lib/src/serialization/untyped_string.dart @@ -1,7 +1,6 @@ part of '../../kiota_abstractions.dart'; class UntypedString extends UntypedNode { - const UntypedString(this.value); final String value; diff --git a/packages/kiota_abstractions/test/serialization/parse_node_factory_registry_test.dart b/packages/kiota_abstractions/test/serialization/parse_node_factory_registry_test.dart index 5f5b27b..22a1b13 100644 --- a/packages/kiota_abstractions/test/serialization/parse_node_factory_registry_test.dart +++ b/packages/kiota_abstractions/test/serialization/parse_node_factory_registry_test.dart @@ -12,11 +12,14 @@ void main() { test('VendorSpecificContentType', () { const contentType = 'application/json'; final mockFactory = MockParseNodeFactory(); - final jsonStream= utf8.encode('{"test": "input"}'); + final jsonStream = utf8.encode('{"test": "input"}'); final mockParseNode = MockParseNode(); - when(mockFactory.getRootParseNode(contentType, jsonStream)).thenReturn(mockParseNode); - ParseNodeFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.putIfAbsent(contentType, ()=>mockFactory); - final rootParseNode = ParseNodeFactoryRegistry.defaultInstance.getRootParseNode('application/vnd+json', jsonStream); + when(mockFactory.getRootParseNode(contentType, jsonStream)) + .thenReturn(mockParseNode); + ParseNodeFactoryRegistry.defaultInstance.contentTypeAssociatedFactories + .putIfAbsent(contentType, () => mockFactory); + final rootParseNode = ParseNodeFactoryRegistry.defaultInstance + .getRootParseNode('application/vnd+json', jsonStream); expect(rootParseNode, isNotNull); }); }); diff --git a/packages/kiota_abstractions/test/serialization/serialization_writer_factory_registry_test.dart b/packages/kiota_abstractions/test/serialization/serialization_writer_factory_registry_test.dart index cebde1e..64590f2 100644 --- a/packages/kiota_abstractions/test/serialization/serialization_writer_factory_registry_test.dart +++ b/packages/kiota_abstractions/test/serialization/serialization_writer_factory_registry_test.dart @@ -11,9 +11,14 @@ void main() { const contentType = 'application/text'; final mockWriter = MockSerializationWriter(); final mockFactory = MockSerializationWriterFactory(); - when(mockFactory.getSerializationWriter(contentType)).thenReturn(mockWriter); - SerializationWriterFactoryRegistry.defaultInstance.contentTypeAssociatedFactories.putIfAbsent(contentType, () => mockFactory); - final serializationWriter = SerializationWriterFactoryRegistry.defaultInstance.getSerializationWriter('application/vnd+text'); + when(mockFactory.getSerializationWriter(contentType)) + .thenReturn(mockWriter); + SerializationWriterFactoryRegistry + .defaultInstance.contentTypeAssociatedFactories + .putIfAbsent(contentType, () => mockFactory); + final serializationWriter = SerializationWriterFactoryRegistry + .defaultInstance + .getSerializationWriter('application/vnd+text'); expect(serializationWriter, isNotNull); }); }); diff --git a/packages/kiota_serialization_form/lib/src/form_serialization_writer.dart b/packages/kiota_serialization_form/lib/src/form_serialization_writer.dart index 90e89c2..5691c50 100644 --- a/packages/kiota_serialization_form/lib/src/form_serialization_writer.dart +++ b/packages/kiota_serialization_form/lib/src/form_serialization_writer.dart @@ -168,7 +168,7 @@ class FormSerializationWriter implements SerializationWriter { if (additionalValuesToMerge != null) { for (final additionalValue in additionalValuesToMerge) { - if(additionalValue != null){ + if (additionalValue != null) { onBeforeObjectSerialization?.call(additionalValue); onStartObjectSerialization?.call(additionalValue, this); diff --git a/packages/kiota_serialization_form/test/form_parse_node_test.dart b/packages/kiota_serialization_form/test/form_parse_node_test.dart index 020c93d..6cd9342 100644 --- a/packages/kiota_serialization_form/test/form_parse_node_test.dart +++ b/packages/kiota_serialization_form/test/form_parse_node_test.dart @@ -85,7 +85,7 @@ void main() { expect( node.getGuidValue(), - equals(UuidValue.nil), + equals(UuidValue.fromString('00000000-0000-0000-0000-000000000000')), ); }); diff --git a/packages/kiota_serialization_json/lib/src/json_parse_node.dart b/packages/kiota_serialization_json/lib/src/json_parse_node.dart index 5f6cdaa..c887f2d 100644 --- a/packages/kiota_serialization_json/lib/src/json_parse_node.dart +++ b/packages/kiota_serialization_json/lib/src/json_parse_node.dart @@ -170,7 +170,7 @@ class JsonParseNode implements ParseNode { UntypedNode? getUntypedValue(dynamic node) { if (node == null) { - return UntypedNull(); + return const UntypedNull(); } if (node is List) { diff --git a/packages/kiota_serialization_json/test/intersection_type_test.dart b/packages/kiota_serialization_json/test/intersection_type_test.dart index 842f134..fa83504 100644 --- a/packages/kiota_serialization_json/test/intersection_type_test.dart +++ b/packages/kiota_serialization_json/test/intersection_type_test.dart @@ -101,8 +101,10 @@ void main() { ..serialize(writer); final content = writer.getSerializedContent(); final result = utf8.decode(content); - expect(result, - '{"id":"opaque","officeLocation":"Montreal","displayName":"McGill"}'); + expect( + result, + '{"id":"opaque","officeLocation":"Montreal","displayName":"McGill"}', + ); }); test('SerializeIntersectionTypeComplexProperty2', () { @@ -132,8 +134,10 @@ void main() { ..serialize(writer); final content = writer.getSerializedContent(); final result = utf8.decode(content); - expect(result, - '[{"id":"10","namingEnum":"Item2:SubItem1","officeLocation":"Montreal"},{"id":"11","namingEnum":"Item3:SubItem1","officeLocation":"Ottawa"}]'); + expect( + result, + '[{"id":"10","namingEnum":"Item2:SubItem1","officeLocation":"Montreal"},{"id":"11","namingEnum":"Item3:SubItem1","officeLocation":"Ottawa"}]', + ); }); }); } diff --git a/packages/kiota_serialization_json/test/json_parse_node_factory_test.dart b/packages/kiota_serialization_json/test/json_parse_node_factory_test.dart index b8d4ab1..7dc39be 100644 --- a/packages/kiota_serialization_json/test/json_parse_node_factory_test.dart +++ b/packages/kiota_serialization_json/test/json_parse_node_factory_test.dart @@ -8,17 +8,19 @@ void main() { test('getParseNodeForJsonContentType', () { final json = utf8.encode('{"key":"value"}'); final factory = JsonParseNodeFactory(); - final JsonParseNode = + final jsonParseNode = factory.getRootParseNode(factory.validContentType, json); - expect(JsonParseNode, isNotNull); + expect(jsonParseNode, isNotNull); }); test('testThrowsExceptionForInvalidContentType', () { const streamContentType = 'application/octet-stream'; final json = utf8.encode('{"key":"value"}'); final factory = JsonParseNodeFactory(); - expect(() => factory.getRootParseNode(streamContentType, json), - throwsArgumentError); + expect( + () => factory.getRootParseNode(streamContentType, json), + throwsArgumentError, + ); }); }); } diff --git a/packages/kiota_serialization_json/test/json_parse_node_test.dart b/packages/kiota_serialization_json/test/json_parse_node_test.dart index ce1b77f..2a34b0a 100644 --- a/packages/kiota_serialization_json/test/json_parse_node_test.dart +++ b/packages/kiota_serialization_json/test/json_parse_node_test.dart @@ -168,8 +168,10 @@ void main() { test('Get enumcollection from json', () { final jsonParseNode = JsonParseNode(jsonDecode(_testCollectionOfEnumsJson)); - final testCollection = jsonParseNode.getCollectionOfEnumValues((value) => - NamingEnum.values.where((ne) => ne.value == value).firstOrNull); + final testCollection = jsonParseNode.getCollectionOfEnumValues( + (value) => + NamingEnum.values.where((ne) => ne.value == value).firstOrNull, + ); expect(testCollection, isNotNull); expect(testCollection.length, 2); diff --git a/packages/kiota_serialization_json/test/json_serialization_writer_factory_test.dart b/packages/kiota_serialization_json/test/json_serialization_writer_factory_test.dart index e51afda..06f6795 100644 --- a/packages/kiota_serialization_json/test/json_serialization_writer_factory_test.dart +++ b/packages/kiota_serialization_json/test/json_serialization_writer_factory_test.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; -import 'package:kiota_abstractions/kiota_abstractions.dart'; import 'package:kiota_serialization_json/kiota_serialization_json.dart'; import 'package:test/test.dart'; @@ -15,8 +13,10 @@ void main() { test('testThrowsExceptionForInvalidContentType', () { const streamContentType = 'application/octet-stream'; final factory = JsonSerializationWriterFactory(); - expect(() => factory.getSerializationWriter(streamContentType), - throwsArgumentError); + expect( + () => factory.getSerializationWriter(streamContentType), + throwsArgumentError, + ); }); }); } diff --git a/packages/kiota_serialization_json/test/json_serialization_writer_test.dart b/packages/kiota_serialization_json/test/json_serialization_writer_test.dart index dcd051f..2a237d6 100644 --- a/packages/kiota_serialization_json/test/json_serialization_writer_test.dart +++ b/packages/kiota_serialization_json/test/json_serialization_writer_test.dart @@ -59,7 +59,8 @@ void main() { expect( utf8.decode(writer.getSerializedContent()), equals( - '{"id":"abc","createdDateTime":"2023-12-01T15:15:00.000","officeLocation":"at the desk","workDuration":"40:00:00.000000","birthDay":"2024-10-01","heightInMetres":1.7,"startWorkTime":"06:00:00","active":true,"numbers":[2,3,5],"a":"some value","b":12,"c":false}'), + '{"id":"abc","createdDateTime":"2023-12-01T15:15:00.000","officeLocation":"at the desk","workDuration":"40:00:00.000000","birthDay":"2024-10-01","heightInMetres":1.7,"startWorkTime":"06:00:00","active":true,"numbers":[2,3,5],"a":"some value","b":12,"c":false}', + ), ); }); @@ -88,7 +89,8 @@ void main() { expect( utf8.decode(writer.getSerializedContent()), equals( - '{"name":"a group","leader":{"heightInMetres":1.9,"endWorkTime":"17:00:00"},"members":[{"officeLocation":"on a chair","workDuration":"2:00:00.000000","a":"#1 coworker"},{"workDuration":"12:00:00.000000","active":true}]}'), + '{"name":"a group","leader":{"heightInMetres":1.9,"endWorkTime":"17:00:00"},"members":[{"officeLocation":"on a chair","workDuration":"2:00:00.000000","a":"#1 coworker"},{"workDuration":"12:00:00.000000","active":true}]}', + ), ); }); }); diff --git a/packages/kiota_serialization_json/test/microsoft_graph_group.dart b/packages/kiota_serialization_json/test/microsoft_graph_group.dart index c27f6c8..f6f6cf9 100644 --- a/packages/kiota_serialization_json/test/microsoft_graph_group.dart +++ b/packages/kiota_serialization_json/test/microsoft_graph_group.dart @@ -30,7 +30,8 @@ class MicrosoftGraphGroup extends Parsable implements AdditionalDataHolder { 'leader': (node) => leader = node.getObjectValue(MicrosoftGraphUser.createFromDiscriminator), 'members': (node) => members = node.getCollectionOfObjectValues( - MicrosoftGraphUser.createFromDiscriminator), + MicrosoftGraphUser.createFromDiscriminator, + ), }; } diff --git a/packages/kiota_serialization_json/test/second_test_entity.dart b/packages/kiota_serialization_json/test/second_test_entity.dart index de37066..dd9043e 100644 --- a/packages/kiota_serialization_json/test/second_test_entity.dart +++ b/packages/kiota_serialization_json/test/second_test_entity.dart @@ -3,7 +3,7 @@ import 'package:kiota_abstractions/kiota_abstractions.dart'; class SecondTestEntity extends Parsable implements AdditionalDataHolder { SecondTestEntity(); - factory SecondTestEntity.createFromDiscriminatorValue(ParseNode parseNode) { + factory SecondTestEntity.createFromDiscriminatorValue(ParseNode _) { return SecondTestEntity(); } @@ -25,9 +25,9 @@ class SecondTestEntity extends Parsable implements AdditionalDataHolder { @override void serialize(SerializationWriter writer) { writer - ..writeStringValue("displayName", displayName) - ..writeIntValue("id", id) - ..writeIntValue("failureRate", failureRate) + ..writeStringValue('displayName', displayName) + ..writeIntValue('id', id) + ..writeIntValue('failureRate', failureRate) ..writeAdditionalData(additionalData); } } diff --git a/packages/kiota_serialization_json/test/union_type_mock.dart b/packages/kiota_serialization_json/test/union_type_mock.dart index 2b38a75..a5e0d17 100644 --- a/packages/kiota_serialization_json/test/union_type_mock.dart +++ b/packages/kiota_serialization_json/test/union_type_mock.dart @@ -20,11 +20,13 @@ class UnionTypeMock extends Parsable implements AdditionalDataHolder { result.stringValue = parseNode.getStringValue(); } else if (parseNode .getCollectionOfObjectValues( - MicrosoftGraphUser.createFromDiscriminator) + MicrosoftGraphUser.createFromDiscriminator, + ) .isNotEmpty) { result.composedType3 = parseNode.getCollectionOfObjectValues( - MicrosoftGraphUser.createFromDiscriminator); + MicrosoftGraphUser.createFromDiscriminator, + ); } return result; } diff --git a/packages/kiota_serialization_json/test/union_type_test.dart b/packages/kiota_serialization_json/test/union_type_test.dart index 927d314..1000209 100644 --- a/packages/kiota_serialization_json/test/union_type_test.dart +++ b/packages/kiota_serialization_json/test/union_type_test.dart @@ -127,8 +127,10 @@ void main() { ..serialize(writer); final content = writer.getSerializedContent(); final result = utf8.decode(content); - expect(result, - '[{"id":"10","officeLocation":"Montreal"},{"id":"11","officeLocation":"Ottawa"}]'); + expect( + result, + '[{"id":"10","officeLocation":"Montreal"},{"id":"11","officeLocation":"Ottawa"}]', + ); }); }); } diff --git a/packages/kiota_serialization_text/test/text_parse_node_test.dart b/packages/kiota_serialization_text/test/text_parse_node_test.dart index a7f338d..8124c7d 100644 --- a/packages/kiota_serialization_text/test/text_parse_node_test.dart +++ b/packages/kiota_serialization_text/test/text_parse_node_test.dart @@ -88,7 +88,7 @@ void main() { expect( node.getGuidValue(), - equals(UuidValue.nil), + equals(UuidValue.fromString('00000000-0000-0000-0000-000000000000')), ); });