diff --git a/.github/workflows/code_check.yaml b/.github/workflows/code_check.yaml index fcb5809..350e3df 100644 --- a/.github/workflows/code_check.yaml +++ b/.github/workflows/code_check.yaml @@ -23,24 +23,9 @@ jobs: - name: Get dependencies run: flutter pub get - - name: Setup Dart Code Metrics - run: dart pub get dart_code_metrics - - - name: Run Dart Code Metrics - run: | - dirs_to_analyze="" - if [ -d lib ]; then dirs_to_analyze+=" lib"; fi - if [ -d test ]; then dirs_to_analyze+=" test"; fi - if [ -d example ]; then dirs_to_analyze+=" example"; fi - if [ dirs_to_analyze != "" ] - then - dart run dart_code_metrics:metrics \ - analyze \ - $dirs_to_analyze \ - --fatal-warnings \ - --fatal-performance \ - --fatal-style - fi + - name: Custom lint + run: dart run custom_lint + - name: Check formatting run: dart format . --set-exit-if-changed diff --git a/example/lib/main.dart b/example/lib/main.dart index 0f8e3d7..da7d074 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,7 +10,7 @@ void main() { } /// Example App main page -// ignore: prefer-match-file-name +// ignore: prefer_match_file_name class App extends StatefulWidget { /// Example app constructor const App({super.key}); diff --git a/lib/languagetool_textfield.dart b/lib/languagetool_textfield.dart index 780083a..6379dc5 100644 --- a/lib/languagetool_textfield.dart +++ b/lib/languagetool_textfield.dart @@ -1,20 +1,20 @@ library languagetool_textfield; -export 'client/language_tool_client.dart'; -export 'core/controllers/language_tool_controller.dart'; -export 'core/enums/delay_type.dart'; -export 'core/model/category.dart'; -export 'core/model/language_tool_raw.dart'; -export 'core/model/match.dart'; -export 'core/model/replacement.dart'; -export 'core/model/rule.dart'; -export 'domain/highlight_style.dart'; -export 'domain/language_check_service.dart'; -export 'domain/mistake.dart'; -export 'domain/writing_mistake.dart'; -export 'implementations/debounce_lang_tool_service.dart'; -export 'implementations/lang_tool_service.dart'; -export 'implementations/throttling_lang_tool_service.dart'; -export 'presentation/language_tool_text_field.dart'; -export 'utils/mistake_popup.dart'; -export 'utils/popup_overlay_renderer.dart'; +export 'src/client/language_tool_client.dart'; +export 'src/core/controllers/language_tool_controller.dart'; +export 'src/core/enums/delay_type.dart'; +export 'src/core/model/category.dart'; +export 'src/core/model/language_tool_raw.dart'; +export 'src/core/model/match.dart'; +export 'src/core/model/replacement.dart'; +export 'src/core/model/rule.dart'; +export 'src/domain/highlight_style.dart'; +export 'src/domain/language_check_service.dart'; +export 'src/domain/mistake.dart'; +export 'src/domain/writing_mistake.dart'; +export 'src/implementations/debounce_lang_tool_service.dart'; +export 'src/implementations/lang_tool_service.dart'; +export 'src/implementations/throttling_lang_tool_service.dart'; +export 'src/presentation/language_tool_text_field.dart'; +export 'src/utils/mistake_popup.dart'; +export 'src/utils/popup_overlay_renderer.dart'; diff --git a/lib/client/language_tool_client.dart b/lib/src/client/language_tool_client.dart similarity index 92% rename from lib/client/language_tool_client.dart rename to lib/src/client/language_tool_client.dart index 48e70a9..af62e3a 100644 --- a/lib/client/language_tool_client.dart +++ b/lib/src/client/language_tool_client.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'package:http/http.dart' as http; -import 'package:languagetool_textfield/core/model/language_tool_raw.dart'; -import 'package:languagetool_textfield/domain/writing_mistake.dart'; +import 'package:languagetool_textfield/src/core/model/language_tool_raw.dart'; +import 'package:languagetool_textfield/src/domain/writing_mistake.dart'; /// Class to interact with the LanguageTool API. /// diff --git a/lib/core/controllers/language_tool_controller.dart b/lib/src/core/controllers/language_tool_controller.dart similarity index 93% rename from lib/core/controllers/language_tool_controller.dart rename to lib/src/core/controllers/language_tool_controller.dart index cd1bb8d..1aa9bed 100644 --- a/lib/core/controllers/language_tool_controller.dart +++ b/lib/src/core/controllers/language_tool_controller.dart @@ -3,18 +3,18 @@ import 'dart:math'; import 'package:collection/collection.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:languagetool_textfield/client/language_tool_client.dart'; -import 'package:languagetool_textfield/core/enums/delay_type.dart'; -import 'package:languagetool_textfield/core/enums/mistake_type.dart'; -import 'package:languagetool_textfield/domain/highlight_style.dart'; -import 'package:languagetool_textfield/domain/language_check_service.dart'; -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/implementations/debounce_lang_tool_service.dart'; -import 'package:languagetool_textfield/implementations/lang_tool_service.dart'; -import 'package:languagetool_textfield/implementations/throttling_lang_tool_service.dart'; -import 'package:languagetool_textfield/utils/closed_range.dart'; -import 'package:languagetool_textfield/utils/keep_latest_response_service.dart'; -import 'package:languagetool_textfield/utils/mistake_popup.dart'; +import 'package:languagetool_textfield/src/client/language_tool_client.dart'; +import 'package:languagetool_textfield/src/core/enums/delay_type.dart'; +import 'package:languagetool_textfield/src/core/enums/mistake_type.dart'; +import 'package:languagetool_textfield/src/domain/highlight_style.dart'; +import 'package:languagetool_textfield/src/domain/language_check_service.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/implementations/debounce_lang_tool_service.dart'; +import 'package:languagetool_textfield/src/implementations/lang_tool_service.dart'; +import 'package:languagetool_textfield/src/implementations/throttling_lang_tool_service.dart'; +import 'package:languagetool_textfield/src/utils/closed_range.dart'; +import 'package:languagetool_textfield/src/utils/keep_latest_response_service.dart'; +import 'package:languagetool_textfield/src/utils/mistake_popup.dart'; /// A TextEditingController with overrides buildTextSpan for building /// marked TextSpans with tap recognizer diff --git a/lib/core/enums/delay_type.dart b/lib/src/core/enums/delay_type.dart similarity index 100% rename from lib/core/enums/delay_type.dart rename to lib/src/core/enums/delay_type.dart diff --git a/lib/core/enums/mistake_type.dart b/lib/src/core/enums/mistake_type.dart similarity index 100% rename from lib/core/enums/mistake_type.dart rename to lib/src/core/enums/mistake_type.dart diff --git a/lib/core/langtool_images.dart b/lib/src/core/langtool_images.dart similarity index 100% rename from lib/core/langtool_images.dart rename to lib/src/core/langtool_images.dart diff --git a/lib/core/model/category.dart b/lib/src/core/model/category.dart similarity index 100% rename from lib/core/model/category.dart rename to lib/src/core/model/category.dart diff --git a/lib/core/model/language_tool_raw.dart b/lib/src/core/model/language_tool_raw.dart similarity index 100% rename from lib/core/model/language_tool_raw.dart rename to lib/src/core/model/language_tool_raw.dart diff --git a/lib/core/model/match.dart b/lib/src/core/model/match.dart similarity index 92% rename from lib/core/model/match.dart rename to lib/src/core/model/match.dart index 5af21bf..1b905f3 100644 --- a/lib/core/model/match.dart +++ b/lib/src/core/model/match.dart @@ -1,5 +1,5 @@ -import 'package:languagetool_textfield/core/model/replacement.dart'; -import 'package:languagetool_textfield/core/model/rule.dart'; +import 'package:languagetool_textfield/src/core/model/replacement.dart'; +import 'package:languagetool_textfield/src/core/model/rule.dart'; /// Object that stores information about matched mistakes. class Match { diff --git a/lib/core/model/replacement.dart b/lib/src/core/model/replacement.dart similarity index 100% rename from lib/core/model/replacement.dart rename to lib/src/core/model/replacement.dart diff --git a/lib/core/model/rule.dart b/lib/src/core/model/rule.dart similarity index 88% rename from lib/core/model/rule.dart rename to lib/src/core/model/rule.dart index 7a4bdd5..785b5d9 100644 --- a/lib/core/model/rule.dart +++ b/lib/src/core/model/rule.dart @@ -1,5 +1,5 @@ -import 'package:languagetool_textfield/core/enums/mistake_type.dart'; -import 'package:languagetool_textfield/core/model/category.dart'; +import 'package:languagetool_textfield/src/core/enums/mistake_type.dart'; +import 'package:languagetool_textfield/src/core/model/category.dart'; /// Object that stores information about the rule (description, type, etc). class Rule { diff --git a/lib/domain/highlight_style.dart b/lib/src/domain/highlight_style.dart similarity index 100% rename from lib/domain/highlight_style.dart rename to lib/src/domain/highlight_style.dart diff --git a/lib/domain/language_check_service.dart b/lib/src/domain/language_check_service.dart similarity index 78% rename from lib/domain/language_check_service.dart rename to lib/src/domain/language_check_service.dart index 2cac080..6bb796c 100644 --- a/lib/domain/language_check_service.dart +++ b/lib/src/domain/language_check_service.dart @@ -1,5 +1,5 @@ -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/utils/result.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/utils/result.dart'; /// A base language check service. abstract class LanguageCheckService { diff --git a/lib/domain/mistake.dart b/lib/src/domain/mistake.dart similarity index 94% rename from lib/domain/mistake.dart rename to lib/src/domain/mistake.dart index 7719e03..d54746f 100644 --- a/lib/domain/mistake.dart +++ b/lib/src/domain/mistake.dart @@ -1,4 +1,4 @@ -import 'package:languagetool_textfield/core/enums/mistake_type.dart'; +import 'package:languagetool_textfield/src/core/enums/mistake_type.dart'; /// A data model class that stores information about a single writing mistake. class Mistake { diff --git a/lib/domain/typedefs.dart b/lib/src/domain/typedefs.dart similarity index 67% rename from lib/domain/typedefs.dart rename to lib/src/domain/typedefs.dart index 598bbdd..de210f9 100644 --- a/lib/domain/typedefs.dart +++ b/lib/src/domain/typedefs.dart @@ -1,7 +1,7 @@ import 'package:flutter/widgets.dart'; -import 'package:languagetool_textfield/core/controllers/language_tool_controller.dart'; -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/utils/popup_overlay_renderer.dart'; +import 'package:languagetool_textfield/src/core/controllers/language_tool_controller.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/utils/popup_overlay_renderer.dart'; /// Callback used to build popup body typedef MistakeBuilderCallback = Widget Function({ diff --git a/lib/domain/writing_mistake.dart b/lib/src/domain/writing_mistake.dart similarity index 92% rename from lib/domain/writing_mistake.dart rename to lib/src/domain/writing_mistake.dart index fd55829..e9aaf67 100644 --- a/lib/domain/writing_mistake.dart +++ b/lib/src/domain/writing_mistake.dart @@ -1,4 +1,4 @@ -import 'package:languagetool_textfield/core/enums/mistake_type.dart'; +import 'package:languagetool_textfield/src/core/enums/mistake_type.dart'; /// Object that stores information about a single writing mistake. class WritingMistake { diff --git a/lib/implementations/debounce_lang_tool_service.dart b/lib/src/implementations/debounce_lang_tool_service.dart similarity index 77% rename from lib/implementations/debounce_lang_tool_service.dart rename to lib/src/implementations/debounce_lang_tool_service.dart index ec03d37..e7fc013 100644 --- a/lib/implementations/debounce_lang_tool_service.dart +++ b/lib/src/implementations/debounce_lang_tool_service.dart @@ -1,6 +1,6 @@ -import 'package:languagetool_textfield/domain/language_check_service.dart'; -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/utils/result.dart'; +import 'package:languagetool_textfield/src/domain/language_check_service.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/utils/result.dart'; import 'package:throttling/throttling.dart'; /// A language check service with debouncing. @@ -21,6 +21,7 @@ class DebounceLangToolService extends LanguageCheckService { Future>?> findMistakes(String text) async => await debouncing.debounce(() => baseService.findMistakes(text)); + // ignore: proper_super_calls @override Future dispose() async { debouncing.close(); diff --git a/lib/implementations/lang_tool_service.dart b/lib/src/implementations/lang_tool_service.dart similarity index 74% rename from lib/implementations/lang_tool_service.dart rename to lib/src/implementations/lang_tool_service.dart index c71ce6a..9cd9e9c 100644 --- a/lib/implementations/lang_tool_service.dart +++ b/lib/src/implementations/lang_tool_service.dart @@ -1,8 +1,8 @@ -import 'package:languagetool_textfield/client/language_tool_client.dart'; -import 'package:languagetool_textfield/domain/language_check_service.dart'; -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/domain/writing_mistake.dart'; -import 'package:languagetool_textfield/utils/result.dart'; +import 'package:languagetool_textfield/src/client/language_tool_client.dart'; +import 'package:languagetool_textfield/src/domain/language_check_service.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/domain/writing_mistake.dart'; +import 'package:languagetool_textfield/src/utils/result.dart'; /// An implementation of language check service with language tool service. class LangToolService extends LanguageCheckService { diff --git a/lib/implementations/throttling_lang_tool_service.dart b/lib/src/implementations/throttling_lang_tool_service.dart similarity index 78% rename from lib/implementations/throttling_lang_tool_service.dart rename to lib/src/implementations/throttling_lang_tool_service.dart index 5b851d0..dfa6868 100644 --- a/lib/implementations/throttling_lang_tool_service.dart +++ b/lib/src/implementations/throttling_lang_tool_service.dart @@ -1,6 +1,6 @@ -import 'package:languagetool_textfield/domain/language_check_service.dart'; -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/utils/result.dart'; +import 'package:languagetool_textfield/src/domain/language_check_service.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/utils/result.dart'; import 'package:throttling/throttling.dart'; /// A language check service with debouncing. @@ -22,6 +22,7 @@ class ThrottlingLangToolService extends LanguageCheckService { Future>?> findMistakes(String text) async => throttling.throttle(() => baseService.findMistakes(text)); + // ignore: proper_super_calls @override Future dispose() async { throttling.close(); diff --git a/lib/presentation/language_tool_text_field.dart b/lib/src/presentation/language_tool_text_field.dart similarity index 93% rename from lib/presentation/language_tool_text_field.dart rename to lib/src/presentation/language_tool_text_field.dart index 78c7b27..9fce27b 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/src/presentation/language_tool_text_field.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:languagetool_textfield/core/controllers/language_tool_controller.dart'; -import 'package:languagetool_textfield/utils/mistake_popup.dart'; -import 'package:languagetool_textfield/utils/popup_overlay_renderer.dart'; +import 'package:languagetool_textfield/src/core/controllers/language_tool_controller.dart'; +import 'package:languagetool_textfield/src/utils/mistake_popup.dart'; +import 'package:languagetool_textfield/src/utils/popup_overlay_renderer.dart'; /// A TextField widget that checks the grammar using the given /// [LanguageToolController] diff --git a/lib/utils/closed_range.dart b/lib/src/utils/closed_range.dart similarity index 100% rename from lib/utils/closed_range.dart rename to lib/src/utils/closed_range.dart diff --git a/lib/utils/extensions/string_extension.dart b/lib/src/utils/extensions/string_extension.dart similarity index 100% rename from lib/utils/extensions/string_extension.dart rename to lib/src/utils/extensions/string_extension.dart diff --git a/lib/utils/keep_latest_response_service.dart b/lib/src/utils/keep_latest_response_service.dart similarity index 100% rename from lib/utils/keep_latest_response_service.dart rename to lib/src/utils/keep_latest_response_service.dart diff --git a/lib/utils/mistake_popup.dart b/lib/src/utils/mistake_popup.dart similarity index 95% rename from lib/utils/mistake_popup.dart rename to lib/src/utils/mistake_popup.dart index f36a074..fff7e3c 100644 --- a/lib/utils/mistake_popup.dart +++ b/lib/src/utils/mistake_popup.dart @@ -2,12 +2,12 @@ import 'dart:math'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:languagetool_textfield/core/controllers/language_tool_controller.dart'; -import 'package:languagetool_textfield/core/langtool_images.dart'; -import 'package:languagetool_textfield/domain/mistake.dart'; -import 'package:languagetool_textfield/domain/typedefs.dart'; -import 'package:languagetool_textfield/utils/extensions/string_extension.dart'; -import 'package:languagetool_textfield/utils/popup_overlay_renderer.dart'; +import 'package:languagetool_textfield/src/core/controllers/language_tool_controller.dart'; +import 'package:languagetool_textfield/src/core/langtool_images.dart'; +import 'package:languagetool_textfield/src/domain/mistake.dart'; +import 'package:languagetool_textfield/src/domain/typedefs.dart'; +import 'package:languagetool_textfield/src/utils/extensions/string_extension.dart'; +import 'package:languagetool_textfield/src/utils/popup_overlay_renderer.dart'; /// Builder class that uses specified [popupRenderer] and [mistakeBuilder] /// to create mistake popup diff --git a/lib/utils/popup_overlay_renderer.dart b/lib/src/utils/popup_overlay_renderer.dart similarity index 100% rename from lib/utils/popup_overlay_renderer.dart rename to lib/src/utils/popup_overlay_renderer.dart diff --git a/lib/utils/result.dart b/lib/src/utils/result.dart similarity index 100% rename from lib/utils/result.dart rename to lib/src/utils/result.dart diff --git a/pubspec.yaml b/pubspec.yaml index ed96e8a..d42d62d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - solid_lints: ^0.0.14 + solid_lints: ^0.1.2 flutter: uses-material-design: true