-
Notifications
You must be signed in to change notification settings - Fork 229
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
Warn about publishing in mixed mode #2583
Conversation
The null-safety analysis now rejects any package that doesn't opt-in before doing resolution. This is reflected in this test.
@@ -445,6 +446,17 @@ class Pubspec { | |||
bool get isEmpty => | |||
name == null && version == Version.none && dependencies.isEmpty; | |||
|
|||
/// The language version implied by the sdk constraint. | |||
/// | |||
/// Given no or unbounded constraint we assume language version 1.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
Doesn't the spec say that the fallback language version is the whatever the current SDK has?
I can see that this might cause validation errors if you have no SDK constraint..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub.dev treats packages with no constraint as dart 1 packages, so at least for null-safety checking I think this makes sense. We might have to revise later.
lib/src/null_safety_analysis.dart
Outdated
.languageVersion; | ||
if (!rootLanguageVersion.supportsNullSafety) { | ||
return NullSafetyAnalysisResult( | ||
NullSafetyCompliance.notCompliant, 'Is not opting in to null safety'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be more specific? Like "Package $packageId has not opted into null-safety with the environment.sdk constraint in pubspec.yaml", or something like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added SourceSpans highlighting the problem
final NullSafetyCompliance compliance; | ||
|
||
/// `null` if compliance == [NullSafetyCompliance.compliant]. | ||
final String reason; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it, we might even want to output this in the JSON output from pub outdated
.
lib/src/null_safety_analysis.dart
Outdated
final languageVersion = pubspec.languageVersion; | ||
if (languageVersion == null || !languageVersion.supportsNullSafety) { | ||
return NullSafetyAnalysisResult(NullSafetyCompliance.notCompliant, | ||
'package:${dependencyId.name} is not opted into null safety'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, can we say something with environment.sdk in pubspec.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added SourceSpans highlighting the problem
lib/src/null_safety_analysis.dart
Outdated
if (!languageVersion.supportsNullSafety) { | ||
return NullSafetyAnalysisResult( | ||
NullSafetyCompliance.notCompliant, | ||
'$fileUrl is opting out of null safety'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'$fileUrl is opting out of null safety'); | |
'$fileUrl is opting out of null-safety with language version marker $languageVersionToken'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added SourceSpans highlighting the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
lib/src/null_safety_analysis.dart
Outdated
.languageVersion; | ||
if (!rootLanguageVersion.supportsNullSafety) { | ||
return NullSafetyAnalysisResult( | ||
NullSafetyCompliance.notCompliant, 'Is not opting in to null safety'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added SourceSpans highlighting the problem
lib/src/null_safety_analysis.dart
Outdated
final languageVersion = pubspec.languageVersion; | ||
if (languageVersion == null || !languageVersion.supportsNullSafety) { | ||
return NullSafetyAnalysisResult(NullSafetyCompliance.notCompliant, | ||
'package:${dependencyId.name} is not opted into null safety'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added SourceSpans highlighting the problem
lib/src/null_safety_analysis.dart
Outdated
if (!languageVersion.supportsNullSafety) { | ||
return NullSafetyAnalysisResult( | ||
NullSafetyCompliance.notCompliant, | ||
'$fileUrl is opting out of null safety'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added SourceSpans highlighting the problem
#2438