Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes the default for checking the SDK version and treating it as a breaking change to off #184

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- introduces `force-use-flutter` option for all commands to force dart_apitool to use the `flutter` command.
- extend type usage tracking and fix situations in which types that are used in @visibleForTesting contexts were detected as not exported
- fix: don't treat adding static elements (methods, fields) or consts to a required interface as breaking
- fix: changed default for `--check-sdk-version` from `on` to `off as changing the SDK version can not lead to breaking existing consumer code

## Version 0.18.0
- add missing export to json output for `extract` command
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Usage: dart-apitool diff [arguments]
This affects the exit code of this program.
[none, fully (default), onlyBreakingChanges]
--[no-]check-sdk-version Determines if the SDK version should be checked.
(defaults to on)
(defaults to off)
--[no-]ignore-prerelease Determines if the pre-release aspect of the new version
shall be ignored when checking versions.
You may want to do this if you want to make sure
Expand Down
5 changes: 3 additions & 2 deletions lib/src/cli/commands/diff_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ This affects the exit code of this program.
);
argParser.addFlag(
_optionNameCheckSdkVersion,
help: 'Determines if the SDK version should be checked.',
defaultsTo: true,
help:
'Determines if the SDK version should be checked.\n(defaults to off)',
defaultsTo: false,
negatable: true,
);
argParser.addFlag(
Expand Down
48 changes: 27 additions & 21 deletions lib/src/diff/package_api_differ.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ class PackageApiDiffer {
newApi.androidPlatformConstraints,
isExperimental: false,
),
if (options.doCheckSdkVersion)
..._calculateSdkDiff(
oldApi,
newApi,
isExperimental: false,
),
..._calculateSdkDiff(
oldApi,
newApi,
isExperimental: false,
doCheckSdkVersion: options.doCheckSdkVersion,
),
..._calculatePackageDependenciesDiff(
oldApi,
newApi,
Expand Down Expand Up @@ -1123,8 +1123,12 @@ class PackageApiDiffer {
return changes;
}

List<ApiChange> _calculateSdkDiff(PackageApi oldApi, PackageApi newApi,
{required bool isExperimental}) {
List<ApiChange> _calculateSdkDiff(
PackageApi oldApi,
PackageApi newApi, {
required bool isExperimental,
required bool doCheckSdkVersion,
}) {
final result = <ApiChange>[];
if (oldApi.sdkType != newApi.sdkType) {
result.add(
Expand All @@ -1139,19 +1143,21 @@ class PackageApiDiffer {
),
);
}
// lowering the version is no problem => check if new version is higher
if (oldApi.minSdkVersion < newApi.minSdkVersion) {
result.add(
ApiChange(
changeCode: ApiChangeCode.csdk02,
affectedDeclaration: null,
contextTrace: [],
type: ApiChangeType.changeBreaking,
isExperimental: isExperimental,
changeDescription:
'Minimum SDK version changed from ${oldApi.minSdkVersion} to ${newApi.minSdkVersion}',
),
);
if (doCheckSdkVersion) {
// lowering the version is no problem => check if new version is higher
if (oldApi.minSdkVersion < newApi.minSdkVersion) {
result.add(
ApiChange(
changeCode: ApiChangeCode.csdk02,
affectedDeclaration: null,
contextTrace: [],
type: ApiChangeType.changeBreaking,
isExperimental: isExperimental,
changeDescription:
'Minimum SDK version changed from ${oldApi.minSdkVersion} to ${newApi.minSdkVersion}',
),
);
}
}
return result;
}
Expand Down
5 changes: 3 additions & 2 deletions readme/change_codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ If the flag got removed then this change is non-breaking. Adding an experimental

If the flag got removed then this change is non-breaking. Adding a sealed flag is considered a breaking change.

## Executables are constructors, methods, and functions. They are all treated the same way.
## Executables
Executables are constructors, methods, and functions. They are all treated the same way.

### CE01

Expand All @@ -102,7 +103,7 @@ If a renaming of a named parameter is detected, then this change is breaking. A

> Executable parameters are reordered

That's a tricky one. Dart-apitool tries to match the old and the new parameters based on name and type to try to follow the reordering. If a reordering happened with named parameters and dart-apitool is able to match them then we have a non-breaking change. If it has (or dart-apitool things that it has) any effect on the user's code then we have a breaking change.
That's a tricky one. Dart-apitool tries to match the old and the new parameters based on name and type to try to follow the reordering. If a reordering happened with named parameters and dart-apitool is able to match them then we have a non-breaking change. If it has (or dart-apitool thinks that it has) any effect on the user's code then we have a breaking change.

### CE05

Expand Down
Loading