Files
SwiftLint/Source/SwiftLintFramework/Rules/QuickDiscouragedCallRuleExamples.swift
T
Ornithologist Coder fe96e4139a Improve validation
* Apply 'cheap' validation earlier. It's not a call to a restrictive
  method, returns no violations.
* But if it it's a call to a restrictive method, then checks if the file
  containts a QuickSpec and if the call is within the bounds of the
  QuickSpec class.
2017-08-18 11:24:03 +02:00

166 lines
5.3 KiB
Swift

//
// QuickDiscouragedCallRuleExamples.swift
// SwiftLint
//
// Created by Ornithologist Coder on 8/11/17.
// Copyright © 2017 Realm. All rights reserved.
//
import Foundation
internal struct QuickDiscouragedCallRuleExamples {
static let nonTriggeringExamples: [String] = [
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" beforeEach {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" beforeEach {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" afterEach {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" describe(\"bar\") {\n" +
" }\n" +
" context(\"bar\") {\n" +
" }\n" +
" it(\"bar\") {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" itBehavesLike(\"bar\")\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" it(\"does something\") {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" context(\"foo\") {\n" +
" afterEach { toto.append(foo) }\n" +
" }\n" +
" }\n" +
"}\n"
]
static let triggeringExamples: [String] = [
"class TotoTests {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" let foo = Foo()\n" +
" }\n" +
" }\n" +
"}\n" +
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" let foo = ↓Foo()\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" let foo = ↓Foo()\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" context(\"foo\") {\n" +
" let foo = ↓Foo()\n" +
" }\n" +
" context(\"bar\") {\n" +
" let foo = ↓Foo()\n" +
" ↓foo.bar()\n" +
" it(\"does something\") {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" context(\"foo\") {\n" +
" context(\"foo\") {\n" +
" beforeEach {\n" +
" let foo = Foo()\n" +
" foo.toto()\n" +
" }\n" +
" it(\"bar\") {\n" +
" }\n" +
" context(\"foo\") {\n" +
" let foo = ↓Foo()\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" context(\"foo\") {\n" +
" let foo = ↓Foo()\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" sharedExamples(\"foo\") {\n" +
" let foo = ↓Foo()\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" describe(\"foo\") {\n" +
" ↓foo()\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" context(\"foo\") {\n" +
" ↓foo()\n" +
" }\n" +
" }\n" +
"}\n",
"class TotoTests: QuickSpec {\n" +
" override func spec() {\n" +
" sharedExamples(\"foo\") {\n" +
" ↓foo()\n" +
" }\n" +
" }\n" +
"}\n"
]
}