Skip to content

Commit

Permalink
Enable SwiftFormat rule "blankLinesAtStartOfScope"
Browse files Browse the repository at this point in the history
  • Loading branch information
jonreid committed Mar 20, 2018
1 parent 69e0420 commit e7507c6
Show file tree
Hide file tree
Showing 25 changed files with 1 addition and 44 deletions.
2 changes: 1 addition & 1 deletion Hamcrest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "${SRCROOT}/bin/swiftformat --disable blankLinesAtStartOfScope,indent,numberFormatting,ranges,redundantReturn,spaceAroundOperators,spaceInsideBraces,strongOutlets,trailingCommas,unusedArguments,void ${SRCROOT}\n";
shellScript = "${SRCROOT}/bin/swiftformat --disable indent,numberFormatting,ranges,redundantReturn,spaceAroundOperators,spaceInsideBraces,strongOutlets,trailingCommas,unusedArguments,void ${SRCROOT}\n";
};
481906251ED69B6500E47930 /* Swift Format */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
3 changes: 0 additions & 3 deletions Hamcrest/DictionaryMatchers.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
public func hasEntry<K, V>(_ keyMatcher: Matcher<K>, _ valueMatcher: Matcher<V>)
-> Matcher<Dictionary<K, V>> {

return Matcher("a dictionary containing [\(keyMatcher.description) -> \(valueMatcher.description)]") {
(dictionary: Dictionary<K, V>) -> Bool in

Expand All @@ -15,7 +14,6 @@ public func hasEntry<K, V>(_ keyMatcher: Matcher<K>, _ valueMatcher: Matcher<V>)

public func hasEntry<K, V: Equatable>(_ expectedKey: K, _ expectedValue: V)
-> Matcher<Dictionary<K, V>> {

return hasEntry(equalToWithoutDescription(expectedKey), equalToWithoutDescription(expectedValue))
}

Expand All @@ -25,7 +23,6 @@ public func hasKey<K, V>(_ matcher: Matcher<K>) -> Matcher<Dictionary<K, V>> {

public func hasKey<K, V>(_ expectedKey: K)
-> Matcher<Dictionary<K, V>> {

return hasKey(equalToWithoutDescription(expectedKey))
}

Expand Down
1 change: 0 additions & 1 deletion Hamcrest/Hamcrest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func isPlayground() -> Bool {

func reportResult(_ possibleResult: String?, file: StaticString = #file, line: UInt = #line)
-> String {

if let result = possibleResult {
HamcrestReportFunction(result, file, line)
return result
Expand Down
1 change: 0 additions & 1 deletion Hamcrest/MatchResult.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
public enum MatchResult: ExpressibleByBooleanLiteral {

case match
case mismatch(String?)

Expand Down
1 change: 0 additions & 1 deletion Hamcrest/Matcher.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
public struct Matcher<T> {

public let description: String
let f: (T) -> MatchResult

Expand Down
1 change: 0 additions & 1 deletion Hamcrest/OperatorMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public func <= <T: Comparable>(value: T, expectedValue: T) -> MatchResultDescrip

public func && (lhs: MatchResultDescription, rhs: MatchResultDescription)
-> MatchResultDescription {

switch (lhs.result, rhs.result) {
case (nil, nil):
return MatchResultDescription(result: .none)
Expand Down
13 changes: 0 additions & 13 deletions Hamcrest/SequenceMatchers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public func hasCount<T: Collection>(_ expectedCount: T.IndexDistance) -> Matcher

public func everyItem<T, S: Sequence>(_ matcher: Matcher<T>)
-> Matcher<S> where S.Iterator.Element == T {

return Matcher("a sequence where every item \(matcher.description)") {
(values: S) -> MatchResult in
var mismatchDescriptions: [String?] = []
Expand Down Expand Up @@ -49,21 +48,18 @@ private func hasItem<T, S: Sequence>(_ matcher: Matcher<T>,

public func hasItem<T, S: Sequence>(_ matcher: Matcher<T>)
-> Matcher<S> where S.Iterator.Element == T {

return Matcher("a sequence containing \(matcher.description)") {
(values: S) -> Bool in hasItem(matcher, values)
}
}

public func hasItem<T: Equatable, S: Sequence>(_ expectedValue: T)
-> Matcher<S> where S.Iterator.Element == T {

return hasItem(equalToWithoutDescription(expectedValue))
}

private func hasItems<T, S: Sequence>(_ matchers: [Matcher<T>])
-> Matcher<S> where S.Iterator.Element == T {

return Matcher("a sequence containing \(joinMatcherDescriptions(matchers))") {
(values: S) -> MatchResult in
var missingItems = [] as [Matcher<T>]
Expand All @@ -85,19 +81,16 @@ private func hasItems<T, S: Sequence>(_ matchers: [Matcher<T>])

public func hasItems<T, S: Sequence>(_ matchers: Matcher<T>...)
-> Matcher<S> where S.Iterator.Element == T {

return hasItems(matchers)
}

public func hasItems<T: Equatable, S: Sequence>
(_ expectedValues: T...) -> Matcher<S> where S.Iterator.Element == T {

return hasItems(expectedValues.map {equalToWithoutDescription($0)})
}

private func contains<T, S: Sequence>(_ matchers: [Matcher<T>])
-> Matcher<S> where S.Iterator.Element == T {

return Matcher("a sequence containing " + joinDescriptions(matchers.map({$0.description}))) {
(values: S) -> MatchResult in
return applyMatchers(matchers, values: values)
Expand All @@ -106,19 +99,16 @@ private func contains<T, S: Sequence>(_ matchers: [Matcher<T>])

public func contains<T, S: Sequence>(_ matchers: Matcher<T>...)
-> Matcher<S> where S.Iterator.Element == T {

return contains(matchers)
}

public func contains<T: Equatable, S: Sequence>
(_ expectedValues: T...) -> Matcher<S> where S.Iterator.Element == T {

return contains(expectedValues.map {equalToWithoutDescription($0)})
}

private func containsInAnyOrder<T, S: Sequence>
(_ matchers: [Matcher<T>]) -> Matcher<S> where S.Iterator.Element == T {

let descriptions = joinDescriptions(matchers.map({$0.description}))

return Matcher("a sequence containing in any order " + descriptions) {
Expand Down Expand Up @@ -150,19 +140,16 @@ private func containsInAnyOrder<T, S: Sequence>

public func containsInAnyOrder<T, S: Sequence>
(_ matchers: Matcher<T>...) -> Matcher<S> where S.Iterator.Element == T {

return containsInAnyOrder(matchers)
}

public func containsInAnyOrder<T: Equatable, S: Sequence>
(_ expectedValues: T...) -> Matcher<S> where S.Iterator.Element == T {

return containsInAnyOrder(expectedValues.map {equalToWithoutDescription($0)})
}

func applyMatchers<T, S: Sequence>
(_ matchers: [Matcher<T>], values: S) -> MatchResult where S.Iterator.Element == T {

var mismatchDescriptions: [String?] = []

var i = 0
Expand Down
1 change: 0 additions & 1 deletion HamcrestDemo-macOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Cocoa

class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!

func applicationDidFinishLaunching(_ aNotification: Notification) {
Expand Down
1 change: 0 additions & 1 deletion HamcrestDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Expand Down
1 change: 0 additions & 1 deletion HamcrestDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Expand Down
1 change: 0 additions & 1 deletion HamcrestDemoTests-macOS/HamcrestDemoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Hamcrest
import XCTest

class HamcrestDemoTests: XCTestCase {

// Look at README.playground for a tutorial.

func testSuccess() {
Expand Down
1 change: 0 additions & 1 deletion HamcrestDemoTests/HamcrestDemoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class HamcrestDemoTests: XCTestCase {

override func setUp() {
super.setUp()
HamcrestReportFunction = {message, file, line in XCTFail(message, file:file, line:line)}
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/ArithmeticMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class ArithmeticMatcherTests: BaseTestCase {

func testEqualTo() {
assertMatch(5, equalTo(5))
assertMismatch(5, equalTo(10), "equal to 10")
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/AssertThatTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class AssertThatTests: BaseTestCase {

func testMatcherWithBoolReturningTrue() {
let matcher = Matcher<Int>("") {value in true}

Expand Down
4 changes: 0 additions & 4 deletions HamcrestTests/BaseTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class BaseTestCase: XCTestCase {

var reportedError: String?

override func setUp() {
Expand All @@ -25,7 +24,6 @@ class BaseTestCase: XCTestCase {
func assertMismatch<T>(_ value: T, _ matcher: Matcher<T>, _ description: String,
mismatchDescription: String? = nil,
file: StaticString = #file, line: UInt = #line) {

reportedError = nil
assertThat(value, matcher)
if let mismatchDescription = mismatchDescription {
Expand All @@ -38,7 +36,6 @@ class BaseTestCase: XCTestCase {
func assertMismatch<T>(_ value: [T], _ matcher: Matcher<[T]>, _ description: String,
mismatchDescription: String? = nil,
file: StaticString = #file, line: UInt = #line) {

reportedError = nil
assertThat(value, matcher)
if let mismatchDescription = mismatchDescription {
Expand All @@ -65,7 +62,6 @@ class BaseTestCase: XCTestCase {

private func expectedMessage(_ value: Any, _ description: String, mismatchDescription: String?)
-> String {

let inset = (mismatchDescription.map {" (\($0))"} ?? "")
return "GOT: \(valueDescription(value))\(inset), EXPECTED: \(description)"
}
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/BasicMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ private func address<T: AnyObject>(_ object: T) -> String {
}

class BasicMatcherTests: BaseTestCase {

func testAnything() {
assertMatch(5, anything())
}
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/DictionaryMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class DictionaryMatcherTests: BaseTestCase {

let dictionary = [
"key1": "value1",
"key2": "value2",
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/ErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class ErrorTests: BaseTestCase {

func testThrownError() {
let matcher = Matcher<Int>("") {value in true}

Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/MatchResultTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class MatchResultTests: XCTestCase {

func testInitBooleanLiteralTrue() {
let matchResult: MatchResult = true

Expand Down
3 changes: 0 additions & 3 deletions HamcrestTests/MatcherMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import XCTest

func succeedingMatcher<T: Equatable>(_ expectingValue: T, description: String = "description",
file: StaticString = #file, line: UInt = #line) -> Matcher<T> {

return Matcher<T>(description) {
(value: T) -> Bool in
XCTAssertEqual(value, expectingValue, file: file, line: line)
Expand All @@ -13,13 +12,11 @@ func succeedingMatcher<T: Equatable>(_ expectingValue: T, description: String =

func succeedingMatcher<T>(_ type: T.Type = T.self, description: String = "description")
-> Matcher<T> {

return Matcher<T>(description) {value in true}
}

func failingMatcher<T>(_ type: T.Type = T.self, description: String = "description",
mismatchDescription: String? = nil) -> Matcher<T> {

return Matcher<T>(description) {value in .mismatch(mismatchDescription)}
}

Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/MetaMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class MetaMatcherTests: BaseTestCase {

func testIs() {
assertMatch(5, `is`(succeedingMatcher()))
assertMismatch(5, `is`(failingMatcher()), "is description")
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/OperatorMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ private func address<T: AnyObject>(_ object: T) -> String {
}

class OperatorMatcherTests: BaseTestCase {

func testSameInstance() {
let object = SampleClass()
assertThat(object === object)
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/ReflectionMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ private class ReflectableClass {
}

class ReflectionMatcherTests: BaseTestCase {

fileprivate let instance = ReflectableClass()

func testHasProperty() {
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/SequenceMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class SequenceMatcherTests: BaseTestCase {

let sequence = ["item1", "item2", "item3"]

func testEmpty() {
Expand Down
1 change: 0 additions & 1 deletion HamcrestTests/StringMatcherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Hamcrest
import XCTest

class StringTests: BaseTestCase {

let string = "foobar"

func testContainsString() {
Expand Down

0 comments on commit e7507c6

Please sign in to comment.