8000 [SwiftLint] Enable line_length rule by ikesyo · Pull Request #970 · Quick/Quick · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[SwiftLint] Enable line_length rule #970

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 21, 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
5 changes: 4 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
disabled_rules:
- line_length
included:
- Sources
- Tests

line_length:
warning: 160
error: 240
6 changes: 2 additions & 4 deletions Sources/Quick/Behavior.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
A `Behavior` encapsulates a set of examples that can be re-used in several locations using the `itBehavesLike` function with a context instance of the generic type.
*/

/// A `Behavior` encapsulates a set of examples that can be re-used in several locations using the `itBehavesLike`
/// function with a context instance of the generic type.
open class Behavior<Context> {

/**
Expand Down
4 changes: 4 additions & 0 deletions Sources/Quick/DSL/DSL.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// swiftlint:disable line_length

/**
Defines a closure to be run prior to any examples in the test suite.
You may define an unlimited number of these closures, but there is no
Expand Down Expand Up @@ -269,3 +271,5 @@ public func fitBehavesLike(_ name: String, flags: FilterFlags = [:], file: FileS
public func fitBehavesLike<C>(_ behavior: Behavior<C>.Type, flags: FilterFlags = [:], file: FileString = #file, line: UInt = #line, context: @escaping () -> C) {
World.sharedWorld.fitBehavesLike(behavior, context: context, flags: flags, file: file, line: line)
}

// swiftlint:enable line_length
19 changes: 10 additions & 9 deletions Sources/Quick/DSL/World+DSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ extension World {

internal func describe(_ description: String, flags: FilterFlags, closure: () -> Void) {
guard currentExampleMetadata == nil else {
raiseError("'describe' cannot be used inside '\(currentPhase)', 'describe' may only be used inside 'context' or 'describe'. ")
raiseError("'describe' cannot be used inside '\(currentPhase)', 'describe' may only be used inside 'context' or 'describe'.")
}
guard currentExampleGroup != nil else {
// swiftlint:disable:next line_length
raiseError("Error: example group was not created by its parent QuickSpec spec. Check that describe() or context() was used in QuickSpec.spec() and not a more general context (i.e. an XCTestCase test)")
}
let group = ExampleGroup(description: description, flags: flags)
Expand All @@ -32,7 +33,7 @@ extension World {

internal func context(_ description: String, flags: FilterFlags, closure: () -> Void) {
guard currentExampleMetadata == nil else {
raiseError("'context' cannot be used inside '\(currentPhase)', 'context' may only be used inside 'context' or 'describe'. ")
raiseError("'context' cannot be used inside '\(currentPhase)', 'context' may only be used inside 'context' or 'describe'.")
}
self.describe(description, flags: flags, closure: closure)
}
Expand All @@ -51,7 +52,7 @@ extension World {

internal func beforeEach(_ closure: @escaping BeforeExampleClosure) {
guard currentExampleMetadata == nil else {
raiseError("'beforeEach' cannot be used inside '\(currentPhase)', 'beforeEach' may only be used inside 'context' or 'describe'. ")
raiseError("'beforeEach' cannot be used inside '\(currentPhase)', 'beforeEach' may only be used inside 'context' or 'describe'.")
}
currentExampleGroup.hooks.appendBefore(closure)
}
Expand All @@ -69,7 +70,7 @@ extension World {

internal func afterEach(_ closure: @escaping AfterExampleClosure) {
guard currentExampleMetadata == nil else {
raiseError("'afterEach' cannot be used inside '\(currentPhase)', 'afterEach' may only be used inside 'context' or 'describe'. ")
raiseError("'afterEach' cannot be used inside '\(currentPhase)', 'afterEach' may only be used inside 'context' or 'describe'.")
}
currentExampleGroup.hooks.appendAfter(closure)
}
Expand All @@ -88,13 +89,13 @@ extension World {
@nonobjc
internal func it(_ description: String, flags: FilterFlags, file: FileString, line: UInt, closure: @escaping () -> Void) {
if beforesCurrentlyExecuting {
raiseError("'it' cannot be used inside 'beforeEach', 'it' may only be used inside 'context' or 'describe'. ")
raiseError("'it' cannot be used inside 'beforeEach', 'it' may only be used inside 'context' or 'describe'.")
}
if aftersCurrentlyExecuting {
raiseError("'it' cannot be used inside 'afterEach', 'it' may only be used inside 'context' or 'describe'. ")
raiseError("'it' cannot be used inside 'afterEach', 'it' may only be used inside 'context' or 'describe'.")
}
guard currentExampleMetadata == nil else {
raiseError("'it' cannot be used inside 'it', 'it' may only be used inside 'context' or 'describe'. ")
raiseError("'it' cannot be used inside 'it', 'it' may only be used inside 'context' or 'describe'.")
}
let callsite = Callsite(file: file, line: line)
let example = Example(description: description, callsite: callsite, flags: flags, closure: closure)
Expand All @@ -118,7 +119,7 @@ extension World {
@nonobjc
internal func itBehavesLike(_ name: String, sharedExampleContext: @escaping SharedExampleContext, flags: FilterFlags, file: FileString, line: UInt) {
guard currentExampleMetadata == nil else {
raiseError("'itBehavesLike' cannot be used inside '\(currentPhase)', 'itBehavesLike' may only be used inside 'context' or 'describe'. ")
raiseError("'itBehavesLike' cannot be used inside '\(currentPhase)', 'itBehavesLike' may only be used inside 'context' or 'describe'.")
}
let callsite = Callsite(file: file, line: line)
let closure = World.sharedWorld.sharedExample(name)
Expand All @@ -144,7 +145,7 @@ extension World {

internal func itBehavesLike<C>(_ behavior: Behavior<C>.Type, context: @escaping () -> C, flags: FilterFlags, file: FileString, line: UInt) {
guard currentExampleMetadata == nil else {
raiseError("'itBehavesLike' cannot be used inside '\(currentPhase)', 'itBehavesLike' may only be used inside 'context' or 'describe'. ")
raiseError("'itBehavesLike' cannot be used inside '\(currentPhase)', 'itBehavesLike' may only be used inside 'context' or 'describe'.")
}
let callsite = Callsite(file: file, line: line)
let closure = behavior.spec
Expand Down
7 changes: 5 additions & 2 deletions Sources/Quick/World.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ final internal class World: _WorldBase {
be mutated to change Quick's behavior.
*/
internal func configure(_ closure: QuickConfigurer) {
assert(!isConfigurationFinalized,
"Quick cannot be configured outside of a +[QuickConfiguration configure:] method. You should not call -[World configure:] directly. Instead, subclass QuickConfiguration and override the +[QuickConfiguration configure:] method.")
assert(
!isConfigurationFinalized,
// swiftlint:disable:next line_length
"Quick cannot be configured outside of a +[QuickConfiguration configure:] method. You should not call -[World configure:] directly. Instead, subclass QuickConfiguration and override the +[QuickConfiguration configure:] method."
)
closure(configuration)
}

Expand Down
1 change: 1 addition & 0 deletions Tests/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
disabled_rules:
- function_body_length
- identifier_name
- line_length
- type_name
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FunctionalTests_AfterEachSpec: QuickSpec {
afterEach { }
}.to(raiseException { (exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'afterEach' cannot be used inside 'it', 'afterEach' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'afterEach' cannot be used inside 'it', 'afterEach' may only be used inside 'context' or 'describe'."))
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FunctionalTests_BeforeEachSpec: QuickSpec {
beforeEach { }
}.to(raiseException { (exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'beforeEach' cannot be used inside 'it', 'beforeEach' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'beforeEach' cannot be used inside 'it', 'beforeEach' may only be used inside 'context' or 'describe'."))
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FunctionalTests_BehaviorTests_ErrorSpec: QuickSpec {
}
.to(raiseException {(exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'itBehavesLike' cannot be used inside 'it', 'itBehavesLike' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'itBehavesLike' cannot be used inside 'it', 'itBehavesLike' may only be used inside 'context' or 'describe'."))
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class QuickContextTests: QuickSpec {
context("A nested context that should throw") { }
}.to(raiseException { (exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'context' cannot be used inside 'it', 'context' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'context' cannot be used inside 'it', 'context' may only be used inside 'context' or 'describe'."))
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class QuickDescribeTests: QuickSpec {
describe("A nested describe that should throw") { }
}.to(raiseException { (exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'describe' cannot be used inside 'it', 'describe' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'describe' cannot be used inside 'it', 'describe' may only be used inside 'context' or 'describe'."))
})
}
}
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 @@ -59,7 +59,7 @@ class FunctionalTests_ItSpec: QuickSpec {
it("will throw an error when it is nested in another it") { }
}.to(raiseException { (exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'it' cannot be used inside 'it', 'it' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'it' cannot be used inside 'it', 'it' may only be used inside 'context' or 'describe'."))
})
}

Expand All @@ -79,7 +79,7 @@ class FunctionalTests_ItSpec: QuickSpec {

it("should have thrown an exception with the correct error message") {
expect(exception).toNot(beNil())
expect(exception!.reason).to(equal("'it' cannot be used inside 'beforeEach', 'it' may only be used inside 'context' or 'describe'. "))
expect(exception!.reason).to(equal("'it' cannot be used inside 'beforeEach', 'it' may only be used inside 'context' or 'describe'."))
}
}

Expand All @@ -90,7 +90,7 @@ class FunctionalTests_ItSpec: QuickSpec {
let capture = NMBExceptionCapture(handler: ({ e in
exception = e
expect(exception).toNot(beNil())
expect(exception!.reason).to(equal("'it' cannot be used inside 'afterEach', 'it' may only be used inside 'context' or 'describe'. "))
expect(exception!.reason).to(equal("'it' cannot be used inside 'afterEach', 'it' may only be used inside 'context' or 'describe'."))
}), finally: nil)

capture.tryBlock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FunctionalTests_SharedExamples_ErrorSpec: QuickSpec {
itBehavesLike("a group of three shared examples")
}.to(raiseException { (exception: NSException) in
expect(exception.name).to(equal(NSExceptionName.internalInconsistencyException))
expect(exception.reason).to(equal("'itBehavesLike' cannot be used inside 'it', 'itBehavesLike' may only be used inside 'context' or 'describe'. "))
expect(exception.reason).to(equal("'itBehavesLike' cannot be used inside 'it', 'itBehavesLike' may only be used inside 'context' or 'describe'."))
})
}
}
Expand Down
0