Skip to content

False positive triggers for async_without_await, unneeded_throws_rethrows with override functions #6416

@akuzminskyi

Description

@akuzminskyi

New Issue Checklist

Bug Description

async_without_await, unneeded_throws_rethrows "false positive" triggers when function has override.

class A {
    func test() async {
        try? await Task.sleep(for: .seconds(0.5)) 
        print("A")
    }
}

class B: A {
    override func test() async { 
        print("B")
    }
}

Task {
    let b = B()
    await b.test()
}

The following code produces B as output, but when the rule is enabled, it suggests to replace to:

class B: A {
    func test() { 
        print("B")
    }
}

as a result, the output will be A, because it doesn't override the original function. So the rule breaks the logic.
The same happens for throws in unneeded_throws_rethrows rule.

I would suggest excluding the warning for functions that have override

$ swiftlint lint

Environment

  • SwiftLint version: 0.63.0
  • Xcode version: 26.0.1
  • Installation method used: Universal macOS Binary
  • Configuration file:
only_rules:
- async_without_await
- unneeded_throws_rethrows

Are you using nested configurations? If so, paste their
relative paths and respective contents.

Metadata

Metadata

Labels

bugUnexpected and reproducible misbehavior.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions