Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

stop discarding futures #3455

Merged
merged 1 commit into from
Jun 14, 2022
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 analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ linter:
# - close_sinks # https://github.com/dart-lang/linter/issues/268
- comment_references
- directives_ordering
- discarded_futures
- invariant_booleans
- join_return_with_assignment
# - lines_longer_than_80_chars # under review (see #1068)
Expand Down
4 changes: 2 additions & 2 deletions tool/checks/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import 'package:path/path.dart' as path;

import 'rules/visit_registered_nodes.dart';

void main() {
Future<void> main() async {
Copy link
Contributor

@albertms10 albertms10 Jun 15, 2022

Choose a reason for hiding this comment

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

As per #3229, we may drop the Future annotation in favor of void in top-level main functions.

WDYT, @pq? If you want, I can open a new PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Relaxing avoid_void_async to allow this idiom does sort of suggest this Future return type annotation is gratuitous. Interestingly, this is what the analyzer ADD_ASYNC quick-fix produces. Maybe we should consider updating it to not do this for main?

/cc @bwilkerson

As for a cleanup PR, @albertms10, sure thing.

Thanks for the feedback!

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no idea how common that idiom is, but if it's common enough then it would make sense to support it. Not sure who ought to be looped in to the conversation.

var rules =
path.normalize(io.File(path.join('lib', 'src', 'rules')).absolute.path);
Driver([VisitRegisteredNodes()]).analyze([rules]);
await Driver([VisitRegisteredNodes()]).analyze([rules]);
}

class Driver {
Expand Down
8 changes: 5 additions & 3 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import 'doc.dart';
import 'rule.dart';

@Deprecated('To be removed')
void main(List<String> args) => grind(args);
Future<void> main(List<String> args) async {
await grind(args);
}

Iterable<String> get sourcePaths => sources.map((dir) => dir.path);

Expand All @@ -26,10 +28,10 @@ Iterable<FileSystemEntity> get sources => existingSourceDirs.expand((dir) {
});

@Task('Generate lint rule docs.')
void docs() {
Future<void> docs() async {
var args = context.invocation.arguments;
var dir = args.getOption('dir');
generateDocs(dir);
await generateDocs(dir);
}

@Task('Format linter sources.')
Expand Down