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

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

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

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

jpsim opened this issue Dec 30, 2016 · 4 comments
Labels
rule-request Requests for a new rules.

Comments

@jpsim
Copy link
Collaborator

jpsim commented Dec 30, 2016

since that's the default separator.

@jpsim jpsim added the rule-request Requests for a new rules. label Dec 30, 2016
jpsim added a commit that referenced this issue Dec 30, 2016
since that's the default separator.

Rule for this requested in #1093.
@ghost
Copy link

ghost 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
Copy link
Collaborator

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

@jpsim
Copy link
Collaborator Author

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
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
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
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
to discourage explicit usage of the default separator. Implements realm#1093.
@marcelofabri
Copy link
Collaborator

Closed by @ornithocoder in #1746 🎉

marcelofabri pushed a commit that referenced this issue Aug 17, 2017
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
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

2 participants