googlearchive / pedantic

How to get the most value from Dart static analysis
https://pub.dev/packages/pedantic
BSD 3-Clause "New" or "Revised" License
324 stars 56 forks source link

Unable to use 1.9.0 on Flutter stable 1.12.13+hotfix.5 #46

Closed MisterJimson closed 4 years ago

MisterJimson commented 4 years ago
Because every version of flutter_test from sdk depends on pedantic 1.8.0+1 and beyond depends on pedantic ^1.9.0, flutter_test from sdk is forbidden.

So, because beyond depends on flutter_test any from sdk, version solving failed.
pub get failed (1; So, because beyond depends on flutter_test any from sdk, version solving failed.

Is this intentional? We need to wait until the Flutter test SDK uses 1.9.0 before we can use it in our projects?

davidmorgan commented 4 years ago

This is a bug in flutter_test; it should not pin to exactly 1.8.0. I'll file an issue.

dnfield commented 4 years ago

Note that, however we slice this, you will not be able to easily use the non-pinned pedantic with Flutter stable. However, you could work around it with a dependency_override:

name: flutter_project

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  pedantic: 1.8.0+1

dependency_overrides:
  pedantic: 1.9.0
dnfield commented 4 years ago

(this should generally be safe because all of the dart code in pedantic is a one line function that doesn't really change from version to version)

fstof commented 4 years ago

This also applies to flutter_driver where it pins the pedantic version.

Should probably fix both of these at one time

dnfield commented 4 years ago

@fstof flutter_driver does not depend on or pin pedantic.

I think this issue should probably be closed. Flutter very intentionally pins its dependencies, including transitive dependencies. We do this because failure to do so opens us up to strange and difficult to debug breakages when some transitive dependency makes a breaking change but doesn't properly update the semver - which happpens more often than one might expect. Flutter aims to depend on as few libraries as possible, and to pin the libraries it does depend on so that it can reliably and predictably run tests.

We do try to frequently update package dependencies - there is an open issue to automate this process at https://github.com/flutter/flutter/issues/37985

IMHO, it is a mistake for any package to ever have a direct non-dev depdnency on pedantic. The package offers only one function that is exactly this:

void unawaited(Future<void> future) {}

which is super trivial to just implement yourself and never get into conflicts between which version of pedantic two packages want to use or pin to.

And worst case scenario, you can just use a dependency override as suggested in https://github.com/dart-lang/pedantic/issues/46#issuecomment-571359160 - which should pretty much always work because pedantic only has that one function in it code wise.

fstof commented 4 years ago

Thanks @dnfield. No problem. Will do the override.

davidmorgan commented 4 years ago

@dnfield Yeah, I'll close this.

IMHO, it is a mistake for any package to ever have a direct non-dev depdnency on pedantic. The package offers only one function that is exactly this:

Please don't suggest that people copy and paste as an alternative to adding a dependency. There's nothing wrong with small packages. Flutter not complying with semver is a bug, copying and pasting is a workaround, not a good practice.