Skip to content

Commit

Permalink
Merge commit 'ad019afd7124c07ef34fb22e6165976116202477' into swift3.0
Browse files Browse the repository at this point in the history
* commit 'ad019afd7124c07ef34fb22e6165976116202477':
  move #872 fix to appropriate changelog section
  closure_spacing accepts empty bodies with a space

# Conflicts:
#	Source/SwiftLintFramework/Rules/ClosureSpacingRule.swift
  • Loading branch information
norio-nomura committed Nov 30, 2016
2 parents b94f2cc + ad019af commit 06e0e83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
[Marcelo Fabri](https://github.com/marcelofabri)
[#881](https://github.com/realm/SwiftLint/issues/881)

##### Bug Fixes
* `closure_spacing` rule now accepts empty bodies with a space.
[Marcelo Fabri](https://github.com/marcelofabri)
[#875](https://github.com/realm/SwiftLint/issues/875)

##### Bug Fixes

* Fix a few edge cases where malformed `MARK:` comments wouldn't trigger a
violation.
Expand All @@ -52,11 +55,15 @@
* `switch_case_on_newline` rule should ignore trailing comments.
[Marcelo Fabri](https://github.com/marcelofabri)
[#874](https://github.com/realm/SwiftLint/issues/874)

* `switch_case_on_newline` rule shouldn't trigger on enums.
[Marcelo Fabri](https://github.com/marcelofabri)
[#878](https://github.com/realm/SwiftLint/issues/878)

* Fix regex bug in Comma Rule causing some violations to not be triggered
when there were consecutive violations in the same expression.
[Savio Figueiredo](https://github.com/sadefigu)
[#872](https://github.com/realm/SwiftLint/issues/872)

## 0.13.0: MakeYourClothesCleanAgain

Expand Down Expand Up @@ -155,11 +162,6 @@
[Norio Nomura](https://github.com/norio-nomura)
[#813](https://github.com/realm/SwiftLint/issues/813)

* Fixed regex bug in Comma Rule. Some violations were not being triggered
when there were consecutive violations in the same expression.
[Savio Figueiredo](https://github.com/sadefigu)
[#872](https://github.com/realm/SwiftLint/issues/872)

## 0.12.0: Vertical Laundry

##### Breaking
Expand Down
9 changes: 7 additions & 2 deletions Source/SwiftLintFramework/Rules/ClosureSpacingRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public struct ClosureSpacingRule: Rule, ConfigurationProviderRule, OptInRule {
description: "Closure expressions should have a single space inside each brace.",
nonTriggeringExamples: [
"[].map ({ $0.description })",
"[].filter { $0.contains(location) }"
"[].filter { $0.contains(location) }",
"extension UITableViewCell: ReusableView { }",
"extension UITableViewCell: ReusableView {}"
],
triggeringExamples: [
"[].filter({$0.contains(location)})",
Expand Down Expand Up @@ -93,7 +95,10 @@ public struct ClosureSpacingRule: Rule, ConfigurationProviderRule, OptInRule {
var violationRanges = matchedUpBraces.filter {
// removes enclosing brances to just content
let content = file.contents.substring($0.location + 1, length: $0.length - 2)
if content.isEmpty { return false } // case when {} is not a closure
if content.isEmpty || content == " " {
// case when {} is not a closure
return false
}
let cleaned = content.trimmingCharacters(in: .whitespaces)
return content != " " + cleaned + " "
}
Expand Down

0 comments on commit 06e0e83

Please sign in to comment.