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

Line length and [String: SourceKitRepresentable] #1008

Closed
marcelofabri opened this issue Dec 20, 2016 · 3 comments
Closed

Line length and [String: SourceKitRepresentable] #1008

marcelofabri opened this issue Dec 20, 2016 · 3 comments
Labels
enhancement Ideas for improvements of existing features and rules.

Comments

@marcelofabri
Copy link
Collaborator

Our current line length limit is 100, which makes creating functions that receives [String: SourceKitRepresentable] as parameter hard, since it's a long (33-char) type.

For example, how should one format this method?

    fileprivate func dictionaryViolations(in file: File,
                                          dictionary: [String: SourceKitRepresentable])
                                                                                    -> [NSRange] {

I find myself using worse choices of name method names or weird formatting because of this limit. I propose we should either (or both 😛):

  1. Increase the limit a bit, to 120 for example.
  2. Create a typealias SouceKitDictionary = [String: SourceKitRepresentable] to save 11 characters.

Thoughts?

@marcelofabri marcelofabri added the enhancement Ideas for improvements of existing features and rules. label Dec 20, 2016
@jpsim
Copy link
Collaborator

jpsim commented Dec 20, 2016

I'd say we could definitely increase of the default even to 120. A quick GitHub search of SwiftLint configurations appears to show that this is a very common value. People have been suggesting this for a very long time and I think we better get with the times. See #28

@mattrubin
Copy link
Contributor

mattrubin commented Dec 20, 2016

I agree with the proposal to extend the default line length limit to 120 characters. I've noticed, though, that the lines that most often exceeded the previous limit of 100 and which were the ugliest to try to wrap were lines containing function declarations (as in the example above). Would it be possible to not apply the line length rule on function declaration lines, and trust that function_parameter_count and other rules will keep the function declarations to a reasonable length?

Edit: I realize now that the original issue here was asking what to do about line length in SwiftLint's own source, and my proposal relates to line length as enforced by SwiftLint's rules. I'm happy to file this proposal as a separate issue, if that's preferable.

@jpsim
Copy link
Collaborator

jpsim commented Dec 20, 2016

That's a good idea, and it's the direction that #975 is going in, so no need to file a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

3 participants