From f87d414e53f2e878f3fd2c0f0237cebdaaa46f80 Mon Sep 17 00:00:00 2001 From: Kevin Moore <kevmoo@users.noreply.github.com> Date: Tue, 29 Jan 2019 16:39:13 -0800 Subject: [PATCH] Fix analysis with latest SDK analyzer (#979) --- pkgs/test_api/analysis_options.yaml | 5 +-- .../lib/src/frontend/async_matcher.dart | 1 - pkgs/test_api/lib/src/frontend/expect.dart | 10 +---- .../lib/src/frontend/throws_matcher.dart | 5 +-- .../lib/src/frontend/throws_matchers.dart | 38 +++++-------------- .../test/frontend/expect_async_test.dart | 3 -- pkgs/test_api/test/frontend/expect_test.dart | 2 - .../test/frontend/matcher/throws_test.dart | 8 ---- 8 files changed, 13 insertions(+), 59 deletions(-) diff --git a/pkgs/test_api/analysis_options.yaml b/pkgs/test_api/analysis_options.yaml index 4d7594a9..e1653118 100644 --- a/pkgs/test_api/analysis_options.yaml +++ b/pkgs/test_api/analysis_options.yaml @@ -10,9 +10,8 @@ analyzer: unused_import: error unused_local_variable: error dead_code: error - ### Useful to uncomment during development to remove the noise of the many - ### deprecated APIs. - # deprecated_member_use: ignore + # There are a number of deprecated members used through this package + deprecated_member_use_from_same_package: ignore linter: rules: - await_only_futures diff --git a/pkgs/test_api/lib/src/frontend/async_matcher.dart b/pkgs/test_api/lib/src/frontend/async_matcher.dart index f88852a1..e2c544ef 100644 --- a/pkgs/test_api/lib/src/frontend/async_matcher.dart +++ b/pkgs/test_api/lib/src/frontend/async_matcher.dart @@ -39,7 +39,6 @@ abstract class AsyncMatcher extends Matcher { Invoker.current.addOutstandingCallback(); result.then((realResult) { if (realResult != null) { - // ignore: deprecated_member_use fail(formatFailure(this, item, realResult as String)); } Invoker.current.removeOutstandingCallback(); diff --git a/pkgs/test_api/lib/src/frontend/expect.dart b/pkgs/test_api/lib/src/frontend/expect.dart index 4937647e..985c6054 100644 --- a/pkgs/test_api/lib/src/frontend/expect.dart +++ b/pkgs/test_api/lib/src/frontend/expect.dart @@ -55,7 +55,6 @@ void expect(actual, matcher, {String reason, skip, @Deprecated("Will be removed in 0.13.0.") bool verbose = false, - // ignore: deprecated_member_use @Deprecated("Will be removed in 0.13.0.") ErrorFormatter formatter}) { _expect(actual, matcher, reason: reason, skip: skip, verbose: verbose, formatter: formatter); @@ -77,16 +76,11 @@ Future expectLater(actual, matcher, {String reason, skip}) => /// The implementation of [expect] and [expectLater]. Future _expect(actual, matcher, - {String reason, - skip, - bool verbose = false, - // ignore: deprecated_member_use - ErrorFormatter formatter}) { + {String reason, skip, bool verbose = false, ErrorFormatter formatter}) { formatter ??= (actual, matcher, reason, matchState, verbose) { var mismatchDescription = StringDescription(); matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); - // ignore: deprecated_member_use return formatFailure(matcher, actual, mismatchDescription.toString(), reason: reason); }; @@ -125,13 +119,11 @@ Future _expect(actual, matcher, reason: "matchAsync() may only return a String, a Future, or null."); if (result is String) { - // ignore: deprecated_member_use fail(formatFailure(matcher as Matcher, actual, result, reason: reason)); } else if (result is Future) { Invoker.current.addOutstandingCallback(); return result.then((realResult) { if (realResult == null) return; - // ignore: deprecated_member_use fail(formatFailure(matcher as Matcher, actual, realResult as String, reason: reason)); }).whenComplete(() { diff --git a/pkgs/test_api/lib/src/frontend/throws_matcher.dart b/pkgs/test_api/lib/src/frontend/throws_matcher.dart index ac4c9462..c6e34d77 100644 --- a/pkgs/test_api/lib/src/frontend/throws_matcher.dart +++ b/pkgs/test_api/lib/src/frontend/throws_matcher.dart @@ -16,7 +16,6 @@ import 'format_stack_trace.dart'; /// at least the type of the error, but you can write `throwsA(anything)` to /// mimic the behavior of this matcher. @Deprecated("Will be removed in 0.13.0") -// ignore: deprecated_member_use const Matcher throws = Throws(); /// This can be used to match three kinds of objects: @@ -36,9 +35,7 @@ const Matcher throws = Throws(); /// In all three cases, when an exception is thrown, this will test that the /// exception object matches [matcher]. If [matcher] is not an instance of /// [Matcher], it will implicitly be treated as `equals(matcher)`. -Matcher throwsA(matcher) => - // ignore: deprecated_member_use - Throws(wrapMatcher(matcher)); +Matcher throwsA(matcher) => Throws(wrapMatcher(matcher)); /// Use the [throwsA] function instead. @Deprecated("Will be removed in 0.13.0") diff --git a/pkgs/test_api/lib/src/frontend/throws_matchers.dart b/pkgs/test_api/lib/src/frontend/throws_matchers.dart index 1745a3c1..7a922127 100644 --- a/pkgs/test_api/lib/src/frontend/throws_matchers.dart +++ b/pkgs/test_api/lib/src/frontend/throws_matchers.dart @@ -7,56 +7,36 @@ import 'package:matcher/matcher.dart'; import 'throws_matcher.dart'; /// A matcher for functions that throw ArgumentError. -const Matcher throwsArgumentError = - // ignore: deprecated_member_use - Throws(isArgumentError); +const Matcher throwsArgumentError = Throws(isArgumentError); /// A matcher for functions that throw ConcurrentModificationError. const Matcher throwsConcurrentModificationError = - // ignore: deprecated_member_use Throws(isConcurrentModificationError); /// A matcher for functions that throw CyclicInitializationError. const Matcher throwsCyclicInitializationError = - // ignore: deprecated_member_use Throws(isCyclicInitializationError); /// A matcher for functions that throw Exception. -const Matcher throwsException = - // ignore: deprecated_member_use - Throws(isException); +const Matcher throwsException = Throws(isException); /// A matcher for functions that throw FormatException. -const Matcher throwsFormatException = - // ignore: deprecated_member_use - Throws(isFormatException); +const Matcher throwsFormatException = Throws(isFormatException); /// A matcher for functions that throw NoSuchMethodError. -const Matcher throwsNoSuchMethodError = - // ignore: deprecated_member_use - Throws(isNoSuchMethodError); +const Matcher throwsNoSuchMethodError = Throws(isNoSuchMethodError); /// A matcher for functions that throw NullThrownError. -const Matcher throwsNullThrownError = - // ignore: deprecated_member_use - Throws(isNullThrownError); +const Matcher throwsNullThrownError = Throws(isNullThrownError); /// A matcher for functions that throw RangeError. -const Matcher throwsRangeError = - // ignore: deprecated_member_use - Throws(isRangeError); +const Matcher throwsRangeError = Throws(isRangeError); /// A matcher for functions that throw StateError. -const Matcher throwsStateError = - // ignore: deprecated_member_use - Throws(isStateError); +const Matcher throwsStateError = Throws(isStateError); /// A matcher for functions that throw Exception. -const Matcher throwsUnimplementedError = - // ignore: deprecated_member_use - Throws(isUnimplementedError); +const Matcher throwsUnimplementedError = Throws(isUnimplementedError); /// A matcher for functions that throw UnsupportedError. -const Matcher throwsUnsupportedError = - // ignore: deprecated_member_use - Throws(isUnsupportedError); +const Matcher throwsUnsupportedError = Throws(isUnsupportedError); diff --git a/pkgs/test_api/test/frontend/expect_async_test.dart b/pkgs/test_api/test/frontend/expect_async_test.dart index a37e6574..a4a70b3f 100644 --- a/pkgs/test_api/test/frontend/expect_async_test.dart +++ b/pkgs/test_api/test/frontend/expect_async_test.dart @@ -330,7 +330,6 @@ void main() { test("works with no arguments", () async { var callbackRun = false; var liveTest = await runTestBody(() { - // ignore: deprecated_member_use expectAsync(() { callbackRun = true; })(); @@ -343,7 +342,6 @@ void main() { test("works with arguments", () async { var callbackRun = false; var liveTest = await runTestBody(() { - // ignore: deprecated_member_use expectAsync((arg1, arg2) { callbackRun = true; })(1, 2); @@ -354,7 +352,6 @@ void main() { }); test("doesn't support a function with 7 arguments", () { - // ignore: deprecated_member_use expect(() => expectAsync((_1, _2, _3, _4, _5, _6, _7) {}), throwsArgumentError); }); diff --git a/pkgs/test_api/test/frontend/expect_test.dart b/pkgs/test_api/test/frontend/expect_test.dart index 9b6e2c1b..2b0de989 100644 --- a/pkgs/test_api/test/frontend/expect_test.dart +++ b/pkgs/test_api/test/frontend/expect_test.dart @@ -27,12 +27,10 @@ void main() { group("an async matcher that fails synchronously", () { test("throws synchronously", () { - // ignore: deprecated_member_use expect(() => expect(() {}, throws), throwsA(isTestFailure(anything))); }); test("can be used with synchronous operators", () { - // ignore: deprecated_member_use expect(() {}, isNot(throws)); }); }); diff --git a/pkgs/test_api/test/frontend/matcher/throws_test.dart b/pkgs/test_api/test/frontend/matcher/throws_test.dart index 9b308d16..b46e12b8 100644 --- a/pkgs/test_api/test/frontend/matcher/throws_test.dart +++ b/pkgs/test_api/test/frontend/matcher/throws_test.dart @@ -13,14 +13,12 @@ void main() { group("synchronous", () { group("[throws]", () { test("with a function that throws an error", () { - // ignore: deprecated_member_use expect(() => throw 'oh no', throws); }); test("with a function that doesn't throw", () async { var closure = () {}; var liveTest = await runTestBody(() { - // ignore: deprecated_member_use expect(closure, throws); }); @@ -36,7 +34,6 @@ void main() { test("with a non-function", () async { var liveTest = await runTestBody(() { - // ignore: deprecated_member_use expect(10, throws); }); @@ -111,13 +108,11 @@ void main() { group("asynchronous", () { group("[throws]", () { test("with a Future that throws an error", () { - // ignore: deprecated_member_use expect(Future.error('oh no'), throws); }); test("with a Future that doesn't throw", () async { var liveTest = await runTestBody(() { - // ignore: deprecated_member_use expect(Future.value(), throws); }); @@ -132,13 +127,11 @@ void main() { }); test("with a closure that returns a Future that throws an error", () { - // ignore: deprecated_member_use expect(() => Future.error('oh no'), throws); }); test("with a closure that returns a Future that doesn't throw", () async { var liveTest = await runTestBody(() { - // ignore: deprecated_member_use expect(() => Future.value(), throws); }); @@ -155,7 +148,6 @@ void main() { test("won't let the test end until the Future completes", () { return expectTestBlocks(() { var completer = Completer(); - // ignore: deprecated_member_use expect(completer.future, throws); return completer; }, (completer) => completer.completeError('oh no')); -- GitLab