Remove 'must be non-null' and 'must not be null' comments from non-framework libraries (#134994)

## Description

This removes all of the comments that are of the form "so-and-so must not be null" or "so-and-so must be non-null" from the cases where those values are defines as non-nullable values.

This PR removes them from the library in the repo that don't have anything to do with the framework.

This was done by hand, since it really didn't lend itself to scripting, so it needs to be more than just spot-checked, I think. I was careful to leave any comment that referred to parameters that were nullable, but I may have missed some.

In addition to being no longer relevant after null safety has been made the default, these comments were largely fragile, in that it was easy for them to get out of date, and not be accurate anymore anyhow.

This did create a number of constructor comments which basically say "Creates a [Foo].", but I don't really know how to avoid that in a large scale change, since there's not much you can really say in a lot of cases.  I think we might consider some leniency for constructors to the "Comment must be meaningful" style guidance (which we de facto have already, since there are a bunch of these).

## Related PRs
- https://github.com/flutter/flutter/pull/134984
- https://github.com/flutter/flutter/pull/134991
- https://github.com/flutter/flutter/pull/134992
- https://github.com/flutter/flutter/pull/134993

## Tests
 - Documentation only change.
This commit is contained in:
Greg Spencer
2023-09-19 10:26:07 -07:00
committed by GitHub
parent d3c60569d1
commit 4ce7fdd92b
12 changed files with 7 additions and 60 deletions

View File

@@ -9,8 +9,6 @@ import 'message.dart';
/// A Flutter Driver command that waits until a given [condition] is satisfied.
class WaitForCondition extends Command {
/// Creates a command that waits for the given [condition] is met.
///
/// The [condition] argument must not be null.
const WaitForCondition(this.condition, {super.timeout});
/// Deserializes this command from the value generated by [serialize].
@@ -89,8 +87,6 @@ class NoTransientCallbacks extends SerializableWaitCondition {
/// Factory constructor to parse a [NoTransientCallbacks] instance from the
/// given JSON map.
///
/// The [json] argument must not be null.
factory NoTransientCallbacks.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'NoTransientCallbacksCondition') {
throw SerializationException('Error occurred during deserializing the NoTransientCallbacksCondition JSON string: $json');
@@ -109,8 +105,6 @@ class NoPendingFrame extends SerializableWaitCondition {
/// Factory constructor to parse a [NoPendingFrame] instance from the given
/// JSON map.
///
/// The [json] argument must not be null.
factory NoPendingFrame.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'NoPendingFrameCondition') {
throw SerializationException('Error occurred during deserializing the NoPendingFrameCondition JSON string: $json');
@@ -129,8 +123,6 @@ class FirstFrameRasterized extends SerializableWaitCondition {
/// Factory constructor to parse a [FirstFrameRasterized] instance from the
/// given JSON map.
///
/// The [json] argument must not be null.
factory FirstFrameRasterized.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'FirstFrameRasterizedCondition') {
throw SerializationException('Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: $json');
@@ -152,8 +144,6 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
/// Factory constructor to parse a [NoPendingPlatformMessages] instance from the
/// given JSON map.
///
/// The [json] argument must not be null.
factory NoPendingPlatformMessages.deserialize(Map<String, String> json) {
if (json['conditionName'] != 'NoPendingPlatformMessagesCondition') {
throw SerializationException('Error occurred during deserializing the NoPendingPlatformMessagesCondition JSON string: $json');
@@ -168,14 +158,10 @@ class NoPendingPlatformMessages extends SerializableWaitCondition {
/// A combined condition that waits until all the given [conditions] are met.
class CombinedCondition extends SerializableWaitCondition {
/// Creates a [CombinedCondition] condition.
///
/// The [conditions] argument must not be null.
const CombinedCondition(this.conditions);
/// Factory constructor to parse a [CombinedCondition] instance from the
/// given JSON map.
///
/// The [jsonMap] argument must not be null.
factory CombinedCondition.deserialize(Map<String, String> jsonMap) {
if (jsonMap['conditionName'] != 'CombinedCondition') {
throw SerializationException('Error occurred during deserializing the CombinedCondition JSON string: $jsonMap');
@@ -210,8 +196,6 @@ class CombinedCondition extends SerializableWaitCondition {
}
/// Parses a [SerializableWaitCondition] or its subclass from the given [json] map.
///
/// The [json] argument must not be null.
SerializableWaitCondition _deserialize(Map<String, String> json) {
final String conditionName = json['conditionName']!;
switch (conditionName) {

View File

@@ -39,8 +39,6 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition {
/// Factory constructor to parse an [InternalNoTransientCallbacksCondition]
/// instance from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalNoTransientCallbacksCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'NoTransientCallbacksCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -67,8 +65,6 @@ class _InternalNoPendingFrameCondition implements WaitCondition {
/// Factory constructor to parse an [InternalNoPendingFrameCondition] instance
/// from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalNoPendingFrameCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'NoPendingFrameCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -95,8 +91,6 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition {
/// Factory constructor to parse an [InternalNoPendingFrameCondition] instance
/// from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalFirstFrameRasterizedCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'FirstFrameRasterizedCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -121,8 +115,6 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
/// Factory constructor to parse an [_InternalNoPendingPlatformMessagesCondition] instance
/// from the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalNoPendingPlatformMessagesCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'NoPendingPlatformMessagesCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -150,14 +142,10 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
class _InternalCombinedCondition implements WaitCondition {
/// Creates an [_InternalCombinedCondition] instance with the given list of
/// [conditions].
///
/// The [conditions] argument must not be null.
const _InternalCombinedCondition(this.conditions);
/// Factory constructor to parse an [_InternalCombinedCondition] instance from
/// the given [SerializableWaitCondition] instance.
///
/// The [condition] argument must not be null.
factory _InternalCombinedCondition.deserialize(SerializableWaitCondition condition) {
if (condition.conditionName != 'CombinedCondition') {
throw SerializationException('Error occurred during deserializing from the given condition: ${condition.serialize()}');
@@ -187,8 +175,6 @@ class _InternalCombinedCondition implements WaitCondition {
}
/// Parses a [WaitCondition] or its subclass from the given serializable [waitCondition].
///
/// The [waitCondition] argument must not be null.
WaitCondition deserializeCondition(SerializableWaitCondition waitCondition) {
final String conditionName = waitCondition.conditionName;
switch (conditionName) {