diff --git a/README.md b/README.md index 9b652eae..1acdefca 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,12 @@ The example for VS Code is below: "type": "dart" } ] + +To check the code quality with Flutter Analyzer (recommended when you want to add something) please run in console: + + flutter analyze + +It should give no errors message: + + Analyzing openflutterecommerceapp... + No issues found! (ran in 3.5s) \ No newline at end of file diff --git a/analysis_options.yaml b/analysis_options.yaml index 108d1058..9a7b6b26 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +1,6 @@ include: package:pedantic/analysis_options.yaml + +analyzer: + errors: + todo: ignore + omit_local_variable_types: ignore \ No newline at end of file diff --git a/lib/data/local/data_source.dart b/lib/data/local/data_source.dart index 8f45935b..b8e051e1 100644 --- a/lib/data/local/data_source.dart +++ b/lib/data/local/data_source.dart @@ -1,7 +1,8 @@ +import 'package:openflutterecommerce/domain/entities/entity.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; + import 'config.dart'; -import 'package:openflutterecommerce/domain/entities/entity.dart'; abstract class DataSource { Database db; @@ -85,7 +86,7 @@ abstract class DataSource { await db.close(); } - checkDatabaseConnection() { + void checkDatabaseConnection() { if (db == null) { throw Exception( 'No open connection to database - call .open() on the datasource to establish a connection to the database'); diff --git a/lib/domain/entities/entity.dart b/lib/domain/entities/entity.dart index e4d29b6d..28e662a1 100644 --- a/lib/domain/entities/entity.dart +++ b/lib/domain/entities/entity.dart @@ -2,12 +2,11 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/widgets.dart'; @immutable -abstract class Entity extends Equatable{ +abstract class Entity extends Equatable { final TKey id; Entity(this.id); - @override Map toMap(); @override diff --git a/test/data/local/all_tests.dart b/test/data/local/all_tests.dart index c3c74399..888877b7 100644 --- a/test/data/local/all_tests.dart +++ b/test/data/local/all_tests.dart @@ -12,6 +12,8 @@ import 'order/order_product_data_source_test.dart' import 'order/order_product_parameter_data_source_test.dart' as order_product_parameter_data_source_test; import 'order/user_order_data_source_test.dart' as user_order_data_source_test; +import 'product/product2parameter_data_source_test.dart' + as product2parameter_data_source_test; import 'product/product_category_data_source_test.dart' as product_category_data_source_test; import 'product/product_data_source_test.dart' as product_data_source_test; @@ -25,14 +27,12 @@ import 'product/product_review_data_source_test.dart' as product_review_data_source_test; import 'product/product_review_photo_data_source_test.dart' as product_review_photo_data_source_test; -import 'product/product2parameter_data_source_test.dart' - as product2parameter_data_source_test; import 'promo/promo_code_data_source_test.dart' as promo_code_data_source_test; import 'user/shipping_address_data_source_test.dart' as shipping_address_data_source_test; import 'user/user_data_source_test.dart' as user_data_source_test; -main(List args) { +void main(List args) { // run tests on all data sources (tables) delivery_method_data_source_test.main(); category_hashtag_data_source_test.main(); diff --git a/test/data/local/cart/product_cart_data_source_test.dart b/test/data/local/cart/product_cart_data_source_test.dart index edee6e5c..73bb3281 100644 --- a/test/data/local/cart/product_cart_data_source_test.dart +++ b/test/data/local/cart/product_cart_data_source_test.dart @@ -53,7 +53,7 @@ void main() { await dataSource.deleteAll(); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: delete a record in productcart table', () async { @@ -65,7 +65,7 @@ void main() { await dataSource.delete(1); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: get all records in productcart table', () async { diff --git a/test/data/local/delivery/delivery_method_data_source_test.dart b/test/data/local/delivery/delivery_method_data_source_test.dart index 94cf866c..24d1ad08 100644 --- a/test/data/local/delivery/delivery_method_data_source_test.dart +++ b/test/data/local/delivery/delivery_method_data_source_test.dart @@ -50,7 +50,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in DeliveryMethod table', () async { @@ -62,7 +62,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in DeliveryMethod table', () async { diff --git a/test/data/local/hashtag/category_hashtag_data_source_test.dart b/test/data/local/hashtag/category_hashtag_data_source_test.dart index 1c7c0b1c..e68ee729 100644 --- a/test/data/local/hashtag/category_hashtag_data_source_test.dart +++ b/test/data/local/hashtag/category_hashtag_data_source_test.dart @@ -50,7 +50,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in CategoryHashTag table', () async { @@ -62,7 +62,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in CategoryHashTag table', () async { diff --git a/test/data/local/hashtag/hashtag_data_source_test.dart b/test/data/local/hashtag/hashtag_data_source_test.dart index 654a3df1..f8ec1b06 100644 --- a/test/data/local/hashtag/hashtag_data_source_test.dart +++ b/test/data/local/hashtag/hashtag_data_source_test.dart @@ -62,7 +62,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in HashTag table', () async { @@ -76,7 +76,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in HashTag table', () async { diff --git a/test/data/local/hashtag/product_hashtag_data_source_test.dart b/test/data/local/hashtag/product_hashtag_data_source_test.dart index 8f500f0e..8b565ad2 100644 --- a/test/data/local/hashtag/product_hashtag_data_source_test.dart +++ b/test/data/local/hashtag/product_hashtag_data_source_test.dart @@ -50,7 +50,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductHashTag table', () async { @@ -62,7 +62,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductHashTag table', () async { diff --git a/test/data/local/order/order_product_data_source_test.dart b/test/data/local/order/order_product_data_source_test.dart index e0f86789..f9d80d62 100644 --- a/test/data/local/order/order_product_data_source_test.dart +++ b/test/data/local/order/order_product_data_source_test.dart @@ -86,7 +86,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in OrderProduct table', () async { @@ -104,7 +104,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in OrderProduct table', () async { diff --git a/test/data/local/order/order_product_parameter_data_source_test.dart b/test/data/local/order/order_product_parameter_data_source_test.dart index 34b43c1b..30626e52 100644 --- a/test/data/local/order/order_product_parameter_data_source_test.dart +++ b/test/data/local/order/order_product_parameter_data_source_test.dart @@ -55,7 +55,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in OrderProductParameter table', () async { @@ -67,7 +67,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in OrderProductParameter table', () async { diff --git a/test/data/local/order/user_order_data_source_test.dart b/test/data/local/order/user_order_data_source_test.dart index ce1e7884..a1e692f5 100644 --- a/test/data/local/order/user_order_data_source_test.dart +++ b/test/data/local/order/user_order_data_source_test.dart @@ -116,7 +116,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in UserOrder table', () async { @@ -139,7 +139,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in UserOrder table', () async { diff --git a/test/data/local/product/product2parameter_data_source_test.dart b/test/data/local/product/product2parameter_data_source_test.dart index e27b1926..a34969d6 100644 --- a/test/data/local/product/product2parameter_data_source_test.dart +++ b/test/data/local/product/product2parameter_data_source_test.dart @@ -69,7 +69,7 @@ void main() { await dataSource.deleteAll(); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: delete a record in product2parameter table', () async { @@ -84,7 +84,7 @@ void main() { await dataSource.delete(1); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: get all records in product2parameter table', () async { diff --git a/test/data/local/product/product_category_data_source_test.dart b/test/data/local/product/product_category_data_source_test.dart index bf01abc9..70c5b162 100644 --- a/test/data/local/product/product_category_data_source_test.dart +++ b/test/data/local/product/product_category_data_source_test.dart @@ -80,7 +80,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductCategory table', () async { @@ -97,7 +97,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductCategory table', () async { diff --git a/test/data/local/product/product_data_source_test.dart b/test/data/local/product/product_data_source_test.dart index 6a423f31..a2141409 100644 --- a/test/data/local/product/product_data_source_test.dart +++ b/test/data/local/product/product_data_source_test.dart @@ -147,7 +147,7 @@ void main() { await productDataSource.deleteAll(); List allProducts = await productDataSource.all(); - expect(allProducts.length == 0, true); + expect(allProducts.isEmpty, true); }); test('test: delete a product', () async { @@ -175,7 +175,7 @@ void main() { await productDataSource.delete(1); List allProducts = await productDataSource.all(); - expect(allProducts.length == 0, true); + expect(allProducts.isEmpty, true); }); test('test: get all products', () async { diff --git a/test/data/local/product/product_image_data_source_test.dart b/test/data/local/product/product_image_data_source_test.dart index 9c97b80b..168742a5 100644 --- a/test/data/local/product/product_image_data_source_test.dart +++ b/test/data/local/product/product_image_data_source_test.dart @@ -74,7 +74,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductImage table', () async { @@ -90,7 +90,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductImage table', () async { @@ -118,7 +118,7 @@ void main() { List allRecords = await dataSource.all(); expect(allRecords.length == 3, true); }); - + tearDown(() async { await dataSource.close(); }); diff --git a/test/data/local/product/product_parameter_data_source_test.dart b/test/data/local/product/product_parameter_data_source_test.dart index ee7657b0..90d4724c 100644 --- a/test/data/local/product/product_parameter_data_source_test.dart +++ b/test/data/local/product/product_parameter_data_source_test.dart @@ -63,7 +63,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductParameter table', () async { @@ -77,7 +77,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductParameter table', () async { diff --git a/test/data/local/product/product_parameter_variant_data_source_test.dart b/test/data/local/product/product_parameter_variant_data_source_test.dart index d8c8c287..a146d01a 100644 --- a/test/data/local/product/product_parameter_variant_data_source_test.dart +++ b/test/data/local/product/product_parameter_variant_data_source_test.dart @@ -79,7 +79,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductParameterVariant table', () async { @@ -95,7 +95,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductParameterVariant table', () async { diff --git a/test/data/local/product/product_review_data_source_test.dart b/test/data/local/product/product_review_data_source_test.dart index ae7c5e0e..3e4dd1f4 100644 --- a/test/data/local/product/product_review_data_source_test.dart +++ b/test/data/local/product/product_review_data_source_test.dart @@ -98,7 +98,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductReview table', () async { @@ -118,7 +118,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductReview table', () async { diff --git a/test/data/local/product/product_review_photo_data_source_test.dart b/test/data/local/product/product_review_photo_data_source_test.dart index c993cf7b..632f6405 100644 --- a/test/data/local/product/product_review_photo_data_source_test.dart +++ b/test/data/local/product/product_review_photo_data_source_test.dart @@ -69,7 +69,7 @@ void main() { await dataSource.deleteAll(); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: delete a record in ProductReviewPhoto table', () async { @@ -84,7 +84,7 @@ void main() { await dataSource.delete(1); List allRecords = await dataSource.all(); - expect(allRecords.length == 0, true); + expect(allRecords.isEmpty, true); }); test('test: get all records in ProductReviewPhoto table', () async { diff --git a/test/data/local/promo/promo_code_data_source_test.dart b/test/data/local/promo/promo_code_data_source_test.dart index 4f9cde29..c0e7acae 100644 --- a/test/data/local/promo/promo_code_data_source_test.dart +++ b/test/data/local/promo/promo_code_data_source_test.dart @@ -86,7 +86,7 @@ void main() { await dataSource.deleteAll(); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: delete a record in promocode table', () async { @@ -104,7 +104,7 @@ void main() { await dataSource.delete(1); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: get all records in promocode table', () async { diff --git a/test/data/local/user/shipping_address_data_source_test.dart b/test/data/local/user/shipping_address_data_source_test.dart index eea5c5e5..f705385a 100644 --- a/test/data/local/user/shipping_address_data_source_test.dart +++ b/test/data/local/user/shipping_address_data_source_test.dart @@ -86,7 +86,7 @@ void main() { await dataSource.deleteAll(); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: delete a record in shippingaddress table', () async { @@ -103,7 +103,7 @@ void main() { await dataSource.delete(1); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: get all records in shippingaddress table', () async { diff --git a/test/data/local/user/user_data_source_test.dart b/test/data/local/user/user_data_source_test.dart index c15ee738..e7fce7e4 100644 --- a/test/data/local/user/user_data_source_test.dart +++ b/test/data/local/user/user_data_source_test.dart @@ -98,7 +98,7 @@ void main() { await dataSource.deleteAll(); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: delete a record in user table', () async { @@ -118,7 +118,7 @@ void main() { await dataSource.delete(1); List allData = await dataSource.all(); - expect(allData.length == 0, true); + expect(allData.isEmpty, true); }); test('test: get all records in user table', () async { diff --git a/test/tests.dart b/test/tests.dart index 0e0382c1..8009af7a 100644 --- a/test/tests.dart +++ b/test/tests.dart @@ -1,6 +1,5 @@ import '../test/data/local/all_tests.dart' as local_database_test; - -main(List args) { +void main(List args) { local_database_test.main(args); -} \ No newline at end of file +}