From b4e98eb659a0f8fa70994269bf9822368bfd442d Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Thu, 15 Aug 2024 16:10:26 +0200 Subject: [PATCH] fix lints --- .../analysis_options.yaml | 75 ++++------------ .../example/main.dart | 2 + .../lib/src/sqflite_ffi_async_database.dart | 1 + packages_web/sqflite_common_ffi_web/README.md | 3 +- .../analysis_options.yaml | 76 +++------------- sqflite/analysis_options.yaml | 80 ++++------------- sqflite_common/analysis_options.yaml | 86 ++++--------------- sqflite_common/lib/src/database_mixin.dart | 5 ++ sqflite_common/lib/src/dev_utils.dart | 1 + .../lib/src/logger/sqflite_logger.dart | 1 + .../lib/src/sqflite_database_factory.dart | 1 + sqflite_common/lib/src/utils.dart | 1 + sqflite_common/lib/src/value_utils.dart | 1 + .../test/database_file_system_io_test.dart | 1 + sqflite_common/test/sqflite_logger_test.dart | 2 + sqflite_common_ffi/analysis_options.yaml | 75 ++++------------ sqflite_common_ffi/example/main.dart | 2 + .../example/persistent_example.dart | 2 + .../lib/src/database_factory_ffi_io.dart | 19 ++-- .../lib/src/database_tracker.dart | 2 + sqflite_common_ffi/lib/src/isolate.dart | 2 + .../lib/src/sqflite_ffi_impl.dart | 25 +++--- .../lib/src/windows/setup_impl.dart | 1 + .../test/sqflite_factory_ffi_test.dart | 2 + .../test/sqflite_ffi_api_test.dart | 2 + .../test/sqflite_ffi_doc_test.dart | 1 + sqflite_common_ffi/tool/windows_setup.dart | 11 +-- sqflite_common_test/analysis_options.yaml | 75 ++++------------ 28 files changed, 152 insertions(+), 403 deletions(-) diff --git a/packages/sqflite_common_ffi_async/analysis_options.yaml b/packages/sqflite_common_ffi_async/analysis_options.yaml index 13b24ca5..4ff2f91e 100644 --- a/packages/sqflite_common_ffi_async/analysis_options.yaml +++ b/packages/sqflite_common_ffi_async/analysis_options.yaml @@ -29,78 +29,33 @@ linter: rules: - always_declare_return_types - avoid_dynamic_calls - - avoid_empty_else - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters + - avoid_print - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - cancel_subscriptions - - curly_braces_in_flow_control_structures - # - depend_on_referenced_packages + - deprecated_member_use_from_same_package - directives_ordering - - empty_catches - - hash_and_equals - - collection_methods_unrelated_type + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - library_names + - list_remove_unrelated_type - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType + - prefer_const_constructors + - prefer_const_literals_to_create_immutables + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes - - prefer_typing_uninitialized_variables + - prefer_void_to_null + - public_member_api_docs - sort_child_properties_last - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_null_aware_assignments - unnecessary_statements - - unrelated_type_equality_checks - unsafe_html - use_full_hex_values_for_flutter_colors - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - # - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - dangling_library_doc_comments - - deprecated_member_use_from_same_package - - implicit_reopen - - invalid_case_patterns - - no_literal_bool_comparisons - - no_self_assignments - - no_wildcard_variable_uses - - type_literal_in_constant_pattern - # === doc rules === - - public_member_api_docs diff --git a/packages/sqflite_common_ffi_async/example/main.dart b/packages/sqflite_common_ffi_async/example/main.dart index 1d6bf339..57f8a707 100644 --- a/packages/sqflite_common_ffi_async/example/main.dart +++ b/packages/sqflite_common_ffi_async/example/main.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:sqflite_common_ffi_async/sqflite_ffi_async.dart'; diff --git a/packages/sqflite_common_ffi_async/lib/src/sqflite_ffi_async_database.dart b/packages/sqflite_common_ffi_async/lib/src/sqflite_ffi_async_database.dart index 25d53594..124a625f 100644 --- a/packages/sqflite_common_ffi_async/lib/src/sqflite_ffi_async_database.dart +++ b/packages/sqflite_common_ffi_async/lib/src/sqflite_ffi_async_database.dart @@ -77,6 +77,7 @@ class SqfliteDatabaseFfiAsync extends SqfliteDatabaseBase { await dir.create(recursive: true); } } catch (e) { + // ignore: avoid_print print('error checking directory $dir: $e'); } sqliteOptions = const sqlite_async.SqliteOptions.defaults(); diff --git a/packages_web/sqflite_common_ffi_web/README.md b/packages_web/sqflite_common_ffi_web/README.md index e456621e..d88b3b86 100644 --- a/packages_web/sqflite_common_ffi_web/README.md +++ b/packages_web/sqflite_common_ffi_web/README.md @@ -3,6 +3,7 @@ sqlite Web implementation (experimental). Features: - Persistency (in indexeddb) - Cross-tab safe (runs in a shared worker) +- Wasm compatible Thanks Simon Binder for the excellent sqlite3 lib. @@ -11,7 +12,7 @@ Thanks Simon Binder for the excellent sqlite3 lib. Add the dependency: ```yaml dependencies: - sqflite_common_ffi_web: '>=0.1.0-dev.1' + sqflite_common_ffi_web: ``` ### Setup binaries diff --git a/packages_web/sqflite_common_ffi_web/analysis_options.yaml b/packages_web/sqflite_common_ffi_web/analysis_options.yaml index a8a8f2d2..12608547 100644 --- a/packages_web/sqflite_common_ffi_web/analysis_options.yaml +++ b/packages_web/sqflite_common_ffi_web/analysis_options.yaml @@ -31,81 +31,33 @@ linter: rules: - always_declare_return_types - avoid_dynamic_calls - - avoid_empty_else - avoid_print - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - cancel_subscriptions - - curly_braces_in_flow_control_structures - # - depend_on_referenced_packages + - deprecated_member_use_from_same_package - directives_ordering - - empty_catches - - hash_and_equals - - collection_methods_unrelated_type + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - library_names + - list_remove_unrelated_type - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType + - prefer_const_constructors + - prefer_const_literals_to_create_immutables + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes - - prefer_typing_uninitialized_variables + - prefer_void_to_null + - public_member_api_docs - sort_child_properties_last - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_null_aware_assignments - unnecessary_statements - - unrelated_type_equality_checks - unsafe_html - use_full_hex_values_for_flutter_colors - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - # - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - dangling_library_doc_comments - - deprecated_member_use_from_same_package - - implicit_reopen - - invalid_case_patterns - - no_literal_bool_comparisons - - no_self_assignments - - no_wildcard_variable_uses - - type_literal_in_constant_pattern - # New in 3.5 - - invalid_runtime_check_with_js_interop_types - # === doc rules === - - public_member_api_docs diff --git a/sqflite/analysis_options.yaml b/sqflite/analysis_options.yaml index cacf4e1a..4ee92678 100644 --- a/sqflite/analysis_options.yaml +++ b/sqflite/analysis_options.yaml @@ -28,82 +28,32 @@ linter: rules: - always_declare_return_types - avoid_dynamic_calls - - avoid_empty_else - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - cancel_subscriptions - - curly_braces_in_flow_control_structures + - deprecated_member_use_from_same_package - directives_ordering - - empty_catches - - hash_and_equals - - collection_methods_unrelated_type + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - library_names + - list_remove_unrelated_type - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType + - prefer_final_locals + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes - - prefer_typing_uninitialized_variables - - sort_child_properties_last + - prefer_void_to_null + - public_member_api_docs + - sort_constructors_first + - sort_unnamed_constructors_first - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_null_aware_assignments - unnecessary_statements - - unrelated_type_equality_checks - unsafe_html - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - # - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - dangling_library_doc_comments - - deprecated_member_use_from_same_package - - implicit_reopen - - invalid_case_patterns - - no_literal_bool_comparisons - - no_self_assignments - - no_wildcard_variable_uses - - type_literal_in_constant_pattern - - # === doc rules === - - public_member_api_docs - # - - prefer_final_locals - - sort_constructors_first - - sort_unnamed_constructors_first diff --git a/sqflite_common/analysis_options.yaml b/sqflite_common/analysis_options.yaml index e812a849..4ff2f91e 100644 --- a/sqflite_common/analysis_options.yaml +++ b/sqflite_common/analysis_options.yaml @@ -27,91 +27,35 @@ analyzer: linter: rules: - # - avoid_print - always_declare_return_types - avoid_dynamic_calls - - avoid_empty_else - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters + - avoid_print - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - cancel_subscriptions - - curly_braces_in_flow_control_structures - - depend_on_referenced_packages + - deprecated_member_use_from_same_package - directives_ordering - - empty_catches - - hash_and_equals - - collection_methods_unrelated_type - - library_private_types_in_public_api + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - library_names + - list_remove_unrelated_type - no_adjacent_strings_in_list - - no_duplicate_case_values - - no_leading_underscores_for_library_prefixes - - no_leading_underscores_for_local_identifiers - - non_constant_identifier_names - - null_check_on_nullable_type_parameter + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_interpolation_to_compose_strings - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType + - prefer_const_constructors + - prefer_const_literals_to_create_immutables + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes - - prefer_typing_uninitialized_variables + - prefer_void_to_null + - public_member_api_docs - sort_child_properties_last - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_constructor_name - # - unnecessary_import - - unnecessary_late - - unnecessary_null_aware_assignments - - unnecessary_nullable_for_final_variable_declarations - unnecessary_statements - # - unnecessary_type_check - - unrelated_type_equality_checks - unsafe_html - use_full_hex_values_for_flutter_colors - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - # - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - dangling_library_doc_comments - - deprecated_member_use_from_same_package - - implicit_reopen - - invalid_case_patterns - - no_literal_bool_comparisons - - no_self_assignments - - no_wildcard_variable_uses - - type_literal_in_constant_pattern - # === doc rules === - - public_member_api_docs diff --git a/sqflite_common/lib/src/database_mixin.dart b/sqflite_common/lib/src/database_mixin.dart index c88ce668..002265d9 100644 --- a/sqflite_common/lib/src/database_mixin.dart +++ b/sqflite_common/lib/src/database_mixin.dart @@ -842,6 +842,7 @@ mixin SqfliteDatabaseMixin implements SqfliteDatabase { paramInTransaction: false }); } catch (e) { + // ignore: avoid_print print('ignore recovered database ROLLBACK error $e'); } } @@ -882,6 +883,7 @@ mixin SqfliteDatabaseMixin implements SqfliteDatabase { } }); } catch (e) { + // ignore: avoid_print print('Error $e before rollback'); } } @@ -892,6 +894,7 @@ mixin SqfliteDatabaseMixin implements SqfliteDatabase { try { await safeAction(() => invokeCloseDatabase(databaseId)); } catch (e) { + // ignore: avoid_print print('error $e closing database $databaseId'); } } @@ -961,6 +964,7 @@ mixin SqfliteDatabaseMixin implements SqfliteDatabase { } catch (e) { // This exception is sometimes hard te catch // during development + // ignore: avoid_print print(e); // create a transaction just to make the current transaction happy @@ -1039,6 +1043,7 @@ mixin SqfliteDatabaseMixin implements SqfliteDatabase { return this; } catch (e) { + // ignore: avoid_print print('error $e during open, closing...'); await doClose(); rethrow; diff --git a/sqflite_common/lib/src/dev_utils.dart b/sqflite_common/lib/src/dev_utils.dart index 6d62eb34..86865ade 100644 --- a/sqflite_common/lib/src/dev_utils.dart +++ b/sqflite_common/lib/src/dev_utils.dart @@ -1,6 +1,7 @@ /// Deprecated to prevent keeping the code used. @Deprecated('Dev only') void devPrint(Object? object) { + // ignore: avoid_print print(object); } diff --git a/sqflite_common/lib/src/logger/sqflite_logger.dart b/sqflite_common/lib/src/logger/sqflite_logger.dart index ea29582a..6330a41a 100644 --- a/sqflite_common/lib/src/logger/sqflite_logger.dart +++ b/sqflite_common/lib/src/logger/sqflite_logger.dart @@ -526,6 +526,7 @@ class _EventInfo { T throwOrResult() { if (error != null) { if (isDebug && (stackTrace != null)) { + // ignore: avoid_print print(stackTrace); } throw error!; diff --git a/sqflite_common/lib/src/sqflite_database_factory.dart b/sqflite_common/lib/src/sqflite_database_factory.dart index f8de0352..dd53c1fc 100644 --- a/sqflite_common/lib/src/sqflite_database_factory.dart +++ b/sqflite_common/lib/src/sqflite_database_factory.dart @@ -42,6 +42,7 @@ set databaseFactory(DatabaseFactory? databaseFactory) { // Warn when changing. might throw in the future if (databaseFactory != null) { if (_databaseFactory != null) { + // ignore: avoid_print print(''' *** sqflite warning *** diff --git a/sqflite_common/lib/src/utils.dart b/sqflite_common/lib/src/utils.dart index 73b6a2c7..4a754214 100644 --- a/sqflite_common/lib/src/utils.dart +++ b/sqflite_common/lib/src/utils.dart @@ -41,6 +41,7 @@ Duration? lockWarningDuration = constant.lockWarningDurationDefault; void Function()? lockWarningCallback = _lockWarningCallbackDefault; void _lockWarningCallbackDefault() { + // ignore: avoid_print print('Warning database has been locked for $lockWarningDuration. ' 'Make sure you always use the transaction object for database operations during a transaction'); } diff --git a/sqflite_common/lib/src/value_utils.dart b/sqflite_common/lib/src/value_utils.dart index ed0bb4a3..65226e25 100644 --- a/sqflite_common/lib/src/value_utils.dart +++ b/sqflite_common/lib/src/value_utils.dart @@ -32,6 +32,7 @@ This will throw an exception in the future. For now it is displayed once per typ final printed = _debugCheckPrinted[type] ?? false; if (!printed) { _debugCheckPrinted[type] = true; + // ignore: avoid_print print(text); } } diff --git a/sqflite_common/test/database_file_system_io_test.dart b/sqflite_common/test/database_file_system_io_test.dart index cc3e1eb7..b22469fe 100644 --- a/sqflite_common/test/database_file_system_io_test.dart +++ b/sqflite_common/test/database_file_system_io_test.dart @@ -13,6 +13,7 @@ void main() { try { await fileSystem.readDatabaseBytes(path); } catch (e) { + // ignore: avoid_print print(e); } await fileSystem.writeDatabaseBytes(path, Uint8List.fromList([1, 2, 3])); diff --git a/sqflite_common/test/sqflite_logger_test.dart b/sqflite_common/test/sqflite_logger_test.dart index 9104505c..e6753e47 100644 --- a/sqflite_common/test/sqflite_logger_test.dart +++ b/sqflite_common/test/sqflite_logger_test.dart @@ -17,6 +17,7 @@ void main() { event.dump( print: (msg) { lines.add(msg?.toString() ?? ''); + // ignore: avoid_print print(msg); }, noStopwatch: true); @@ -46,6 +47,7 @@ void main() { event.dump( print: (msg) { lines.add(msg?.toString() ?? ''); + // ignore: avoid_print print(msg); }, noStopwatch: true); diff --git a/sqflite_common_ffi/analysis_options.yaml b/sqflite_common_ffi/analysis_options.yaml index 13b24ca5..4ff2f91e 100644 --- a/sqflite_common_ffi/analysis_options.yaml +++ b/sqflite_common_ffi/analysis_options.yaml @@ -29,78 +29,33 @@ linter: rules: - always_declare_return_types - avoid_dynamic_calls - - avoid_empty_else - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters + - avoid_print - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - cancel_subscriptions - - curly_braces_in_flow_control_structures - # - depend_on_referenced_packages + - deprecated_member_use_from_same_package - directives_ordering - - empty_catches - - hash_and_equals - - collection_methods_unrelated_type + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - library_names + - list_remove_unrelated_type - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType + - prefer_const_constructors + - prefer_const_literals_to_create_immutables + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes - - prefer_typing_uninitialized_variables + - prefer_void_to_null + - public_member_api_docs - sort_child_properties_last - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_null_aware_assignments - unnecessary_statements - - unrelated_type_equality_checks - unsafe_html - use_full_hex_values_for_flutter_colors - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - # - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - dangling_library_doc_comments - - deprecated_member_use_from_same_package - - implicit_reopen - - invalid_case_patterns - - no_literal_bool_comparisons - - no_self_assignments - - no_wildcard_variable_uses - - type_literal_in_constant_pattern - # === doc rules === - - public_member_api_docs diff --git a/sqflite_common_ffi/example/main.dart b/sqflite_common_ffi/example/main.dart index ce03f247..07ba4eea 100644 --- a/sqflite_common_ffi/example/main.dart +++ b/sqflite_common_ffi/example/main.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'package:sqflite_common_ffi/sqflite_ffi.dart'; Future main() async { diff --git a/sqflite_common_ffi/example/persistent_example.dart b/sqflite_common_ffi/example/persistent_example.dart index 65f5d602..ac2f3047 100644 --- a/sqflite_common_ffi/example/persistent_example.dart +++ b/sqflite_common_ffi/example/persistent_example.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'dart:io'; import 'package:path/path.dart'; diff --git a/sqflite_common_ffi/lib/src/database_factory_ffi_io.dart b/sqflite_common_ffi/lib/src/database_factory_ffi_io.dart index 6f398aa8..a4159abd 100644 --- a/sqflite_common_ffi/lib/src/database_factory_ffi_io.dart +++ b/sqflite_common_ffi/lib/src/database_factory_ffi_io.dart @@ -38,23 +38,26 @@ bool _debug = false; // devWarning(true); // false SqfliteIsolate? _isolate; final _isolateLock = Lock(); +// ignore: avoid_print +void _log(Object? object) => print(object); + /// Extension on MethodCall /// Handle a method call in a background isolate Future ffiMethodCallhandleInIsolate(FfiMethodCall methodCall, {SqfliteFfiInit? ffiInit}) async { try { if (_debug) { - print('main_send: $methodCall'); + _log('main_send: $methodCall'); } var result = await _isolateHandle(methodCall, ffiInit); if (_debug) { - print('main_recv: $result'); + _log('main_recv: $result'); } return result; } catch (e, st) { if (_debug) { - print(e); - print(st); + _log(e); + _log(st); } rethrow; } @@ -64,20 +67,20 @@ Future ffiMethodCallhandleInIsolate(FfiMethodCall methodCall, Future ffiMethodCallHandleNoIsolate(FfiMethodCall methodCall) async { try { if (_debug) { - print('handle $methodCall'); + _log('handle $methodCall'); } dynamic result = await methodCall.rawHandle(); if (_debug) { - print('result: $result'); + _log('result: $result'); } // devPrint('result: $result'); return result; } catch (e, st) { if (_debug) { - print(e); - print(st); + _log(e); + _log(st); } throw methodCall.wrapAnyExceptionNoIsolate(e); } diff --git a/sqflite_common_ffi/lib/src/database_tracker.dart b/sqflite_common_ffi/lib/src/database_tracker.dart index ab921d8e..9e547932 100644 --- a/sqflite_common_ffi/lib/src/database_tracker.dart +++ b/sqflite_common_ffi/lib/src/database_tracker.dart @@ -53,6 +53,7 @@ CREATE TABLE IF NOT EXISTS $_tableName ( _closeExisting(); } } catch (e) { + // ignore: avoid_print print('error $e creating tracker db'); } } @@ -88,6 +89,7 @@ CREATE TABLE IF NOT EXISTS $_tableName ( try { sqlite3.fromPointer(ptr).dispose(); } catch (e) { + // ignore: avoid_print print('error $e disposing $ptr'); } } diff --git a/sqflite_common_ffi/lib/src/isolate.dart b/sqflite_common_ffi/lib/src/isolate.dart index 8b8059ba..0161cf5d 100644 --- a/sqflite_common_ffi/lib/src/isolate.dart +++ b/sqflite_common_ffi/lib/src/isolate.dart @@ -21,6 +21,7 @@ class SqfliteIsolate { var recvPort = ReceivePort(); var map = methodCall.toDataMap(); if (_debug) { + // ignore: avoid_print print('send $map'); } map['sendPort'] = recvPort.sendPort; @@ -28,6 +29,7 @@ class SqfliteIsolate { sendPort.send(map); var response = await recvPort.first; if (_debug) { + // ignore: avoid_print print('recv $response'); } return responseToResultOrThrow(response); diff --git a/sqflite_common_ffi/lib/src/sqflite_ffi_impl.dart b/sqflite_common_ffi/lib/src/sqflite_ffi_impl.dart index e5930851..4719a98f 100644 --- a/sqflite_common_ffi/lib/src/sqflite_ffi_impl.dart +++ b/sqflite_common_ffi/lib/src/sqflite_ffi_impl.dart @@ -21,6 +21,9 @@ export 'sqflite_ffi_handler.dart' final _debug = false; // devWarning(true); // false +// ignore: avoid_print +void _log(Object? object) => print(object); + final _globalHandlerLock = Lock(); /// By id @@ -150,7 +153,7 @@ class SqfliteFfiDatabase { } var id = _ffiDb.lastInsertRowId; if (logLevel >= sqfliteLogLevelSql) { - print('$_prefix Inserted $id'); + _log('$_prefix Inserted $id'); } return id; } @@ -185,7 +188,7 @@ class SqfliteFfiDatabase { if (sql == sqflitePragmaDbDefensiveOff) { /// There is no good way to debug that but to use a print statements sometimes... if (_debug) { - print('Turning off defensive mode'); + _log('Turning off defensive mode'); } /// final int SQLITE_DBCONFIG_DEFENSIVE = 1010; @@ -212,14 +215,14 @@ class SqfliteFfiDatabase { /// Log the result if needed. void logResult({String? result}) { if (result != null && (logLevel >= sqfliteLogLevelSql)) { - print('$_prefix $result'); + _log('$_prefix $result'); } } /// Log the sql statement if needed. void logSql({required String sql, List? sqlArguments, String? result}) { if (logLevel >= sqfliteLogLevelSql) { - print( + _log( '$_prefix $sql${(sqlArguments?.isNotEmpty ?? false) ? ' $sqlArguments' : ''}'); logResult(result: result); } @@ -319,7 +322,7 @@ class SqfliteFfiDatabase { // null means no insert var id = _getLastInsertId(); if (logLevel >= sqfliteLogLevelSql) { - print('$_prefix Inserted id $id'); + _log('$_prefix Inserted id $id'); } return id; } @@ -460,7 +463,7 @@ class SqfliteFfiDatabase { int _getUpdatedRows() { var rowCount = _ffiDb.updatedRows; if (logLevel >= sqfliteLogLevelSql) { - print('$_prefix Modified $rowCount rows'); + _log('$_prefix Modified $rowCount rows'); } return rowCount; } @@ -508,7 +511,7 @@ class SqfliteFfiDatabase { void addError(dynamic e, [dynamic st]) { if (_debug && st != null) { - print('stack: $st'); + _log('stack: $st'); } SqfliteFfiException wrap(dynamic e) { return _ffiWrapAnyException(e, @@ -678,12 +681,12 @@ extension SqfliteFfiMethodCallHandler on FfiMethodCall { // devPrint('$this'); try { if (_debug) { - print('handle $this'); + _log('handle $this'); } dynamic result = await rawHandle(); if (_debug) { - print('result: $result'); + _log('result: $result'); } // devPrint('result: $result'); @@ -691,8 +694,8 @@ extension SqfliteFfiMethodCallHandler on FfiMethodCall { } catch (e, st) { // devPrint('st $st'); if (_debug) { - print('error: $e'); - print('st $st'); + _log('error: $e'); + _log('st $st'); } var ffiException = wrapAnyException(e); diff --git a/sqflite_common_ffi/lib/src/windows/setup_impl.dart b/sqflite_common_ffi/lib/src/windows/setup_impl.dart index d37200fd..1dce7486 100644 --- a/sqflite_common_ffi/lib/src/windows/setup_impl.dart +++ b/sqflite_common_ffi/lib/src/windows/setup_impl.dart @@ -10,6 +10,7 @@ Map pathGetJson(String path) { try { return (jsonDecode(content) as Map).cast(); } catch (e) { + // ignore: avoid_print print('error in $path $e'); rethrow; } diff --git a/sqflite_common_ffi/test/sqflite_factory_ffi_test.dart b/sqflite_common_ffi/test/sqflite_factory_ffi_test.dart index 6992561f..6bdc0c78 100644 --- a/sqflite_common_ffi/test/sqflite_factory_ffi_test.dart +++ b/sqflite_common_ffi/test/sqflite_factory_ffi_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library sqflite_common_ffi.test.sqflite_factory_ffi_test; diff --git a/sqflite_common_ffi/test/sqflite_ffi_api_test.dart b/sqflite_common_ffi/test/sqflite_ffi_api_test.dart index 05af66f0..f662fe88 100644 --- a/sqflite_common_ffi/test/sqflite_ffi_api_test.dart +++ b/sqflite_common_ffi/test/sqflite_ffi_api_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + @TestOn('vm') library sqflite_common_ffi.test.sqflite_ffi_doc_test; diff --git a/sqflite_common_ffi/test/sqflite_ffi_doc_test.dart b/sqflite_common_ffi/test/sqflite_ffi_doc_test.dart index 99e70e5b..99fd51fb 100644 --- a/sqflite_common_ffi/test/sqflite_ffi_doc_test.dart +++ b/sqflite_common_ffi/test/sqflite_ffi_doc_test.dart @@ -36,6 +36,7 @@ void main() { } on DatabaseException catch (e) { // no such table: Test expect(e.isNoSuchTableError('Test'), isTrue); + // ignore: avoid_print print(e.toString()); } diff --git a/sqflite_common_ffi/tool/windows_setup.dart b/sqflite_common_ffi/tool/windows_setup.dart index 0ded952e..934040b8 100644 --- a/sqflite_common_ffi/tool/windows_setup.dart +++ b/sqflite_common_ffi/tool/windows_setup.dart @@ -30,14 +30,15 @@ class Sqlite3DllSetupHelper { try { var map = pathGetJson(bundledJsonInfoFilePath); var sqlite3Info = Sqlite3DllInfo.fromMap(map); - print('sqlite3Info $sqlite3Info'); + // ignore: avoid_print + stdout.writeln('sqlite3Info $sqlite3Info'); } catch (_) {} return null; } Future getZip() async { if (!File(localZip).existsSync()) { - print('Downloading sqlite3 $sqlite3Info'); + stdout.writeln('Downloading sqlite3 $sqlite3Info'); await Directory(dirname(localZip)).create(recursive: true); try { await File(localZip).writeAsBytes(await readBytes(Uri.parse(srcZip))); @@ -54,7 +55,7 @@ class Sqlite3DllSetupHelper { var jsonInfo = File(localExtractedJsonInfoFile); if (!jsonInfo.existsSync()) { // Extract the zip - print('Extracting $localZip to $localExtractedZipDir'); + stdout.writeln('Extracting $localZip to $localExtractedZipDir'); final inputStream = InputFileStream(localZip); final archive = ZipDecoder().decodeBuffer(inputStream); await extractArchiveToDisk(archive, localExtractedZipDir); @@ -65,7 +66,7 @@ class Sqlite3DllSetupHelper { Future copyToBundle() async { var srcFile = join(localExtractedZipDir, 'sqlite3.dll'); var dstFile = bundledSqlite3DllFilePath; - print('Copying $srcZip to $dstFile'); + stdout.writeln('Copying $srcZip to $dstFile'); //await File(dstFile).delete(recursive: true); await File(srcFile).copy(dstFile); await File(bundledJsonInfoFilePath) @@ -89,7 +90,7 @@ Future setupSqliteDll() async { await helper.extractZip(); await helper.copyToBundle(); } else { - print('sqlite3 $sqlite3Info already up to date'); + stdout.writeln('sqlite3 $sqlite3Info already up to date'); } } else { stderr.writeln('To run on linux!'); diff --git a/sqflite_common_test/analysis_options.yaml b/sqflite_common_test/analysis_options.yaml index 86611e0e..64cd8e1d 100644 --- a/sqflite_common_test/analysis_options.yaml +++ b/sqflite_common_test/analysis_options.yaml @@ -28,78 +28,33 @@ linter: rules: - always_declare_return_types - avoid_dynamic_calls - - avoid_empty_else - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters + # - avoid_print - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - cancel_subscriptions - - curly_braces_in_flow_control_structures - # - depend_on_referenced_packages + - deprecated_member_use_from_same_package - directives_ordering - - empty_catches - - hash_and_equals - - collection_methods_unrelated_type + - implicit_reopen + - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types + - iterable_contains_unrelated_type + - library_names + - list_remove_unrelated_type - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names + - no_literal_bool_comparisons + - no_self_assignments - omit_local_variable_types - package_api_docs - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType + - prefer_const_constructors + - prefer_const_literals_to_create_immutables + - prefer_if_elements_to_conditional_expressions - prefer_single_quotes - - prefer_typing_uninitialized_variables + - prefer_void_to_null + # - public_member_api_docs - sort_child_properties_last - test_types_in_equals - throw_in_finally - unawaited_futures - - unnecessary_null_aware_assignments - unnecessary_statements - - unrelated_type_equality_checks - unsafe_html - use_full_hex_values_for_flutter_colors - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - # - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - dangling_library_doc_comments - - deprecated_member_use_from_same_package - - implicit_reopen - - invalid_case_patterns - - no_literal_bool_comparisons - - no_self_assignments - - no_wildcard_variable_uses - - type_literal_in_constant_pattern - # === doc rules === - - public_member_api_docs