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

Rule Request: prefer 'joined()' over 'joined(separator: "")' #1093

Closed
jpsim opened this Issue Dec 30, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@jpsim
Collaborator

jpsim commented Dec 30, 2016

since that's the default separator.

@jpsim jpsim added the rule-request label Dec 30, 2016

jpsim added a commit that referenced this issue Dec 30, 2016

prefer 'joined()' over 'joined(separator: "")'
since that's the default separator.

Rule for this requested in #1093.
@aamctustwo

This comment has been minimized.

Show comment
Hide comment
@aamctustwo

aamctustwo Dec 31, 2016

Contributor

Does SourceKitten provide sufficient detail to make this rule more general? In other words, detect any instance where a function is being used with its default arguments.

Contributor

aamctustwo commented Dec 31, 2016

Does SourceKitten provide sufficient detail to make this rule more general? In other words, detect any instance where a function is being used with its default arguments.

@marcelofabri

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Dec 31, 2016

Collaborator

I don't think so, we'd have to keep a list with known functions and default parameters.

Collaborator

marcelofabri commented Dec 31, 2016

I don't think so, we'd have to keep a list with known functions and default parameters.

@jpsim

This comment has been minimized.

Show comment
Hide comment
@jpsim

jpsim Jan 1, 2017

Collaborator

Does SourceKitten provide sufficient detail to make this rule more general?

No, it doesn't, because binary Swift modules don't actually contain that information 😱

For example, looking at the generated interface for the Swift standard library in Xcode itself, you get this:

extension Array where Element == String {
    public func joined(separator: String = default) -> String
}

Notice the default in the place where you'd expect to see "".

I actually think (I could be wrong) that this has something to do with Swift's planned ABI stability. But I'm not sure.

Collaborator

jpsim commented Jan 1, 2017

Does SourceKitten provide sufficient detail to make this rule more general?

No, it doesn't, because binary Swift modules don't actually contain that information 😱

For example, looking at the generated interface for the Swift standard library in Xcode itself, you get this:

extension Array where Element == String {
    public func joined(separator: String = default) -> String
}

Notice the default in the place where you'd expect to see "".

I actually think (I could be wrong) that this has something to do with Swift's planned ABI stability. But I'm not sure.

ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Aug 3, 2017

Add joined_default_parameter opt-in rule
to discourage explicit use of default separator. Implements realm#1093.

ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Aug 3, 2017

Add joined_default_parameter opt-in rule
to discourage explicit usage of the default separator. Implements realm#1093.

ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Aug 3, 2017

Add joined_default_parameter opt-in rule
to discourage explicit usage of the default separator. Implements realm#1093.

ornithocoder added a commit to ornithocoder/personal-fork-swiftlint that referenced this issue Aug 3, 2017

Add joined_default_parameter opt-in rule
to discourage explicit usage of the default separator. Implements realm#1093.
@marcelofabri

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Aug 7, 2017

Collaborator

Closed by @ornithocoder in #1746 🎉

Collaborator

marcelofabri commented Aug 7, 2017

Closed by @ornithocoder in #1746 🎉

marcelofabri added a commit that referenced this issue Aug 17, 2017

Add joined_default_parameter opt-in rule
to discourage explicit usage of the default separator. Implements #1093.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment