Skip to content

Commit

Permalink
[ClosureEndIndentationRule] Fix crash with Swift 5.6 (realm#3831)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim authored and Ryan Cole committed Feb 19, 2022
1 parent b09caa3 commit 374f202
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#### Bug Fixes

* None.
* Fix crash in the `closure_end_indentation` rule when linting with Swift 5.6.
[JP Simard](https://github.com/jpsim)
[#3830](https://github.com/realm/SwiftLint/issues/3830)

## 0.46.2: Detergent Package

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ extension ClosureEndIndentationRule {
let firstArgumentOffset = firstArgument.offset,
case let offset = nameOffset + nameLength,
case let length = firstArgumentOffset - offset,
length > 0,
case let byteRange = ByteRange(location: offset, length: length),
let range = file.stringView.byteRangeToNSRange(byteRange),
let match = regex("\\(\\s*\\n\\s*").firstMatch(in: file.contents, options: [], range: range)?.range,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ internal struct ClosureEndIndentationRuleExamples {
" },\n" +
" anotherClosure: { y in\n" +
" print(y)\n" +
" })")
" })"),
Example("(-variable).foo()")
]

static let triggeringExamples = [
Expand Down

0 comments on commit 374f202

Please sign in to comment.