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 redundant typed throws rule #1718

Conversation

miguel-jimenez-0529
Copy link
Contributor

This PR adds a new redundantTypedThrows rule, which removes a typed throws (introduced in Swift 6.0) if it is redundant.

For example:

- func foo() throws(Never) -> Int {
+ func foo() -> Int {
      return 0
  }

- func foo() throws(any Error) -> Int {
+ func foo() throws -> Int {
      throw MyError.foo
  }

We don't remove (Error) because we can't guarantee it will reference the Swift.Error protocol
(it's relatively common to define a custom error like enum Error: Swift.Error { ... }).

@miguel-jimenez-0529
Copy link
Contributor Author

cc: @calda

Copy link
Collaborator

@calda calda left a comment

Choose a reason for hiding this comment

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

Looks great! Nice work @miguel-jimenez-0529!

Copy link

codecov bot commented Jun 7, 2024

Codecov Report

Attention: Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.17%. Comparing base (56723db) to head (8b28de6).

Files Patch % Lines
Sources/Rules.swift 96.42% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1718      +/-   ##
===========================================
+ Coverage    95.16%   95.17%   +0.01%     
===========================================
  Files           20       20              
  Lines        23185    23226      +41     
===========================================
+ Hits         22063    22105      +42     
+ Misses        1122     1121       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nicklockwood nicklockwood merged commit 8e64cef into nicklockwood:develop Jun 8, 2024
5 of 7 checks passed
nicklockwood pushed a commit that referenced this pull request Jun 8, 2024
nicklockwood pushed a commit that referenced this pull request Jun 9, 2024
nicklockwood pushed a commit that referenced this pull request Jun 9, 2024
nicklockwood pushed a commit that referenced this pull request Jun 9, 2024
nicklockwood pushed a commit that referenced this pull request Jun 9, 2024
nicklockwood pushed a commit that referenced this pull request Jun 9, 2024
nicklockwood pushed a commit that referenced this pull request Jun 10, 2024
nicklockwood pushed a commit that referenced this pull request Jun 11, 2024
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