Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

[New rule] avoid-closure-without-call #1217

Closed
fzyzcjy opened this issue Apr 4, 2023 · 2 comments
Closed

[New rule] avoid-closure-without-call #1217

fzyzcjy opened this issue Apr 4, 2023 · 2 comments
Assignees
Labels
area-rules type: enhancement New feature or request

Comments

@fzyzcjy
Copy link
Contributor

fzyzcjy commented Apr 4, 2023

Rule details

It is a common typo to forget to call a function, but instead just leave the closure there, especially when doing refactoring etc. Thus, this rule will avoid this.

What type of rule is this?

Warns about a potential problem

Example code

Example 1:


InkWell(
  onTap: () => _handle, // BAD
  onTap: () => _handle(), // GOOD
  onTap: _handle, // GOOD
)

void _handle() { ... }

Example 2:

extension Ext on List {
  void myFunction(int a) { ... }
}

Something(
  someCallback: (a) => myList.myFunction, // BAD
  someCallback: (a) => myList.myFunction(a), // GOOD
  someCallback: myList.myFunction, // GOOD
)


### Participation

- [X] I am willing to submit a pull request to implement this rule.

### Additional comments

_No response_
@fzyzcjy fzyzcjy added area-rules type: enhancement New feature or request labels Apr 4, 2023
@fzyzcjy fzyzcjy changed the title (Will make PR if it not implemented) [New rule] avoid-closure-without-call [New rule] avoid-closure-without-call Apr 4, 2023
@incendial
Copy link
Member

Great suggestion, implemented

@incendial
Copy link
Member

Available in Teams 1.3.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-rules type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants