Skip to content

Commit

Permalink
fix analyze issues, add a comment to readme.md on how to check that c…
Browse files Browse the repository at this point in the history
…ode has no analyze problems
  • Loading branch information
Yahhi committed Mar 14, 2020
1 parent 8ca3f1b commit bec8450
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 49 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 5 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
include: package:pedantic/analysis_options.yaml

analyzer:
errors:
todo: ignore
omit_local_variable_types: ignore
5 changes: 3 additions & 2 deletions lib/data/local/data_source.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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');
Expand Down
3 changes: 1 addition & 2 deletions lib/domain/entities/entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/widgets.dart';

@immutable
abstract class Entity<TKey> extends Equatable{
abstract class Entity<TKey> extends Equatable {
final TKey id;

Entity(this.id);

@override
Map<String, dynamic> toMap();

@override
Expand Down
6 changes: 3 additions & 3 deletions test/data/local/all_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> args) {
void main(List<String> args) {
// run tests on all data sources (tables)
delivery_method_data_source_test.main();
category_hashtag_data_source_test.main();
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/cart/product_cart_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void main() {
await dataSource.deleteAll();

List<ProductCartEntity> allData = await dataSource.all();
expect(allData.length == 0, true);
expect(allData.isEmpty, true);
});

test('test: delete a record in productcart table', () async {
Expand All @@ -65,7 +65,7 @@ void main() {
await dataSource.delete(1);

List<ProductCartEntity> allData = await dataSource.all();
expect(allData.length == 0, true);
expect(allData.isEmpty, true);
});

test('test: get all records in productcart table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
await dataSource.deleteAll();

List<DeliveryMethodEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in DeliveryMethod table', () async {
Expand All @@ -62,7 +62,7 @@ void main() {
await dataSource.delete(1);

List<DeliveryMethodEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in DeliveryMethod table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
await dataSource.deleteAll();

List<CategoryHashTagEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in CategoryHashTag table', () async {
Expand All @@ -62,7 +62,7 @@ void main() {
await dataSource.delete(1);

List<CategoryHashTagEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in CategoryHashTag table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/hashtag/hashtag_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void main() {
await dataSource.deleteAll();

List<HashTagEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in HashTag table', () async {
Expand All @@ -76,7 +76,7 @@ void main() {
await dataSource.delete(1);

List<HashTagEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in HashTag table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/hashtag/product_hashtag_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void main() {
await dataSource.deleteAll();

List<ProductHashTagEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductHashTag table', () async {
Expand All @@ -62,7 +62,7 @@ void main() {
await dataSource.delete(1);

List<ProductHashTagEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductHashTag table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/order/order_product_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void main() {
await dataSource.deleteAll();

List<OrderProductEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in OrderProduct table', () async {
Expand All @@ -104,7 +104,7 @@ void main() {
await dataSource.delete(1);

List<OrderProductEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in OrderProduct table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void main() {
await dataSource.deleteAll();

List<OrderProductParameterEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in OrderProductParameter table', () async {
Expand All @@ -67,7 +67,7 @@ void main() {
await dataSource.delete(1);

List<OrderProductParameterEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in OrderProductParameter table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/order/user_order_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void main() {
await dataSource.deleteAll();

List<UserOrderEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in UserOrder table', () async {
Expand All @@ -139,7 +139,7 @@ void main() {
await dataSource.delete(1);

List<UserOrderEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in UserOrder table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void main() {
await dataSource.deleteAll();

List<Product2ParameterEntity> allData = await dataSource.all();
expect(allData.length == 0, true);
expect(allData.isEmpty, true);
});

test('test: delete a record in product2parameter table', () async {
Expand All @@ -84,7 +84,7 @@ void main() {
await dataSource.delete(1);

List<Product2ParameterEntity> allData = await dataSource.all();
expect(allData.length == 0, true);
expect(allData.isEmpty, true);
});

test('test: get all records in product2parameter table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void main() {
await dataSource.deleteAll();

List<ProductCategoryEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductCategory table', () async {
Expand All @@ -97,7 +97,7 @@ void main() {
await dataSource.delete(1);

List<ProductCategoryEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductCategory table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/product/product_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void main() {
await productDataSource.deleteAll();

List<ProductEntity> allProducts = await productDataSource.all();
expect(allProducts.length == 0, true);
expect(allProducts.isEmpty, true);
});

test('test: delete a product', () async {
Expand Down Expand Up @@ -175,7 +175,7 @@ void main() {
await productDataSource.delete(1);

List<ProductEntity> allProducts = await productDataSource.all();
expect(allProducts.length == 0, true);
expect(allProducts.isEmpty, true);
});

test('test: get all products', () async {
Expand Down
6 changes: 3 additions & 3 deletions test/data/local/product/product_image_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void main() {
await dataSource.deleteAll();

List<ProductImageEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductImage table', () async {
Expand All @@ -90,7 +90,7 @@ void main() {
await dataSource.delete(1);

List<ProductImageEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductImage table', () async {
Expand Down Expand Up @@ -118,7 +118,7 @@ void main() {
List<ProductImageEntity> allRecords = await dataSource.all();
expect(allRecords.length == 3, true);
});

tearDown(() async {
await dataSource.close();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void main() {
await dataSource.deleteAll();

List<ProductParameterEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductParameter table', () async {
Expand All @@ -77,7 +77,7 @@ void main() {
await dataSource.delete(1);

List<ProductParameterEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductParameter table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void main() {
await dataSource.deleteAll();

List<ProductParameterVariantEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductParameterVariant table', () async {
Expand All @@ -95,7 +95,7 @@ void main() {
await dataSource.delete(1);

List<ProductParameterVariantEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductParameterVariant table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/product/product_review_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void main() {
await dataSource.deleteAll();

List<ProductReviewEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductReview table', () async {
Expand All @@ -118,7 +118,7 @@ void main() {
await dataSource.delete(1);

List<ProductReviewEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductReview table', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void main() {
await dataSource.deleteAll();

List<ProductReviewPhotoEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: delete a record in ProductReviewPhoto table', () async {
Expand All @@ -84,7 +84,7 @@ void main() {
await dataSource.delete(1);

List<ProductReviewPhotoEntity> allRecords = await dataSource.all();
expect(allRecords.length == 0, true);
expect(allRecords.isEmpty, true);
});

test('test: get all records in ProductReviewPhoto table', () async {
Expand Down
4 changes: 2 additions & 2 deletions test/data/local/promo/promo_code_data_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void main() {
await dataSource.deleteAll();

List<PromoCodeEntity> allData = await dataSource.all();
expect(allData.length == 0, true);
expect(allData.isEmpty, true);
});

test('test: delete a record in promocode table', () async {
Expand All @@ -104,7 +104,7 @@ void main() {
await dataSource.delete(1);

List<PromoCodeEntity> allData = await dataSource.all();
expect(allData.length == 0, true);
expect(allData.isEmpty, true);
});

test('test: get all records in promocode table', () async {
Expand Down
Loading

0 comments on commit bec8450

Please sign in to comment.