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

RedundantTypeAnnotation: add 'ignore_type_interfaces' option #5839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jaredgrubb
Copy link

The redundant_type_annotation and explicit_type_interface rules conflict. For users that want to have an explicit type interface, but still be able to write simple code inside the bodies of functions, I want to add an option to redundant_type_annotation that has it ignore "type interfaces".

For example, this allows:

struct Foo {
    var bar: Bar = Bar() // OK: ignore this! I want explicit types on interfaces.
    func baz() {
       let bar: Bar = Bar() // WARN: redundant_type_annotation kicks in here though.
    }
}

I suggest that this addresses the complaint made in Issue #3750.

The `redundant_type_annotation` and `explicit_type_interface` rules conflict.
For users that want to have an explicit type interface, but still be able to write
simple code inside the bodies of functions, I want to add an option to
`redundant_type_annotation` that has it ignore "type interfaces".

For example, this allows:
```
struct Foo {
    var bar: Bar = Bar() // OK: ignore this! I want explicit types on interfaces.
    func baz() {
       let bar: Bar = Bar() // WARN: redundant_type_annotation kicks in here though.
    }
}
```
@SwiftLintBot
Copy link

SwiftLintBot commented Oct 28, 2024

17 Messages
📖 Linting Aerial with this PR took 0.93s vs 0.93s on main (0% slower)
📖 Linting Alamofire with this PR took 1.27s vs 1.27s on main (0% slower)
📖 Linting Brave with this PR took 7.22s vs 7.21s on main (0% slower)
📖 Linting DuckDuckGo with this PR took 5.1s vs 5.1s on main (0% slower)
📖 Linting Firefox with this PR took 10.73s vs 10.67s on main (0% slower)
📖 Linting Kickstarter with this PR took 9.9s vs 9.93s on main (0% faster)
📖 Linting Moya with this PR took 0.53s vs 0.54s on main (1% faster)
📖 Linting NetNewsWire with this PR took 2.83s vs 2.82s on main (0% slower)
📖 Linting Nimble with this PR took 0.78s vs 0.78s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.61s vs 8.45s on main (1% slower)
📖 Linting Quick with this PR took 0.45s vs 0.45s on main (0% slower)
📖 Linting Realm with this PR took 4.52s vs 4.53s on main (0% faster)
📖 Linting Sourcery with this PR took 2.31s vs 2.32s on main (0% faster)
📖 Linting Swift with this PR took 4.54s vs 4.53s on main (0% slower)
📖 Linting VLC with this PR took 1.26s vs 1.26s on main (0% slower)
📖 Linting Wire with this PR took 17.8s vs 17.85s on main (0% faster)
📖 Linting WordPress with this PR took 11.4s vs 11.45s on main (0% faster)

Generated by 🚫 Danger

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

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

The new option makes sense to me. Thanks for adding it!

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.

3 participants