Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalonunez authored and github-actions[bot] committed Mar 30, 2023
1 parent c5fe8fd commit 9491e42
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 87 deletions.
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
products: [
.executable(
name: "ross",
targets: ["ross"]),
targets: ["ross"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
Expand All @@ -23,10 +23,10 @@ let package = Package(
.product(name: "SwiftSyntax", package: "swift-syntax"),
]),

.testTarget(
name: "RossTests",
dependencies: [
"ross"
]),
.testTarget(
name: "RossTests",
dependencies: [
"ross"
]),
]
)
162 changes: 81 additions & 81 deletions Tests/RossTests/RossTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest

final class RossTests: XCTestCase {

// MARK: Lifecycle
// MARK: Lifecycle

override func setUp() async throws {
try fileManager.createDirectory(at: examplesDirectory, withIntermediateDirectories: false)
Expand All @@ -24,71 +24,71 @@ final class RossTests: XCTestCase {
let fileURL = examplesDirectory.appendingPathComponent("Test.swift")

let file = """
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
import SwiftSyntax
/// This class takes the raw source text and scans through it searching for comments that instruct
/// the formatter to change the status of rules for the following node. The comments may include no
/// rule names to affect all rules, a single rule name to affect that rule, or a comma delimited
/// list of rule names to affect a number of rules. Ignore is the only supported operation.
public class RuleMask {
/// Stores the source ranges in which all rules are ignored.
private var allRulesIgnoredRanges: [SourceRange] = []
/// Map of rule names to list ranges in the source where the rule is ignored.
private var ruleMap: [String: [SourceRange]] = [:]
/// Used to compute line numbers of syntax nodes.
private let sourceLocationConverter: SourceLocationConverter
}
"""
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
import SwiftSyntax
/// This class takes the raw source text and scans through it searching for comments that instruct
/// the formatter to change the status of rules for the following node. The comments may include no
/// rule names to affect all rules, a single rule name to affect that rule, or a comma delimited
/// list of rule names to affect a number of rules. Ignore is the only supported operation.
public class RuleMask {
/// Stores the source ranges in which all rules are ignored.
private var allRulesIgnoredRanges: [SourceRange] = []
/// Map of rule names to list ranges in the source where the rule is ignored.
private var ruleMap: [String: [SourceRange]] = [:]
/// Used to compute line numbers of syntax nodes.
private let sourceLocationConverter: SourceLocationConverter
}
"""

XCTAssert(fileManager.createFile(atPath: fileURL.path, contents: file.data(using: .utf8)))

var cli = Ross(directory: examplesDirectory.path)
try await cli.run()

let expected = #"""
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
import SwiftSyntax
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
import SwiftSyntax
public class RuleMask {
public class RuleMask {
private var allRulesIgnoredRanges: [SourceRange] = []
private var allRulesIgnoredRanges: [SourceRange] = []
private var ruleMap: [String: [SourceRange]] = [:]
private var ruleMap: [String: [SourceRange]] = [:]
private let sourceLocationConverter: SourceLocationConverter
}
"""#
private let sourceLocationConverter: SourceLocationConverter
}
"""#

let actual = try String(contentsOf: fileURL, encoding: .utf8)
XCTAssertEqual(actual, expected)
Expand All @@ -98,18 +98,18 @@ final class RossTests: XCTestCase {
let fileURL = examplesDirectory.appendingPathComponent("Test.swift")

let file = """
/// The enablement of a lint/format rule based on the presence or absence of comment directives in
/// the source file.
public enum RuleState {
/// The enablement of a lint/format rule based on the presence or absence of comment directives in
/// the source file.
public enum RuleState {
/// There is no explicit information in the source file about whether the rule should be enable
/// or disabled at the requested location, so the configuration default should be used
case `default`
/// There is no explicit information in the source file about whether the rule should be enable
/// or disabled at the requested location, so the configuration default should be used
case `default`
/// The rule is explicitly disabled at the requested location.
case disabled
}
"""
/// The rule is explicitly disabled at the requested location.
case disabled
}
"""

XCTAssert(fileManager.createFile(atPath: fileURL.path, contents: file.data(using: .utf8)))

Expand All @@ -119,16 +119,16 @@ final class RossTests: XCTestCase {
let expected = #"""
public enum RuleState {
public enum RuleState {
case `default`
case `default`
case disabled
}
"""#
case disabled
}
"""#

let actual = try String(contentsOf: fileURL, encoding: .utf8)
XCTAssertEqual(actual, expected)
Expand All @@ -138,19 +138,19 @@ final class RossTests: XCTestCase {
let fileURL = examplesDirectory.appendingPathComponent("Test.swift")

let file = """
/**
Registers a handler in an `Application` for a given path.
- Parameters:
- app: The `Application` to register the handler in.
- path: The path to register the handler for.
*/
public func register(in app: Application, for path: String) {
app.on(method, path.pathComponents) { [handle] req async throws in
try await handle(req)
/**
Registers a handler in an `Application` for a given path.
- Parameters:
- app: The `Application` to register the handler in.
- path: The path to register the handler for.
*/
public func register(in app: Application, for path: String) {
app.on(method, path.pathComponents) { [handle] req async throws in
try await handle(req)
}
}
}
"""
"""

XCTAssert(fileManager.createFile(atPath: fileURL.path, contents: file.data(using: .utf8)))

Expand All @@ -159,12 +159,12 @@ final class RossTests: XCTestCase {

let expected = """
public func register(in app: Application, for path: String) {
app.on(method, path.pathComponents) { [handle] req async throws in
try await handle(req)
public func register(in app: Application, for path: String) {
app.on(method, path.pathComponents) { [handle] req async throws in
try await handle(req)
}
}
}
"""
"""

let actual = try String(contentsOf: fileURL, encoding: .utf8)
XCTAssertEqual(actual, expected)
Expand Down

0 comments on commit 9491e42

Please sign in to comment.