Skip to content

Commit

Permalink
Apply formatting for Swift 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDesiatov committed Dec 9, 2020
1 parent c94cfcf commit fa5fcbb
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 40 deletions.
21 changes: 10 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: '^Carthage'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: check-merge-conflict
- repo: https://github.com/hodovani/pre-commit-swift
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: check-merge-conflict
- repo: https://github.com/hodovani/pre-commit-swift
rev: master
hooks:
- id: swift-lint
- id: swift-format
- id: swift-lint
- id: swift-format
3 changes: 1 addition & 2 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
--ifdef noindent
--stripunusedargs closure-only
--disable andOperator
--swiftversion 4.2
--exclude Carthage
--swiftversion 5.1
1 change: 0 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function_body_length:
- 50

excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- .build
- Example/Pods
- Tests/CoreXLSXTests/XCTestManifests.swift
2 changes: 1 addition & 1 deletion Example/CoreXLSXExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
didFinishLaunchingWithOptions options: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
// Override point for customization after application launch.
return true
true
}

func applicationWillResignActive(_ application: UIApplication) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreXLSX/Comments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct CommentList: Codable, Equatable {
public let items: [Comment]

public var itemsByReference: [String: Comment] {
return Dictionary(uniqueKeysWithValues: items.map { ($0.reference, $0) })
Dictionary(uniqueKeysWithValues: items.map { ($0.reference, $0) })
}

enum CodingKeys: String, CodingKey {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreXLSX/Relationships.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ public struct Relationship: Codable, Equatable {
public let target: String

func path(from root: String) -> String {
return Path(target).isRoot ? target : "\(root)/\(target)"
Path(target).isRoot ? target : "\(root)/\(target)"
}
}
6 changes: 3 additions & 3 deletions Sources/CoreXLSX/Worksheet/CellQueries.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public extension Worksheet {
func cells<T>(atColumns columns: T) -> [Cell]
where T: Collection, T.Element == ColumnReference
{
return data?.rows.map {
data?.rows.map {
$0.cells.filter { columns.contains($0.reference.column) }
}
.reduce([]) { $0 + $1 } ?? []
Expand All @@ -34,7 +34,7 @@ public extension Worksheet {
func cells<T>(atRows rows: T) -> [Cell]
where T: Collection, T.Element == UInt
{
return data?.rows.filter { rows.contains($0.reference) }
data?.rows.filter { rows.contains($0.reference) }
.reduce([]) { $0 + $1.cells } ?? []
}

Expand All @@ -44,7 +44,7 @@ public extension Worksheet {
where T1: Collection, T1.Element == ColumnReference,
T2: Collection, T2.Element == UInt
{
return data?.rows.filter { rows.contains($0.reference) }.map {
data?.rows.filter { rows.contains($0.reference) }.map {
$0.cells.filter { columns.contains($0.reference.column) }
}
.reduce([]) { $0 + $1 } ?? []
Expand Down
4 changes: 2 additions & 2 deletions Sources/CoreXLSX/Worksheet/CellReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public struct CellReference {

extension CellReference: Equatable {
public static func ==(lhs: CellReference, rhs: CellReference) -> Bool {
return lhs.column == rhs.column && lhs.row == rhs.row
lhs.column == rhs.column && lhs.row == rhs.row
}
}

extension CellReference: CustomStringConvertible {
public var description: String {
return "\(column)\(row)"
"\(column)\(row)"
}
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/CoreXLSX/Worksheet/ColumnReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct ColumnReference {
}

func reducer(acc: String, i: Int) -> String {
return String(Character(UnicodeScalar(
String(Character(UnicodeScalar(
ColumnReference.firstAllowedCharacter.value - 1 + UInt32(i)
)!)) + acc
}
Expand Down Expand Up @@ -112,23 +112,23 @@ public struct ColumnReference {

extension ColumnReference: CustomStringConvertible {
public var description: String {
return "\(value)"
"\(value)"
}
}

extension ColumnReference: Comparable {
public static func <(lhs: ColumnReference, rhs: ColumnReference) -> Bool {
return lhs.intValue < rhs.intValue
lhs.intValue < rhs.intValue
}

public static func ==(lhs: ColumnReference, rhs: ColumnReference) -> Bool {
return lhs.value == rhs.value
lhs.value == rhs.value
}
}

extension ColumnReference: Strideable {
public func distance(to target: ColumnReference) -> Int {
return target.intValue - intValue
target.intValue - intValue
}

public func advanced(by offset: Int) -> ColumnReference {
Expand Down
18 changes: 9 additions & 9 deletions Sources/CoreXLSX/Worksheet/Worksheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct Worksheet: Codable {
public struct FormatProperties: Codable, Equatable {
@available(*, deprecated, renamed: "defaultColumnWidth")
public var defaultColWidth: String? {
return defaultColumnWidth
defaultColumnWidth
}

public let defaultColumnWidth: String?
Expand All @@ -58,7 +58,7 @@ public struct Worksheet: Codable {

@available(*, deprecated, renamed: "outlineLevelColumn")
public var outlineLevelCol: String? {
return outlineLevelColumn
outlineLevelColumn
}

public let outlineLevelColumn: String?
Expand Down Expand Up @@ -88,15 +88,15 @@ public struct Worksheet: Codable {

@available(*, deprecated, renamed: "properties")
public var sheetPr: SheetPr? {
return properties
properties
}

public let properties: Properties?

public struct Dimension: Codable {
@available(*, deprecated, renamed: "reference")
public var ref: String {
return reference
reference
}

public let reference: String
Expand All @@ -114,22 +114,22 @@ public struct Worksheet: Codable {

@available(*, deprecated, renamed: "formatProperties")
public var sheetFormatPr: SheetFormatPr {
return formatProperties ?? FormatProperties()
formatProperties ?? FormatProperties()
}

public let formatProperties: FormatProperties?
public let columns: Columns?

@available(*, deprecated, renamed: "columns")
public var cols: Cols? {
return columns
columns
}

public let data: Data?

@available(*, deprecated, renamed: "data")
public var sheetData: SheetData {
return data ?? Data(rows: [])
data ?? Data(rows: [])
}

public let mergeCells: MergeCells?
Expand Down Expand Up @@ -221,7 +221,7 @@ public struct Row: Codable {

@available(*, deprecated, renamed: "height")
public var ht: String? {
return height?.description
height?.description
}

public let height: Double?
Expand Down Expand Up @@ -252,7 +252,7 @@ public struct MergeCell: Codable {

@available(*, deprecated, renamed: "reference")
public var ref: String {
return reference
reference
}

enum CodingKeys: String, CodingKey {
Expand Down
6 changes: 3 additions & 3 deletions Sources/CoreXLSX/XLSXFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public class XLSXFile {

/// Return an array of paths to relationships of type `officeDocument`
public func parseDocumentPaths() throws -> [String] {
return try parseRelationships().items
try parseRelationships().items
.filter { $0.type == .officeDocument }
.map { $0.target }
}
Expand Down Expand Up @@ -240,7 +240,7 @@ public class XLSXFile {
public func parseWorksheetPathsAndNames(
workbook: Workbook
) throws -> [(name: String?, path: String)] {
return try parseDocumentPaths().map {
try parseDocumentPaths().map {
try parseDocumentRelationships(path: $0)
}.flatMap { (path, relationships) -> [(name: String?, path: String)] in
let worksheets = relationships.items.filter { $0.type == .worksheet }
Expand All @@ -261,7 +261,7 @@ public class XLSXFile {

/// Parse and return an array of worksheets in this XLSX file.
public func parseWorksheetPaths() throws -> [String] {
return try parseDocumentPaths().map {
try parseDocumentPaths().map {
try parseDocumentRelationships(path: $0)
}.flatMap { (path, relationships) -> [String] in
let worksheets = relationships.items.filter { $0.type == .worksheet }
Expand Down
2 changes: 1 addition & 1 deletion Tests/CoreXLSXTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ extension WorksheetTests {
}

public func __allTests() -> [XCTestCaseEntry] {
return [
[
testCase(BorderTest.__allTests__BorderTest),
testCase(CellQueriesTests.__allTests__CellQueriesTests),
testCase(CellReferenceTests.__allTests__CellReferenceTests),
Expand Down

0 comments on commit fa5fcbb

Please sign in to comment.