From edc76a1c480bf03b686fee538e0ccde904a3f370 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Tue, 15 Aug 2023 04:58:16 -0500 Subject: [PATCH] Cleanup meta annotation usage (#3990) --- analysis_options.yaml | 1 + lib/src/executable.dart | 7 ++----- lib/src/ignore.dart | 5 +---- lib/src/pub_embeddable_command.dart | 4 +--- lib/src/third_party/tar/lib/src/charcodes.dart | 2 ++ lib/src/third_party/tar/lib/src/utils.dart | 2 ++ lib/src/validator/leak_detection.dart | 9 +++------ test/get/git/git_not_installed_test.dart | 2 ++ test/get/path/relative_symlink_test.dart | 2 ++ test/global/activate/feature_test.dart | 1 + test/run/forwards_signal_posix_test.dart | 2 ++ test/validator/file_case_test.dart | 1 + 12 files changed, 20 insertions(+), 18 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 66e368ef2..f0bd15af3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -25,6 +25,7 @@ linter: - cancel_subscriptions - dangling_library_doc_comments - directives_ordering + - library_annotations - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString diff --git a/lib/src/executable.dart b/lib/src/executable.dart index b54397f19..ea5820567 100644 --- a/lib/src/executable.dart +++ b/lib/src/executable.dart @@ -7,7 +7,6 @@ import 'dart:io'; import 'dart:isolate'; import 'package:args/args.dart'; -import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; import 'entrypoint.dart'; @@ -208,8 +207,7 @@ Future _runDartProgram( } /// The result of a `getExecutableForCommand` command resolution. -@sealed -class DartExecutableWithPackageConfig { +final class DartExecutableWithPackageConfig { /// Can be a .dart file or a incremental snapshot. final String executable; @@ -414,8 +412,7 @@ enum CommandResolutionIssue { } /// Indicates that a command string did not resolve to an executable. -@sealed -class CommandResolutionFailedException implements Exception { +final class CommandResolutionFailedException implements Exception { final String message; final CommandResolutionIssue issue; CommandResolutionFailedException._(this.message, this.issue); diff --git a/lib/src/ignore.dart b/lib/src/ignore.dart index 726814f56..2633521f1 100644 --- a/lib/src/ignore.dart +++ b/lib/src/ignore.dart @@ -27,8 +27,6 @@ /// [1]: https://git-scm.com/docs/gitignore library; -import 'package:meta/meta.dart'; - /// A set of ignore rules representing a single ignore file. /// /// An [Ignore] instance holds [`.gitignore` rules][1] relative to a given path. @@ -48,8 +46,7 @@ import 'package:meta/meta.dart'; /// ``` /// /// [1]: https://git-scm.com/docs/gitignore -@sealed -class Ignore { +final class Ignore { final List<_IgnoreRule> _rules; /// Create an [Ignore] instance with a set of [`.gitignore` compatible][1] diff --git a/lib/src/pub_embeddable_command.dart b/lib/src/pub_embeddable_command.dart index b12b70db9..32ff21e2c 100644 --- a/lib/src/pub_embeddable_command.dart +++ b/lib/src/pub_embeddable_command.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart'; import 'package:usage/usage.dart'; import 'command.dart' show PubCommand, PubTopLevel; @@ -27,8 +26,7 @@ import 'log.dart'; import 'utils.dart'; /// The information needed for the embedded pub command to send analytics. -@sealed -class PubAnalytics { +final class PubAnalytics { /// Name of the custom dimension of the dependency kind. final String dependencyKindCustomDimensionName; diff --git a/lib/src/third_party/tar/lib/src/charcodes.dart b/lib/src/third_party/tar/lib/src/charcodes.dart index de0762fbf..b25bb369a 100644 --- a/lib/src/third_party/tar/lib/src/charcodes.dart +++ b/lib/src/third_party/tar/lib/src/charcodes.dart @@ -1,4 +1,6 @@ @internal +library; + import 'package:meta/meta.dart'; /// "Line feed" control character. diff --git a/lib/src/third_party/tar/lib/src/utils.dart b/lib/src/third_party/tar/lib/src/utils.dart index 1ea5506bd..1c42cc6e2 100644 --- a/lib/src/third_party/tar/lib/src/utils.dart +++ b/lib/src/third_party/tar/lib/src/utils.dart @@ -1,4 +1,6 @@ @internal +library; + import 'dart:async'; import 'dart:convert'; import 'dart:math'; diff --git a/lib/src/validator/leak_detection.dart b/lib/src/validator/leak_detection.dart index 69a905441..6e128f8c6 100644 --- a/lib/src/validator/leak_detection.dart +++ b/lib/src/validator/leak_detection.dart @@ -23,8 +23,7 @@ const _falseSecretsDocumentationLink = 'https://dart.dev/go/false-secrets'; /// A validator that validates attempts to find secrets that are about to be /// accidentally leaked. -@sealed -class LeakDetectionValidator extends Validator { +final class LeakDetectionValidator extends Validator { @override Future validate() async { // Load `false_secrets` from `pubspec.yaml`. @@ -105,8 +104,7 @@ class LeakDetectionValidator extends Validator { } /// Instance of a match against a [LeakPattern]. -@sealed -class LeakMatch { +final class LeakMatch { final LeakPattern pattern; final SourceSpan span; @@ -119,8 +117,7 @@ class LeakMatch { /// Definition of a pattern for detecting accidentally leaked secrets. @visibleForTesting -@sealed -class LeakPattern { +final class LeakPattern { /// Human readable name for the kind of secret this pattern matches. final String kind; diff --git a/test/get/git/git_not_installed_test.dart b/test/get/git/git_not_installed_test.dart index a6eed84b0..479f6eb4a 100644 --- a/test/get/git/git_not_installed_test.dart +++ b/test/get/git/git_not_installed_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('linux') +library; + import 'dart:io'; import 'package:test/test.dart'; diff --git a/test/get/path/relative_symlink_test.dart b/test/get/path/relative_symlink_test.dart index 1266bfff1..126dd5c98 100644 --- a/test/get/path/relative_symlink_test.dart +++ b/test/get/path/relative_symlink_test.dart @@ -7,6 +7,8 @@ // support relative paths. So this test, by design, will not pass on Windows. // So just skip it. @TestOn('!windows') +library; + import 'package:path/path.dart' as path; import 'package:test/test.dart'; diff --git a/test/global/activate/feature_test.dart b/test/global/activate/feature_test.dart index 6f54ca3db..4063ae676 100644 --- a/test/global/activate/feature_test.dart +++ b/test/global/activate/feature_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @Skip() +library; import 'package:test/test.dart'; diff --git a/test/run/forwards_signal_posix_test.dart b/test/run/forwards_signal_posix_test.dart index 3a1299f78..cfb18da45 100644 --- a/test/run/forwards_signal_posix_test.dart +++ b/test/run/forwards_signal_posix_test.dart @@ -8,6 +8,8 @@ // in `pub run`. Now signals only work as expected when sent to the process // group. And this seems hard to emulate in a test. @TestOn('!windows') +library; + import 'dart:io'; import 'package:test/test.dart'; diff --git a/test/validator/file_case_test.dart b/test/validator/file_case_test.dart index b2c0464d5..37b279ff2 100644 --- a/test/validator/file_case_test.dart +++ b/test/validator/file_case_test.dart @@ -7,6 +7,7 @@ 'windows': Skip('Windows file system is case-insensitive'), 'mac-os': Skip('MacOS file system is case-insensitive'), }) +library; import 'package:pub/src/exit_codes.dart'; import 'package:test/test.dart';