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

Add lint 'discarded_futures'. #4659

Merged
merged 10 commits into from
Oct 31, 2022
Merged

Add lint 'discarded_futures'. #4659

merged 10 commits into from
Oct 31, 2022

Conversation

polina-c
Copy link
Contributor

No description provided.

@polina-c polina-c changed the title Add lint discarded_features. Add lint 'discarded_features'. Oct 29, 2022
@polina-c polina-c changed the title Add lint 'discarded_features'. Add lint 'discarded_futures'. Oct 31, 2022
when(mockClassObject.requestRetainingPath()).thenAnswer((_) async {
retainingPathNotifier.value = testRetainingPath;
});

when(mockClassObject.inboundReferences).thenReturn(inboundRefsNotifier);

// Intebtionally unwaited.
// ignore: discarded_futures
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way we can turn this lint off for the test/ directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I did not find how to exclude just one lint for a directory.
  2. I think code reader will benefit from seeing that a future is dropped.

@@ -166,7 +166,8 @@ class ReleaseNotes extends AnimatedWidget {
: Expanded(
child: Markdown(
data: markdownData!,
onTapLink: (_, href, __) => launchUrl(href!, context),
onTapLink: (_, href, __) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onTapLink: (_, href, __) =>
onTapLink: (_, href, __) async =>
launchUrl(href!, context),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like the fixes to go to separate PRs. They may affect functionality and tests. And I do not want this massive PR to be held by this and thus become victim of error-prone merges.

Created bug: #4668

@@ -158,7 +160,8 @@ class _ConnectDialogState extends State<ConnectDialog>
SizedBox(
width: scaleByFontFactor(350.0),
child: TextField(
onSubmitted: actionInProgress ? null : (str) => _connect(),
onSubmitted:
actionInProgress ? null : (str) => unawaited(_connect()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
actionInProgress ? null : (str) => unawaited(_connect()),
actionInProgress ? null : (str) async => _connect(),

@@ -265,7 +268,7 @@ class ImportFileInstructions extends StatelessWidget {
),
const SizedBox(height: defaultSpacing),
ElevatedButton(
onPressed: () => _importFile(context),
onPressed: () => unawaited(_importFile(context)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onPressed: () => unawaited(_importFile(context)),
onPressed: () async => _importFile(context),

@@ -101,7 +103,7 @@ class _CallStackState extends State<CallStack>
final result = Material(
color: selected ? theme.colorScheme.selectedRowColor : null,
child: InkWell(
onTap: () => _onStackFrameSelected(frame),
onTap: () => unawaited(_onStackFrameSelected(frame)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onTap: () => unawaited(_onStackFrameSelected(frame)),
onTap: () async => _onStackFrameSelected(frame),

@@ -220,7 +222,8 @@ class VariableSelectionControls extends MaterialTextSelectionControls {
clipboardStatus: clipboardStatus!,
handleCut: canCut(delegate) ? () => handleCut(delegate) : null,
handleCopy: canCopy(delegate) ? () => handleCopy(delegate) : null,
handlePaste: canPaste(delegate) ? () => handlePaste(delegate) : null,
handlePaste:
canPaste(delegate) ? () => unawaited(handlePaste(delegate)) : null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
canPaste(delegate) ? () => unawaited(handlePaste(delegate)) : null,
canPaste(delegate) ? () => unawaited(handlePaste(delegate)) : null,

@@ -121,7 +121,7 @@ final enumValueInstance = AsyncValue.data(
);

void main() {
setUpAll(() => loadFonts());
setUpAll(() async => await loadFonts());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setUpAll(() async => await loadFonts());
setUpAll(() async => loadFonts());

@@ -30,6 +30,9 @@ void main() {

setUp(() {
reloads = 0;

// Intebtionally unwaited.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Intebtionally unwaited.
// Intentionally unwaited.

y

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also make the setup closure async instead
setUp(() async {

@@ -81,6 +84,9 @@ void main() {

setUp(() {
restarts = 0;

// Intebtionally unwaited.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Intebtionally unwaited.
// Intentionally unwaited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same about the setup could instead be async

@@ -38,6 +38,8 @@ void main() {
when(mockClassObject.reachableSize).thenReturn(null);
when(mockClassObject.retainedSize).thenReturn(null);

// Intebtionally unwaited.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Intebtionally unwaited.
// Intentionally unwaited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could make setup async instead
setUp(() async {

when(mockClassObject.requestRetainingPath()).thenAnswer((_) async {
retainingPathNotifier.value = testRetainingPath;
});

when(mockClassObject.inboundReferences).thenReturn(inboundRefsNotifier);

// Intebtionally unwaited.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Intebtionally unwaited.
// Intentionally unwaited.

@polina-c polina-c merged commit b3eefe3 into flutter:master Oct 31, 2022
@polina-c polina-c deleted the lint branch October 31, 2022 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants