From 92d761374e1c22882539d47290ac5336d0ac20a6 Mon Sep 17 00:00:00 2001 From: Jamie Edge Date: Wed, 21 Dec 2016 12:37:31 +0000 Subject: [PATCH 1/9] Fix HTML output so that it is valid HTML 5. --- .../Reporters/HTMLReporter.swift | 67 +++++++++++++------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/Source/SwiftLintFramework/Reporters/HTMLReporter.swift b/Source/SwiftLintFramework/Reporters/HTMLReporter.swift index 2fb8cdb85..72503427c 100644 --- a/Source/SwiftLintFramework/Reporters/HTMLReporter.swift +++ b/Source/SwiftLintFramework/Reporters/HTMLReporter.swift @@ -45,7 +45,9 @@ public struct HTMLReporter: Reporter { "\n", "\n", "\t\n", - "\t\tSwiftlint Report\n", + "\t\t\n", + "\t\t\n", + "\t\t\n", "\t\t\n", + "\t\t\n", + "\t\tSwiftLint Report\n", "\t\n", "\t\n", - "\t\t

Swiftlint Report

\n", + "\t\t

SwiftLint Report

\n", + "\t\t\n", "\t\t
\n", + "\t\t\n", "\t\t

Violations

\n", - "\t\t\n", + "\t\t\n", + "\t\t
\n", "\t\t\t\n", "\t\t\t\t\n", "\t\t\t\t\t\n", "\t\t\t\n", rows, "\t\t\t\n", "\t\t
\n", @@ -95,9 +113,12 @@ public struct HTMLReporter: Reporter { "\t\t\t
\n", + "\t\t\n", "\t\t
\n", + "\t\t\n", "\t\t

Summary

\n", - "\t\t\n", + "\t\t\n", + "\t\t
\n", "\t\t\t\n", "\t\t\t\t\n", "\t\t\t\t\t\n", @@ -113,10 +134,14 @@ public struct HTMLReporter: Reporter { "\t\t\t\t\n", "\t\t\t\n", "\t\t
Total files with violations
\n", + "\t\t\n", "\t\t
\n", - "\t\t

Created with \n", - "\t\t\tSwiftlint\n", - "\t\t ", swiftlintVersion, " on: ", dateString, "

\n", + "\t\t\n", + "\t\t

\n", + "\t\t\tCreated with\n", + "\t\t\tSwiftLint\n", + "\t\t\t", swiftlintVersion, " on ", dateString, "\n", + "\t\t

\n", "\t\n", "" ].joined() @@ -130,10 +155,10 @@ public struct HTMLReporter: Reporter { let character: Int = location.character ?? 0 return [ "\t\t\t\t\n", - "\t\t\t\t\t\(index)\n", + "\t\t\t\t\t\(index)\n", "\t\t\t\t\t", file, "\n", - "\t\t\t\t\t\(line):\(character)\n", - "\t\t\t\t\t", severity, "\n", + "\t\t\t\t\t\(line):\(character)\n", + "\t\t\t\t\t", severity, "\n", "\t\t\t\t\t\(violation.reason.escapedForXML())\n", "\t\t\t\t\n" ].joined() From 2b5e52c229d202a01bb2fa9f9fbad4d475e27a9f Mon Sep 17 00:00:00 2001 From: Marcelo Fabri Date: Wed, 21 Dec 2016 10:37:33 -0200 Subject: [PATCH 2/9] Make `mark` rule slightly faster --- Source/SwiftLintFramework/Rules/MarkRule.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/SwiftLintFramework/Rules/MarkRule.swift b/Source/SwiftLintFramework/Rules/MarkRule.swift index eca08b333..4bdda04a0 100644 --- a/Source/SwiftLintFramework/Rules/MarkRule.swift +++ b/Source/SwiftLintFramework/Rules/MarkRule.swift @@ -54,27 +54,27 @@ public struct MarkRule: CorrectableRule, ConfigurationProviderRule { private let mark = "MARK:" private var nonSpaceOrTwoOrMoreSpace: String { - return "(\(nonSpace)|\(twoOrMoreSpace))" + return "(?:\(nonSpace)|\(twoOrMoreSpace))" } private var spaceStartPattern: String { - return "(\(nonSpaceOrTwoOrMoreSpace)\(mark))" + return "(?:\(nonSpaceOrTwoOrMoreSpace)\(mark))" } private var endNonSpacePattern: String { - return "(\(mark)\(nonSpace))" + return "(?:\(mark)\(nonSpace))" } private var endTwoOrMoreSpacePattern: String { - return "(\(mark)\(twoOrMoreSpace))" + return "(?:\(mark)\(twoOrMoreSpace))" } private var twoOrMoreSpacesAfterHyphenPattern: String { - return "(\(mark) -\(twoOrMoreSpace))" + return "(?:\(mark) -\(twoOrMoreSpace))" } private var nonSpaceOrNewlineAfterHyphenPattern: String { - return "(\(mark) -[^ \n])" + return "(?:\(mark) -[^ \n])" } private var pattern: String { From 970f29e05867a22a32ba578ebdeb464acbcb6c5d Mon Sep 17 00:00:00 2001 From: Jamie Edge Date: Wed, 21 Dec 2016 12:51:23 +0000 Subject: [PATCH 3/9] Update the HTML report colour scheme to differentiate warnings and errors. --- Source/SwiftLintFramework/Reporters/HTMLReporter.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/SwiftLintFramework/Reporters/HTMLReporter.swift b/Source/SwiftLintFramework/Reporters/HTMLReporter.swift index 72503427c..1198668be 100644 --- a/Source/SwiftLintFramework/Reporters/HTMLReporter.swift +++ b/Source/SwiftLintFramework/Reporters/HTMLReporter.swift @@ -70,15 +70,17 @@ public struct HTMLReporter: Reporter { "\t\t\t}\n", "\t\t\t\n", "\t\t\t.error, .warning {\n", - "\t\t\t\tbackground-color: #f0f099;\n", + "\t\t\t\ttext-align: center;", "\t\t\t}\n", "\t\t\t\n", "\t\t\t.error {\n", - "\t\t\t\tcolor: #ff0000;\n", + "\t\t\t\tbackground-color: #FF9D92;\n", + "\t\t\t\tcolor: #7F0800;\n", "\t\t\t}\n", "\t\t\t\n", "\t\t\t.warning {\n", - "\t\t\t\tcolor: #b36b00;\n", + "\t\t\t\tbackground-color: #FFF59E;\n", + "\t\t\t\tcolor: #7F7000;\n", "\t\t\t}\n", "\t\t\n", "\t\t\n", From daba9abbc9042c3472f5b25adbecfebf66f9bcfa Mon Sep 17 00:00:00 2001 From: Jamie Edge Date: Wed, 21 Dec 2016 13:28:07 +0000 Subject: [PATCH 4/9] Add Arial font to improve the appearance of the HTML report. --- Source/SwiftLintFramework/Reporters/HTMLReporter.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/SwiftLintFramework/Reporters/HTMLReporter.swift b/Source/SwiftLintFramework/Reporters/HTMLReporter.swift index 1198668be..615b92fe5 100644 --- a/Source/SwiftLintFramework/Reporters/HTMLReporter.swift +++ b/Source/SwiftLintFramework/Reporters/HTMLReporter.swift @@ -49,6 +49,11 @@ public struct HTMLReporter: Reporter { "\t\t\n", "\t\t\n", "\t\t + + SwiftLint Report -

Swiftlint Report

+

SwiftLint Report

+
+

Violations

- + +
- + - - + + - + - - + + - + - - + + - + - - + +
@@ -51,38 +76,41 @@
11 filename1:2Warning1:2Warning Violation Reason.
22 filename1:2Error1:2Error Violation Reason.
33 filename1:2Error1:2Error Shorthand syntactic sugar should be used, i.e. [Int] instead of Array<Int>.
44 <nopath>0:0Error0:0Error Colons should be next to the identifier when specifying a type.
+
+

Summary

- + +
@@ -98,9 +126,13 @@
Total files with violations
+
-

Created with - Swiftlint - 1.2.3 on: 13/12/2016

+ +

+ Created with + SwiftLint + 1.2.3 on 13/12/2016 +

\ No newline at end of file From 0e93d4adfe8323830997fabbd0be23e4da4d9da0 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Wed, 21 Dec 2016 10:52:20 -0800 Subject: [PATCH 8/9] add `mark` rule perf improvements to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 783fe26f9..a952f67a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ * `operator_usage_whitespace` rule is now correctable. [Marcelo Fabri](https://github.com/marcelofabri) -* `implicit_getter` rule performance improvements. +* `implicit_getter` and `mark` rule performance improvements. [Marcelo Fabri](https://github.com/marcelofabri) ##### Bug Fixes From b57691507b13c6c99a844fa398d63ae358fb4bb4 Mon Sep 17 00:00:00 2001 From: Marcelo Fabri Date: Wed, 21 Dec 2016 16:38:52 -0200 Subject: [PATCH 9/9] Fix false positive in `empty_parentheses_with_trailing_closure` rule Fixes #1021 --- CHANGELOG.md | 4 ++++ .../Rules/EmptyParenthesesWithTrailingClosureRule.swift | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 786d1acf6..cf12eb584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,10 @@ * Fix the validity and styling of the HTML reporter. [Jamie Edge](https://github.com/JamieEdge) +* Fix false positive in `empty_parentheses_with_trailing_closure` rule. + [Marcelo Fabri](https://github.com/marcelofabri) + [#1021](https://github.com/realm/SwiftLint/issues/1021) + ## 0.14.0: Super Awesome Retractable Drying Rack ##### Breaking diff --git a/Source/SwiftLintFramework/Rules/EmptyParenthesesWithTrailingClosureRule.swift b/Source/SwiftLintFramework/Rules/EmptyParenthesesWithTrailingClosureRule.swift index 35a7afb9b..d02781cfe 100644 --- a/Source/SwiftLintFramework/Rules/EmptyParenthesesWithTrailingClosureRule.swift +++ b/Source/SwiftLintFramework/Rules/EmptyParenthesesWithTrailingClosureRule.swift @@ -24,7 +24,12 @@ public struct EmptyParenthesesWithTrailingClosureRule: ASTRule, ConfigurationPro "[1, 2].map({ $0 + 1 })\n", "[1, 2].reduce(0) { $0 + $1 }", "[1, 2].map { number in\n number + 1 \n}\n", - "let isEmpty = [1, 2].isEmpty()\n" + "let isEmpty = [1, 2].isEmpty()\n", + "UIView.animateWithDuration(0.3, animations: {\n" + + " self.disableInteractionRightView.alpha = 0\n" + + "}, completion: { _ in\n" + + " ()\n" + + "})" ], triggeringExamples: [ "[1, 2].map↓() { $0 + 1 }", @@ -59,7 +64,7 @@ public struct EmptyParenthesesWithTrailingClosureRule: ASTRule, ConfigurationPro guard let range = file.contents.bridge() .byteRangeToNSRange(start: rangeStart, length: rangeLength), let match = regex.firstMatch(in: file.contents, options: [], range: range), - match.range.location != NSNotFound else { + match.range.location == range.location else { return [] }