8000 [SwiftLint] Set trailing_comma's mandatory_comma option to true by ikesyo · Pull Request #974 · Quick/Quick · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[SwiftLint] Set trailing_comma's mandatory_comma option to true #974

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

Merged
merged 1 commit into from
May 26, 2020
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
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ included:
line_length:
warning: 160
error: 240

trailing_comma:
mandatory_comma: true
32 changes: 18 additions & 14 deletions Sources/Quick/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ public typealias ExampleFilter = (_ example: Example) -> Bool
final public class Configuration: NSObject {
internal let exampleHooks = ExampleHooks()
internal let suiteHooks = SuiteHooks()
internal var exclusionFilters: [ExampleFilter] = [ { example in
if let pending = example.filterFlags[Filter.pending] {
return pending
} else {
return false
}
}]
internal var inclusionFilters: [ExampleFilter] = [ { example in
if let focused = example.filterFlags[Filter.focused] {
return focused
} else {
return false
}
}]
internal var exclusionFilters: [ExampleFilter] = [
{ example in // swiftlint:disable:this opening_brace
if let pending = example.filterFlags[Filter.pending] {
return pending
} else {
return false
}
},
]
internal var inclusionFilters: [ExampleFilter] = [
{ example in // swiftlint:disable:this opening_brace
if let focused = example.filterFlags[Filter.focused] {
return focused
} else {
return false
}
},
]

/**
Run all examples if none match the configured filters. True by default.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Quick/String+C99ExtendedIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension String {
.controlCharacters,
.punctuationCharacters,
.nonBaseCharacters,
.symbols
.symbols,
]

for invalidSet in invalidCharacterSets {
Expand Down
6 changes: 3 additions & 3 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Quick.QCKMain([
FunctionalTests_SharedExamples_ContextSpec.self,
FunctionalTests_SharedExamples_Spec.self,
_FunctionalTests_FocusedSpec_Focused.self,
_FunctionalTests_FocusedSpec_Unfocused.self
_FunctionalTests_FocusedSpec_Unfocused.self,
],
configurations: [
FunctionalTests_Configuration_AfterEach.self,
FunctionalTests_Configuration_BeforeEach.self,
FunctionalTests_FocusedSpec_SharedExamplesConfiguration.self,
FunctionalTests_SharedExamples_BeforeEachTests_SharedExamples.self,
FunctionalTests_SharedExamplesTests_SharedExamples.self
FunctionalTests_SharedExamplesTests_SharedExamples.self,
],
testCases: [
testCase(AfterEachTests.allTests),
Expand All @@ -42,5 +42,5 @@ testCases: [
testCase(ItTests.allTests),
testCase(PendingTests.allTests),
testCase(SharedExamples_BeforeEachTests.allTests),
testCase(SharedExamplesTests.allTests)
testCase(SharedExamplesTests.allTests),
])
4 changes: 2 additions & 2 deletions Tests/QuickTests/QuickFocusedTests/FocusedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ class _FunctionalTests_FocusedSpec_Unfocused: QuickSpec {
final class FocusedTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (FocusedTests) -> () throws -> Void)] {
return [
("testOnlyFocusedExamplesAreExecuted", testOnlyFocusedExamplesAreExecuted)
("testOnlyFocusedExamplesAreExecuted", testOnlyFocusedExamplesAreExecuted),
]
}

func testOnlyFocusedExamplesAreExecuted() {
let result = qck_runSpecs([
_FunctionalTests_FocusedSpec_Focused.self,
_FunctionalTests_FocusedSpec_Unfocused.self
_FunctionalTests_FocusedSpec_Unfocused.self,
])
XCTAssertEqual(result?.executionCount, 8)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class FunctionalTests_AfterEachSpec: QuickSpec {
// The list should contain the afterEach for those example, executed from top to bottom.
expect(afterEachOrder).to(equal([
.outerOne, .outerTwo, .outerThree,
.outerOne, .outerTwo, .outerThree
]))
.outerOne, .outerTwo, .outerThree,
]))
}
}

Expand All @@ -68,7 +68,7 @@ class FunctionalTests_AfterEachSpec: QuickSpec {
final class AfterEachTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (AfterEachTests) -> () throws -> Void)] {
return [
("testAfterEachIsExecutedInTheCorrectOrder", testAfterEachIsExecutedInTheCorrectOrder)
("testAfterEachIsExecutedInTheCorrectOrder", testAfterEachIsExecutedInTheCorrectOrder),
]
}

Expand All @@ -83,7 +83,7 @@ final class AfterEachTests: XCTestCase, XCTestCaseProvider {
.outerOne, .outerTwo, .outerThree,
// [3] The inner afterEach closures are executed from top to bottom,
// then the outer afterEach closures are executed from top to bottom.
.innerOne, .innerTwo, .outerOne, .outerTwo, .outerThree
.innerOne, .innerTwo, .outerOne, .outerTwo, .outerThree,
]
XCTAssertEqual(afterEachOrder, expectedOrder)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FunctionalTests_BeforeEachSpec: QuickSpec {
final class BeforeEachTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (BeforeEachTests) -> () throws -> Void)] {
return [
("testBeforeEachIsExecutedInTheCorrectOrder", testBeforeEachIsExecutedInTheCorrectOrder)
("testBeforeEachIsExecutedInTheCorrectOrder", testBeforeEachIsExecutedInTheCorrectOrder),
]
}

Expand All @@ -68,7 +68,7 @@ final class BeforeEachTests: XCTestCase, XCTestCaseProvider {
.outerOne, .outerTwo,
// [3] The outer beforeEach closures are executed from top to bottom,
// then the inner beforeEach closures are executed from top to bottom.
.outerOne, .outerTwo, .innerOne, .innerTwo, .innerThree
.outerOne, .outerTwo, .innerOne, .innerTwo, .innerThree,
]
XCTAssertEqual(beforeEachOrder, expectedOrder)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class FunctionalTests_BeforeSuite_Spec: QuickSpec {
final class BeforeSuiteTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (BeforeSuiteTests) -> () throws -> Void)] {
return [
("testBeforeSuiteIsExecutedBeforeAnyExamples", testBeforeSuiteIsExecutedBeforeAnyExamples)
("testBeforeSuiteIsExecutedBeforeAnyExamples", testBeforeSuiteIsExecutedBeforeAnyExamples),
]
}

func testBeforeSuiteIsExecutedBeforeAnyExamples() {
// Execute the spec with an assertion before the one with a beforeSuite
let result = qck_runSpecs([
FunctionalTests_BeforeSuite_Spec.self,
FunctionalTests_BeforeSuite_BeforeSuiteSpec.self
])
FunctionalTests_BeforeSuite_BeforeSuiteSpec.self,
])

XCTAssert(result!.hasSucceeded)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ final class BehaviorTests: XCTestCase, XCTestCaseProvider {

static var allTests: [(String, (BehaviorTests) -> () throws -> Void)] {
return [
("testBehaviorPassContextToExamples",
testBehaviorPassContextToExamples),
("testBehaviorExecutesThreeExamples",
testBehaviorExecutesThreeExamples)
("testBehaviorPassContextToExamples", testBehaviorPassContextToExamples),
("testBehaviorExecutesThreeExamples", testBehaviorExecutesThreeExamples),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Configuration_AfterEachSpec: QuickSpec {
final class Configuration_AfterEachTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (Configuration_AfterEachTests) -> () throws -> Void)] {
return [
("testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted", testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted)
("testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted", testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Configuration_BeforeEachSpec: QuickSpec {
final class Configuration_BeforeEachTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (Configuration_BeforeEachTests) -> () throws -> Void)] {
return [
("testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted", testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted)
("testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted", testExampleIsRunAfterTheConfigurationBeforeEachIsExecuted),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Quick
final class DescribeTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (DescribeTests) -> () throws -> Void)] {
return [
("testDescribeThrowsIfUsedOutsideOfQuickSpec", testDescribeThrowsIfUsedOutsideOfQuickSpec)
("testDescribeThrowsIfUsedOutsideOfQuickSpec", testDescribeThrowsIfUsedOutsideOfQuickSpec),
]
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/QuickTests/QuickTests/FunctionalTests/ItTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FunctionalTests_ItSpec: QuickSpec {

expect(allSelectors) == [
"when_an_example_has_a_unique_name__doesn_t_add_multiple_selectors_for_it",
"when_an_example_has_a_unique_name__has_a_unique_name"
"when_an_example_has_a_unique_name__has_a_unique_name",
]
}
}
Expand All @@ -46,7 +46,7 @@ class FunctionalTests_ItSpec: QuickSpec {
expect(allSelectors) == [
"when_two_examples_have_the_exact_name__has_exactly_the_same_name",
"when_two_examples_have_the_exact_name__has_exactly_the_same_name_2",
"when_two_examples_have_the_exact_name__makes_a_unique_name_for_each_of_the_above"
"when_two_examples_have_the_exact_name__makes_a_unique_name_for_each_of_the_above",
]
}

Expand Down Expand Up @@ -110,7 +110,7 @@ class FunctionalTests_ItSpec: QuickSpec {
final class ItTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (ItTests) -> () throws -> Void)] {
return [
("testAllExamplesAreExecuted", testAllExamplesAreExecuted)
("testAllExamplesAreExecuted", testAllExamplesAreExecuted),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class PendingTests: XCTestCase, XCTestCaseProvider {
return [
("testAnOtherwiseFailingExampleWhenMarkedPendingDoesNotCauseTheSuiteToFail", testAnOtherwiseFailingExampleWhenMarkedPendingDoesNotCauseTheSuiteToFail),
("testBeforeEachOnlyRunForEnabledExamples", testBeforeEachOnlyRunForEnabledExamples),
("testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples", testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples)
("testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples", testBeforeEachDoesNotRunForContextsWithOnlyPendingExamples),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class SharedExamples_BeforeEachTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (SharedExamples_BeforeEachTests) -> () throws -> Void)] {
return [
("testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample", testBeforeEachOutsideOfSharedExamplesExecutedOnceBeforeEachExample),
("testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample", testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample)
("testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample", testBeforeEachInSharedExamplesExecutedOnceBeforeEachSharedExample),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class SharedExamplesTests: XCTestCase, XCTestCaseProvider {
static var allTests: [(String, (SharedExamplesTests) -> () throws -> Void)] {
return [
("testAGroupOfThreeSharedExamplesExecutesThreeExamples", testAGroupOfThreeSharedExamplesExecutesThreeExamples),
("testSharedExamplesWithContextPassContextToExamples", testSharedExamplesWithContextPassContextToExamples)
("testSharedExamplesWithContextPassContextToExamples", testSharedExamplesWithContextPassContextToExamples),
]
}

Expand Down
0