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

fix Mark rule case // MARK: - #789

Merged
merged 2 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
The rule now enabled by default again (no longer opt-in).
[J. Cheyo Jimenez](https://github.com/masters3d)
[#772](https://github.com/realm/SwiftLint/issues/772)
* Fixed regex bug in Mark Rule where MARK could not be used with only a hyphen
but no descriptive text: `// MARK: -`
[Ruotger Deecke](https://github.com/roddi)
[#778](https://github.com/realm/SwiftLint/issues/778)

## 0.12.0: Vertical Laundry

Expand Down
5 changes: 3 additions & 2 deletions Source/SwiftLintFramework/Rules/MarkRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public struct MarkRule: ConfigurationProviderRule {
description: "MARK comment should be in valid format.",
nonTriggeringExamples: [
"// MARK: good\n",
"// MARK: - good\n"
"// MARK: - good\n",
"// MARK: -\n"
],
triggeringExamples: [
"//MARK: bad",
Expand All @@ -32,7 +33,7 @@ public struct MarkRule: ConfigurationProviderRule {
)

public func validateFile(file: File) -> [StyleViolation] {
let options = ["MARK:[^ ]", "[^ ]MARK: [^-]", "\\sMARK:[^ ]", "MARK:[ ][-][^ ]"]
let options = ["MARK:[^ ]", "[^ ]MARK: [^-]", "\\sMARK:[^ ]", "MARK:[ ][-][^\\s ]"]
let pattern = "(" + options.joinWithSeparator("|") + ")"

return file.matchPattern(pattern, withSyntaxKinds: [.Comment]).flatMap { range in
Expand Down