diff --git a/example/regex_substituter_fixtures/pubspec.yaml b/example/regex_substituter_fixtures/pubspec.yaml index 7f5ddd1..c640b7b 100644 --- a/example/regex_substituter_fixtures/pubspec.yaml +++ b/example/regex_substituter_fixtures/pubspec.yaml @@ -5,4 +5,4 @@ version: 0.0.0 dependencies: codemod: ^0.1.0 environment: - sdk: '>=2.11.0 <3.0.0' + sdk: '>=3.0.0 <4.0.0' diff --git a/pubspec.yaml b/pubspec.yaml index 40d2789..ce4a69e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: codemod -version: 1.0.11 +version: 1.1.0 homepage: https://github.com/Workiva/dart_codemod description: > @@ -7,10 +7,10 @@ description: > towards updating and refactoring Dart code, but can modify any files. environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=3.0.0 <4.0.0' dependencies: - analyzer: ^5.0.0 + analyzer: ^6.3.0 args: ^2.0.0 glob: ^2.0.1 io: ^1.0.0 @@ -27,5 +27,5 @@ dev_dependencies: dart_style: ^2.0.0 dependency_validator: ^3.0.0 meta: ^1.6.0 - mockito: ^5.3.2 + mocktail: ^1.0.1 pedantic: ^1.11.0 diff --git a/test/aggregate_suggestor_test.dart b/test/aggregate_suggestor_test.dart index ccae4e7..3ff9f52 100644 --- a/test/aggregate_suggestor_test.dart +++ b/test/aggregate_suggestor_test.dart @@ -15,10 +15,10 @@ @TestOn('vm') import 'package:codemod/codemod.dart'; import 'package:codemod/test.dart'; -import 'package:mockito/annotations.dart'; +import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; -import 'aggregate_suggestor_test.mocks.dart'; +class MockPatch extends Mock implements Patch {} @override Stream fooSuggestor(_) async* { @@ -36,7 +36,6 @@ class BarPatch extends MockPatch {} class ShouldBeSkippedPatch extends MockPatch {} -@GenerateMocks([Patch]) void main() { test('aggregate should yield patches from each suggestor', () async { final suggestor = aggregate([fooSuggestor, barSuggestor]); diff --git a/test/aggregate_suggestor_test.mocks.dart b/test/aggregate_suggestor_test.mocks.dart deleted file mode 100644 index 7c70643..0000000 --- a/test/aggregate_suggestor_test.mocks.dart +++ /dev/null @@ -1,38 +0,0 @@ -// Mocks generated by Mockito 5.0.3 from annotations -// in codemod/test/aggregate_suggestor_test.dart. -// Do not manually edit this file. - -import 'package:codemod/src/patch.dart' as _i2; -import 'package:mockito/mockito.dart' as _i1; - -// ignore_for_file: comment_references -// ignore_for_file: unnecessary_parenthesis - -/// A class which mocks [Patch]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockPatch extends _i1.Mock implements _i2.Patch { - MockPatch() { - _i1.throwOnMissingStub(this); - } - - @override - int get startOffset => - (super.noSuchMethod(Invocation.getter(#startOffset), returnValue: 0) - as int); - @override - String get updatedText => - (super.noSuchMethod(Invocation.getter(#updatedText), returnValue: '') - as String); - @override - int get hashCode => - (super.noSuchMethod(Invocation.getter(#hashCode), returnValue: 0) as int); - @override - bool operator ==(Object? other) => - (super.noSuchMethod(Invocation.method(#==, [other]), returnValue: false) - as bool); - @override - String toString() => - (super.noSuchMethod(Invocation.method(#toString, []), returnValue: '') - as String); -} diff --git a/test/util_test.dart b/test/util_test.dart index 32cb0fd..201fc98 100644 --- a/test/util_test.dart +++ b/test/util_test.dart @@ -15,17 +15,15 @@ @TestOn('vm') import 'dart:io'; -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; +import 'package:mocktail/mocktail.dart'; import 'package:source_span/source_span.dart'; import 'package:test/test.dart'; import 'package:codemod/src/patch.dart'; import 'package:codemod/src/util.dart'; -import 'util_test.mocks.dart'; +class MockStdout extends Mock implements Stdout {} -@GenerateMocks([Stdout]) void main() { group('Utils', () { group('applyPatches()', () { @@ -132,21 +130,21 @@ line 5;'''); group('calculateDiffSize()', () { test('returns 10 if stdout does not have a terminal', () { final mockStdout = MockStdout(); - when(mockStdout.hasTerminal).thenReturn(false); + when(() => mockStdout.hasTerminal).thenReturn(false); expect(calculateDiffSize(mockStdout), 10); }); test('returns 10 if # of terminal lines is too small', () { final mockStdout = MockStdout(); - when(mockStdout.hasTerminal).thenReturn(true); - when(mockStdout.terminalLines).thenReturn(15); + when(() => mockStdout.hasTerminal).thenReturn(true); + when(() => mockStdout.terminalLines).thenReturn(15); expect(calculateDiffSize(mockStdout), 10); }); test('returns 10 less than available # of terminal lines', () { final mockStdout = MockStdout(); - when(mockStdout.hasTerminal).thenReturn(true); - when(mockStdout.terminalLines).thenReturn(50); + when(() => mockStdout.hasTerminal).thenReturn(true); + when(() => mockStdout.terminalLines).thenReturn(50); expect(calculateDiffSize(mockStdout), 40); }); }); diff --git a/test/util_test.mocks.dart b/test/util_test.mocks.dart deleted file mode 100644 index 0b7d390..0000000 --- a/test/util_test.mocks.dart +++ /dev/null @@ -1,84 +0,0 @@ -// Mocks generated by Mockito 5.0.3 from annotations -// in codemod/test/util_test.dart. -// Do not manually edit this file. - -import 'dart:async' as _i4; -import 'dart:convert' as _i3; -import 'dart:io' as _i2; - -import 'package:mockito/mockito.dart' as _i1; - -// ignore_for_file: comment_references -// ignore_for_file: unnecessary_parenthesis - -class _FakeIOSink extends _i1.Fake implements _i2.IOSink {} - -class _FakeEncoding extends _i1.Fake implements _i3.Encoding {} - -/// A class which mocks [Stdout]. -/// -/// See the documentation for Mockito's code generation for more information. -class MockStdout extends _i1.Mock implements _i2.Stdout { - MockStdout() { - _i1.throwOnMissingStub(this); - } - - @override - bool get hasTerminal => - (super.noSuchMethod(Invocation.getter(#hasTerminal), returnValue: false) - as bool); - @override - int get terminalColumns => - (super.noSuchMethod(Invocation.getter(#terminalColumns), returnValue: 0) - as int); - @override - int get terminalLines => - (super.noSuchMethod(Invocation.getter(#terminalLines), returnValue: 0) - as int); - @override - bool get supportsAnsiEscapes => - (super.noSuchMethod(Invocation.getter(#supportsAnsiEscapes), - returnValue: false) as bool); - @override - _i2.IOSink get nonBlocking => - (super.noSuchMethod(Invocation.getter(#nonBlocking), - returnValue: _FakeIOSink()) as _i2.IOSink); - @override - _i3.Encoding get encoding => (super.noSuchMethod(Invocation.getter(#encoding), - returnValue: _FakeEncoding()) as _i3.Encoding); - @override - set encoding(_i3.Encoding? encoding) => - super.noSuchMethod(Invocation.setter(#encoding, encoding), - returnValueForMissingStub: null); - @override - _i4.Future get done => (super.noSuchMethod(Invocation.getter(#done), - returnValue: Future.value(null)) as _i4.Future); - @override - void writeAll(Iterable? objects, [String? sep = r'']) => - super.noSuchMethod(Invocation.method(#writeAll, [objects, sep]), - returnValueForMissingStub: null); - @override - void add(List? data) => - super.noSuchMethod(Invocation.method(#add, [data]), - returnValueForMissingStub: null); - @override - void addError(Object? error, [StackTrace? stackTrace]) => - super.noSuchMethod(Invocation.method(#addError, [error, stackTrace]), - returnValueForMissingStub: null); - @override - void writeCharCode(int? charCode) => - super.noSuchMethod(Invocation.method(#writeCharCode, [charCode]), - returnValueForMissingStub: null); - @override - _i4.Future addStream(_i4.Stream>? stream) => - (super.noSuchMethod(Invocation.method(#addStream, [stream]), - returnValue: Future.value(null)) as _i4.Future); - @override - _i4.Future flush() => - (super.noSuchMethod(Invocation.method(#flush, []), - returnValue: Future.value(null)) as _i4.Future); - @override - _i4.Future close() => - (super.noSuchMethod(Invocation.method(#close, []), - returnValue: Future.value(null)) as _i4.Future); -}