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

Possible closure_end_indentation rule issue #2121

Closed
2 tasks done
erichoracek opened this issue Mar 29, 2018 · 2 comments
Closed
2 tasks done

Possible closure_end_indentation rule issue #2121

erichoracek opened this issue Mar 29, 2018 · 2 comments

Comments

@erichoracek
Copy link
Contributor

erichoracek commented Mar 29, 2018

New Issue Checklist

Rule issue

I'm wondering whether the following code should be triggering the closure_end_indentation rule to fail (it currently doesn't):

function(
  parameter: a,
  closure: { x in
    // code
},
  anotherClosure: {
    // code
})

To me, this reads as a violation of the rule: since the closure's opening brace is on a line with one level of indentation, it seems like the closing brace should have the same level of indentation. The rule reads as follows:

"Closure end should have the same indentation as the line that started it.

My assumption from reading the rule is that the following code would satisfy it:

function(
  parameter: a,
  closure: { x in
    // code
  },
  anotherClosure: {
    // code
  })

From this, it would appear that currently, the rule treats "the line that started it" as the start of the function declaration, rather than the line on which the opening brace is located.

What do you think? Thanks in advance! cc @marcelofabri

@jpsim
Copy link
Collaborator

jpsim commented Apr 23, 2018

I agree with this, I'd consider the existing behavior to be a bug and the correct way to address is to fix the existing behavior, no need to create a new rule or configuration point.

@erichoracek
Copy link
Contributor Author

erichoracek commented Apr 23, 2018

@jpsim great to hear! I put up #2132 to update this rule to lint against this case. Thanks in advance for taking a look!

erichoracek added a commit to erichoracek/SwiftLint that referenced this issue Apr 30, 2018
erichoracek added a commit to erichoracek/SwiftLint that referenced this issue May 5, 2018
erichoracek added a commit to erichoracek/SwiftLint that referenced this issue May 6, 2018
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

No branches or pull requests

2 participants