From 6d6797343a637da315c1d8c0a95e0f915a3d3920 Mon Sep 17 00:00:00 2001 From: Gillian <72627535+buijs-dev@users.noreply.github.com> Date: Mon, 13 May 2024 14:26:39 +0200 Subject: [PATCH] Project cleanup. --- lib/src/common/project.dart | 2 +- test/src/cli/cli_test.dart | 2 +- test/src/cli/option_test.dart | 4 ++-- test/src/cli/task_project_clean_cache_test.dart | 4 ++-- test/src/cli/task_service_test.dart | 6 +++--- test/src/cli/task_test.dart | 6 +++--- test/src/common/exception_test.dart | 2 +- test/src/systemtest/e2e_test.dart | 1 + 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/src/common/project.dart b/lib/src/common/project.dart index 240dbf5..b271a9e 100644 --- a/lib/src/common/project.dart +++ b/lib/src/common/project.dart @@ -229,7 +229,7 @@ extension on File { final endIndex = content.indexOf("pluginClass:"); if (startIndex == -1 || endIndex == -1) { - throw KlutterException( + throw const KlutterException( "Failed to find tag plugin:platforms:android:package in pubspec.yaml", ); } diff --git a/test/src/cli/cli_test.dart b/test/src/cli/cli_test.dart index 7422369..e713703 100644 --- a/test/src/cli/cli_test.dart +++ b/test/src/cli/cli_test.dart @@ -32,7 +32,7 @@ void main() { }); test("Execute task using main execute entrypoint", () async { - final task = TaskName.gradle; + const task = TaskName.gradle; final context = Context(Directory.systemTemp, {}); final result = await execute(task, context); expect(result.contains("Received invalid command"), true); diff --git a/test/src/cli/option_test.dart b/test/src/cli/option_test.dart index 1436fe1..dda7d8f 100644 --- a/test/src/cli/option_test.dart +++ b/test/src/cli/option_test.dart @@ -23,7 +23,7 @@ import "package:test/test.dart"; void main() { test("Verify InputException toString", () { - expect(InputException("splash!").toString(), + expect(const InputException("splash!").toString(), "InputException with cause: 'splash!'"); }); @@ -77,7 +77,7 @@ void main() { }); group("GroupNameOption throws exception if input is not a bool", () { - final option = GroupNameOption(); + const option = GroupNameOption(); void testThrowing(String groupName, String message) { test("$groupName throws $message", () { expect( diff --git a/test/src/cli/task_project_clean_cache_test.dart b/test/src/cli/task_project_clean_cache_test.dart index 3e2f9f6..bea6620 100644 --- a/test/src/cli/task_project_clean_cache_test.dart +++ b/test/src/cli/task_project_clean_cache_test.dart @@ -128,12 +128,12 @@ class DirectoryStub implements Directory { @override Future delete({bool recursive = false}) { - throw KlutterException("BOOM!"); + throw const KlutterException("BOOM!"); } @override void deleteSync({bool recursive = false}) { - throw KlutterException("BOOM!"); + throw const KlutterException("BOOM!"); } @override diff --git a/test/src/cli/task_service_test.dart b/test/src/cli/task_service_test.dart index 45ba0d6..669bc79 100644 --- a/test/src/cli/task_service_test.dart +++ b/test/src/cli/task_service_test.dart @@ -39,12 +39,12 @@ void main() { expect( tasks.getTask(TaskName.add).toString(), "add\n lib (Required) name of the library to add.\n" - " root (Optional) klutter project root directory. Defaults to \'current working directory\'.\n", + " root (Optional) klutter project root directory. Defaults to 'current working directory'.\n", ); expect( tasks.getTask(TaskName.init).toString(), - "init\n bom (Optional) klutter gradle version. Defaults to '2024.1.1.beta'.\n flutter (Optional) flutter sdk version in format major.minor.patch. Defaults to '3.10.6'.\n root (Optional) klutter project root directory. Defaults to \'current working directory\'.\n ios (Optional) ios version. Defaults to \'13.0\'.\n", + "init\n bom (Optional) klutter gradle version. Defaults to '2024.1.1.beta'.\n flutter (Optional) flutter sdk version in format major.minor.patch. Defaults to '3.10.6'.\n root (Optional) klutter project root directory. Defaults to 'current working directory'.\n ios (Optional) ios version. Defaults to '13.0'.\n", ); }); @@ -78,7 +78,7 @@ void main() { " bom (Optional) klutter gradle version. Defaults to '2024.1.1.beta'.\n" " flutter (Optional) flutter sdk version in format major.minor.patch. Defaults to '3.10.6'.\n" " root (Optional) klutter project root directory. Defaults to 'current working directory'.\n" - " ios (Optional) ios version. Defaults to \'13.0\'.\n" + " ios (Optional) ios version. Defaults to '13.0'.\n" "\n" "get\n" " flutter (Optional) flutter sdk version in format major.minor.patch. Defaults to '3.10.6'.\n" diff --git a/test/src/cli/task_test.dart b/test/src/cli/task_test.dart index e5d22f5..8804180 100644 --- a/test/src/cli/task_test.dart +++ b/test/src/cli/task_test.dart @@ -36,7 +36,7 @@ void main() { final result = await _InvalidTask().execute(Context(Directory.systemTemp, {})); expect(result.isOk, false); - expect(result.message, "unsupported value: Instance of \'FakeInput\'"); + expect(result.message, "unsupported value: Instance of 'FakeInput'"); }); test("An exception is thrown when unsupported options are present", () async { @@ -48,9 +48,9 @@ void main() { }); test("Verify toTaskOptionOrNull for valid options", () async { - TaskOption.values.forEach((value) { + for (final value in TaskOption.values) { expect(value.name.toTaskOptionOrNull, value, reason: "roundtrip $value"); - }); + } }); } diff --git a/test/src/common/exception_test.dart b/test/src/common/exception_test.dart index ddf6605..a9874ea 100644 --- a/test/src/common/exception_test.dart +++ b/test/src/common/exception_test.dart @@ -24,7 +24,7 @@ import "package:test/test.dart"; void main() { test("Verify exception toString returns a readable message", () { expect( - () => throw KlutterException("BOOM!"), + () => throw const KlutterException("BOOM!"), throwsA(predicate((e) => e is KlutterException && e.toString() == "KlutterException with cause: 'BOOM!'"))); diff --git a/test/src/systemtest/e2e_test.dart b/test/src/systemtest/e2e_test.dart index a8c5411..ac8e7b8 100644 --- a/test/src/systemtest/e2e_test.dart +++ b/test/src/systemtest/e2e_test.dart @@ -238,6 +238,7 @@ void main() { } }); } catch (e, s) { + // ignore: avoid_print print(s); }