-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 async_without_await
rule
#5869
base: main
Are you sure you want to change the base?
Add async_without_await
rule
#5869
Conversation
0887f12
to
f46ddfb
Compare
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.
Thank you for this first implementation!
Apart from my inline comments I have a few remarks:
- The current implementation only covers functions. Think about adding support for other declarations supporting
async
. - Automatic fixes could be offered by this rule.
- I presume the rule will currently fail to flag the
async
onf
in the following example:func f() async { func g() async {} let x = { await g() } }
- Perhaps
async_without_await
is sufficient as the rule's name. It sounds more like something to be aware of and not like a serious violation.
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoAsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoAsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoAsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoAsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoAsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoAsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
no_async_without_await
ruleasync_without_await
rule
Hi @SimplyDanny,
But it fails if a method is declared in a |
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.
Well done!
Again a few nits and some remarks:
- Please check the findings in OSS repositories. This violation is a false positive for example.
- The current implementation doesn't respect
async let x = ...
constructs.
Source/SwiftLintBuiltInRules/Rules/Lint/AsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/AsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/AsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/AsyncWithoutAwaitRule.swift
Outdated
Show resolved
Hide resolved
…itRule.swift Co-authored-by: Danny Mösch <[email protected]>
…itRule.swift Co-authored-by: Danny Mösch <[email protected]>
…itRule.swift Co-authored-by: Danny Mösch <[email protected]>
Co-authored-by: Danny Mösch <[email protected]>
…itRule.swift Co-authored-by: Danny Mösch <[email protected]>
Co-authored-by: Danny Mösch <[email protected]>
…swift Co-authored-by: Michal Srutek <[email protected]>
8f13b30
to
1ebcdb7
Compare
Source/SwiftLintBuiltInRules/Rules/Lint/AsyncWithoutAwaitRuleExamples.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/AsyncWithoutAwaitRuleExamples.swift
Outdated
Show resolved
Hide resolved
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.
👏
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.
🧡
Adds
async_without_await
#5082