Skip to content

Commit

Permalink
Merge pull request #73 from Workiva/dart3_wip
Browse files Browse the repository at this point in the history
RM-161448 Release dart_codemod 1.1.0 with Dart 3 support
  • Loading branch information
rmconsole2-wf authored Oct 31, 2023
2 parents 0baa399 + 06b28ea commit 3321751
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 162 deletions.
51 changes: 28 additions & 23 deletions .github/workflows/dart_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
sdk: [ stable, beta, dev ]
sdk: [ 2.19.6, stable, beta ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
Expand All @@ -32,24 +32,29 @@ jobs:
- name: Run tests
run: dart test

validate_analyzer:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [ stable ]
analyzer:
- ^5.0.0
# Uncomment once we're on Dart 2.19+
# - ^6.0.0
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
- name: Update analyzer constraint to ${{ matrix.analyzer }}
run: dart pub remove analyzer && dart pub add analyzer:${{ matrix.analyzer }} && git diff pubspec.yaml
- name: Analyze project source
run: dart analyze
- name: Run tests
run: dart test
# If new major versions of analyzer are released in the future and we want to
# be compatible with multiple majors, use this workflow to validate.
# NOTE: we're currently compatible with analyzer v5 and v6, but v5 is only
# compatible with Dart 2 and v6 is only compatible with Dart 3, so we are
# already testing both major versions above. Use this workflow below if we
# need to test compatibility across multiple analyzer majors all on Dart 3.
# validate_analyzer:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# sdk: [ stable ]
# analyzer:
# - ^6.0.0
# - ^7.0.0
# steps:
# - uses: actions/checkout@v4
# - uses: dart-lang/setup-dart@v1
# with:
# sdk: ${{ matrix.sdk }}
# - name: Update analyzer constraint to ${{ matrix.analyzer }}
# run: dart pub remove analyzer && dart pub add analyzer:${{ matrix.analyzer }} && git diff pubspec.yaml
# - name: Analyze project source
# run: dart analyze
# - name: Run tests
# run: dart test
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.1.0](https://github.com/Workiva/dart_codemod/compare/1.0.11...1.1.0)

- Compatibility with Dart 3 and analyzer 6.

## [1.0.11](https://github.com/Workiva/dart_codemod/compare/1.0.10...1.0.11)

- Widen analyzer dependency range to include v3, v4, and v5.
Expand Down
2 changes: 1 addition & 1 deletion example/regex_substituter_fixtures/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: codemod
version: 1.0.11
version: 1.1.0
homepage: https://github.com/Workiva/dart_codemod

description: >
Write and run automated code modifications on a codebase. Primarily geared
towards updating and refactoring Dart code, but can modify any files.
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.19.0 <4.0.0'

dependencies:
analyzer: ^5.0.0
analyzer: '>=5.13.0 <7.0.0'
args: ^2.0.0
glob: ^2.0.1
io: ^1.0.0
Expand All @@ -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
5 changes: 2 additions & 3 deletions test/aggregate_suggestor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Patch> fooSuggestor(_) async* {
Expand All @@ -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]);
Expand Down
38 changes: 0 additions & 38 deletions test/aggregate_suggestor_test.mocks.dart

This file was deleted.

16 changes: 7 additions & 9 deletions test/util_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () {
Expand Down Expand Up @@ -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);
});
});
Expand Down
84 changes: 0 additions & 84 deletions test/util_test.mocks.dart

This file was deleted.

0 comments on commit 3321751

Please sign in to comment.