mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
fcf848608e
* Add Example wrapper in order to display test failures inline when running in Xcode. * Stop using Swift 5.1-only features so we can compile on Xcode 10.2. * Wrap strings in Example. * Add Changelog entry. * Wrap all examples in Example struct. * Better and more complete capturing of line numbers. * Fix broken test. * Better test traceability. * Address or disable linting warnings. * Add documentation comments. * Disable linter for a few cases. * Limit mutability and add copy-and-mutate utility functions. * Limit scope of mutability.
92 lines
3.3 KiB
Swift
92 lines
3.3 KiB
Swift
internal struct VerticalParameterAlignmentRuleExamples {
|
|
static let nonTriggeringExamples: [Example] = {
|
|
let commonExamples = [
|
|
Example("""
|
|
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
dictionary: SourceKittenDictionary) { }
|
|
"""),
|
|
Example("""
|
|
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
dictionary: SourceKittenDictionary) -> [StyleViolation]
|
|
"""),
|
|
Example("""
|
|
func foo(bar: Int)
|
|
"""),
|
|
Example("""
|
|
func foo(bar: Int) -> String
|
|
"""),
|
|
Example("""
|
|
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
dictionary: SourceKittenDictionary)
|
|
-> [StyleViolation]
|
|
"""),
|
|
Example("""
|
|
func validateFunction(
|
|
_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
dictionary: SourceKittenDictionary) -> [StyleViolation]
|
|
"""),
|
|
Example("""
|
|
func validateFunction(
|
|
_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
dictionary: SourceKittenDictionary
|
|
) -> [StyleViolation]
|
|
"""),
|
|
Example("""
|
|
func regex(_ pattern: String,
|
|
options: NSRegularExpression.Options = [.anchorsMatchLines,
|
|
.dotMatchesLineSeparators]) -> NSRegularExpression
|
|
"""),
|
|
Example("""
|
|
func foo(a: Void,
|
|
b: [String: String] =
|
|
[:]) {
|
|
}
|
|
"""),
|
|
Example("""
|
|
func foo(data: (size: CGSize,
|
|
identifier: String)) {}
|
|
""")
|
|
]
|
|
|
|
guard SwiftVersion.current >= .fiveDotOne else {
|
|
return commonExamples
|
|
}
|
|
|
|
return commonExamples + [
|
|
Example("""
|
|
func foo(data: Data,
|
|
@ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {}
|
|
""")
|
|
]
|
|
}()
|
|
|
|
static let triggeringExamples: [Example] = {
|
|
let commonExamples = [
|
|
Example("""
|
|
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
↓dictionary: SourceKittenDictionary) { }
|
|
"""),
|
|
Example("""
|
|
func validateFunction(_ file: SwiftLintFile, kind: SwiftDeclarationKind,
|
|
↓dictionary: SourceKittenDictionary) { }
|
|
"""),
|
|
Example("""
|
|
func validateFunction(_ file: SwiftLintFile,
|
|
↓kind: SwiftDeclarationKind,
|
|
↓dictionary: SourceKittenDictionary) { }
|
|
""")
|
|
]
|
|
|
|
guard SwiftVersion.current >= .fiveDotOne else {
|
|
return commonExamples
|
|
}
|
|
|
|
return commonExamples + [
|
|
Example("""
|
|
func foo(data: Data,
|
|
↓@ViewBuilder content: @escaping (Data.Element.IdentifiedValue) -> Content) {}
|
|
""")
|
|
]
|
|
}()
|
|
}
|