Skip to content

Commit

Permalink
Skip checking existence of trailing comment in CommaRule if already…
Browse files Browse the repository at this point in the history
… violating

Fix #683
  • Loading branch information
norio-nomura committed Jun 8, 2016
1 parent 82fef35 commit fcd30c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
[Andrew Rahn](https://github.com/paddlefish)
[#667](https://github.com/realm/SwiftLint/issues/667)

* Fix `CommaRule` ignored some violations when trailing comment exists.
[Norio Nomura](https://github.com/norio-nomura)
[#683](https://github.com/realm/SwiftLint/issues/683)

## 0.10.0: `laundry-select` edition

##### Breaking
Expand Down
6 changes: 6 additions & 0 deletions Source/SwiftLintFramework/Rules/CommaRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public struct CommaRule: CorrectableRule, ConfigurationProviderRule {
return nil
}

// If the first range does not start with comma, it already violates this rule
// whatever is contained in the second range.
if !(contents as NSString).substringWithRange(firstRange).hasPrefix(",") {
return firstRange
}

// check second captured range
let secondRange = match.rangeAtIndex(2)
guard let matchByteSecondRange = contents
Expand Down

0 comments on commit fcd30c5

Please sign in to comment.