Skip to content

Commit

Permalink
Merge pull request #28 from amiantos/impose-swiftformat
Browse files Browse the repository at this point in the history
Impose SwiftFormat
  • Loading branch information
amiantos committed Apr 6, 2023
2 parents 762fdc7 + 045e3b5 commit c24337e
Show file tree
Hide file tree
Showing 25 changed files with 221 additions and 181 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Swift Linters

on:
pull_request:
paths:
- '.github/workflows/swift.yml'
- '.swift.yml'
- '**/*.swift'


jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint
uses: norio-nomura/action-swiftlint@3.1.0
env:
DIFF_BASE: ${{ github.base_ref }}
SwiftFormat:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: .build/release/swiftformat
key: $-linting-swiftformat-$
- name: Build nicklockwood/SwiftFormat
run: |
if [ -f ".build/release/swiftformat" ]; then
if ! [ -x "$(command -v swift-format)" ]; then
sudo cp -f .build/release/swiftformat /usr/local/bin/swiftformat
fi
else
git clone --depth 1 --branch master https://github.com/nicklockwood/SwiftFormat
cd SwiftFormat
swift build --disable-sandbox -c release
mv .build .. && cd ..
rm -rf SwiftFormat
sudo cp -f .build/release/swiftformat /usr/local/bin/swiftformat
fi
- name: SwiftFormat
run: |
swiftformat --version
swiftformat . --config .swiftformat --lint
18 changes: 0 additions & 18 deletions .github/workflows/swiftlint.yml

This file was deleted.

1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
8 changes: 8 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--exclude Tests/XCTestManifests.swift,Tests/BadConfig,Snapshots,Build,PluginTests
--binarygrouping none
--decimalgrouping none
--hexgrouping none
--octalgrouping none
--semicolons never
--wrapcollections before-first
--wrapparameters before-first
2 changes: 1 addition & 1 deletion GamebookEngine/Data/GameDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
import UIKit

class GameDatabase {
static let standard: GameDatabase = GameDatabase()
static let standard: GameDatabase = .init()

var mainManagedObjectContext: NSManagedObjectContext
var persistentContainer: NSPersistentContainer
Expand Down
6 changes: 3 additions & 3 deletions GamebookEngine/Data/GamePlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GamePlayer: GamePlayerDelegate {

func pickedDecision(at index: Int) {
guard let decision = decisions.item(at: index),
let page = decision.destination else { return }
let page = decision.destination else { return }
self.page = page
loadPage()
}
Expand Down Expand Up @@ -90,7 +90,7 @@ class GamePlayer: GamePlayerDelegate {
var passOrFail: [Bool] = []
for rule in rules {
guard let ruleAttributeUUID = rule.attribute?.uuid else { continue }
var pass: Bool = false
var pass = false
switch rule.type {
case .isEqualTo:
pass = Float(rule.value) == currentValues[ruleAttributeUUID] ? true : false
Expand All @@ -105,7 +105,7 @@ class GamePlayer: GamePlayerDelegate {
}
switch decision.matchStyle {
case .matchAll:
var failure: Bool = false
var failure = false
for passState in passOrFail where passState == false {
failure = true
break
Expand Down
17 changes: 10 additions & 7 deletions GamebookEngine/Data/GameSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import UIKit

class GameSerializer {
static let standard: GameSerializer = GameSerializer()
static let standard: GameSerializer = .init()

// MARK: - Game

Expand Down Expand Up @@ -38,8 +38,9 @@ class GameSerializer {
alert.addAction(alertButton)
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController
{
rootViewController.present(alert, animated: true, completion: nil)
}
}
Expand All @@ -48,8 +49,9 @@ class GameSerializer {
}
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController
{
rootViewController.present(alert, animated: true, completion: nil)
alert.view.tintColor = UIColor(named: "text") ?? .darkGray
}
Expand All @@ -69,8 +71,9 @@ class GameSerializer {
alert.addAction(alertButton)
DispatchQueue.main.async {
if let appDelegate = UIApplication.shared.delegate,
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController {
let appWindow = appDelegate.window!,
let rootViewController = appWindow.rootViewController
{
rootViewController.present(alert, animated: true, completion: nil)
}
}
Expand Down
22 changes: 11 additions & 11 deletions GamebookEngine/Data/Models/Attribute+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import CoreData
import Foundation

extension Attribute {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Attribute> {
public extension Attribute {
@nonobjc class func fetchRequest() -> NSFetchRequest<Attribute> {
return NSFetchRequest<Attribute>(entityName: "Attribute")
}

@NSManaged public var name: String
@NSManaged public var uuid: UUID
@NSManaged public var consequences: NSSet?
@NSManaged public var game: Game
@NSManaged var name: String
@NSManaged var uuid: UUID
@NSManaged var consequences: NSSet?
@NSManaged var game: Game
}

// MARK: Gamebook Engine Methods
Expand All @@ -33,16 +33,16 @@ extension Attribute {

// MARK: Generated accessors for consequences

extension Attribute {
public extension Attribute {
@objc(addConsequencesObject:)
@NSManaged public func addToConsequences(_ value: Consequence)
@NSManaged func addToConsequences(_ value: Consequence)

@objc(removeConsequencesObject:)
@NSManaged public func removeFromConsequences(_ value: Consequence)
@NSManaged func removeFromConsequences(_ value: Consequence)

@objc(addConsequences:)
@NSManaged public func addToConsequences(_ values: NSSet)
@NSManaged func addToConsequences(_ values: NSSet)

@objc(removeConsequences:)
@NSManaged public func removeFromConsequences(_ values: NSSet)
@NSManaged func removeFromConsequences(_ values: NSSet)
}
18 changes: 9 additions & 9 deletions GamebookEngine/Data/Models/Consequence+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ import Foundation
}
}

extension Consequence {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Consequence> {
public extension Consequence {
@nonobjc class func fetchRequest() -> NSFetchRequest<Consequence> {
return NSFetchRequest<Consequence>(entityName: "Consequence")
}

@NSManaged public var amount: Float
@NSManaged public var type: ConsequenceType
@NSManaged public var uuid: UUID?
@NSManaged public var attribute: Attribute?
@NSManaged public var page: Page?
@NSManaged var amount: Float
@NSManaged var type: ConsequenceType
@NSManaged var uuid: UUID?
@NSManaged var attribute: Attribute?
@NSManaged var page: Page?
}

// MARK: Gamebook Engine Methods

extension Consequence {
public var hasIssues: Bool {
public extension Consequence {
var hasIssues: Bool {
guard attribute != nil else { return true }
return false
}
Expand Down
24 changes: 12 additions & 12 deletions GamebookEngine/Data/Models/Decision+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ import Foundation
}
}

extension Decision {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Decision> {
public extension Decision {
@nonobjc class func fetchRequest() -> NSFetchRequest<Decision> {
return NSFetchRequest<Decision>(entityName: "Decision")
}

@NSManaged public var content: String
@NSManaged public var uuid: UUID
@NSManaged public var destination: Page?
@NSManaged public var page: Page
@NSManaged public var matchStyle: MatchType
@NSManaged public var rules: NSSet?
@NSManaged var content: String
@NSManaged var uuid: UUID
@NSManaged var destination: Page?
@NSManaged var page: Page
@NSManaged var matchStyle: MatchType
@NSManaged var rules: NSSet?
}

// MARK: Gamebook Engine Methods

extension Decision {
public var hasIssues: Bool {
guard let destination = self.destination else { return true }
if let rules = self.rules?.allObjects as? [Rule] {
public extension Decision {
var hasIssues: Bool {
guard let destination = destination else { return true }
if let rules = rules?.allObjects as? [Rule] {
for rule in rules where rule.hasIssues {
return true
}
Expand Down
54 changes: 27 additions & 27 deletions GamebookEngine/Data/Models/Game+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ import Foundation
}
}

extension Game {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Game> {
public extension Game {
@nonobjc class func fetchRequest() -> NSFetchRequest<Game> {
return NSFetchRequest<Game>(entityName: "Game")
}

@NSManaged public var name: String
@NSManaged public var uuid: UUID
@NSManaged public var author: String
@NSManaged public var license: String?
@NSManaged public var website: URL?
@NSManaged public var about: String?
@NSManaged public var font: GameFont
@NSManaged public var attributes: NSSet?
@NSManaged public var pages: NSOrderedSet?
@NSManaged var name: String
@NSManaged var uuid: UUID
@NSManaged var author: String
@NSManaged var license: String?
@NSManaged var website: URL?
@NSManaged var about: String?
@NSManaged var font: GameFont
@NSManaged var attributes: NSSet?
@NSManaged var pages: NSOrderedSet?
}

// MARK: Gamebook Engine Methods
Expand All @@ -73,50 +73,50 @@ extension Game {

// MARK: Generated accessors for attributes

extension Game {
public extension Game {
@objc(addAttributesObject:)
@NSManaged public func addToAttributes(_ value: Attribute)
@NSManaged func addToAttributes(_ value: Attribute)

@objc(removeAttributesObject:)
@NSManaged public func removeFromAttributes(_ value: Attribute)
@NSManaged func removeFromAttributes(_ value: Attribute)

@objc(addAttributes:)
@NSManaged public func addToAttributes(_ values: NSSet)
@NSManaged func addToAttributes(_ values: NSSet)

@objc(removeAttributes:)
@NSManaged public func removeFromAttributes(_ values: NSSet)
@NSManaged func removeFromAttributes(_ values: NSSet)
}

// MARK: Generated accessors for pages

extension Game {
public extension Game {
@objc(insertObject:inPagesAtIndex:)
@NSManaged public func insertIntoPages(_ value: Page, at idx: Int)
@NSManaged func insertIntoPages(_ value: Page, at idx: Int)

@objc(removeObjectFromPagesAtIndex:)
@NSManaged public func removeFromPages(at idx: Int)
@NSManaged func removeFromPages(at idx: Int)

@objc(insertPages:atIndexes:)
@NSManaged public func insertIntoPages(_ values: [Page], at indexes: NSIndexSet)
@NSManaged func insertIntoPages(_ values: [Page], at indexes: NSIndexSet)

@objc(removePagesAtIndexes:)
@NSManaged public func removeFromPages(at indexes: NSIndexSet)
@NSManaged func removeFromPages(at indexes: NSIndexSet)

@objc(replaceObjectInPagesAtIndex:withObject:)
@NSManaged public func replacePages(at idx: Int, with value: Page)
@NSManaged func replacePages(at idx: Int, with value: Page)

@objc(replacePagesAtIndexes:withPages:)
@NSManaged public func replacePages(at indexes: NSIndexSet, with values: [Page])
@NSManaged func replacePages(at indexes: NSIndexSet, with values: [Page])

@objc(addPagesObject:)
@NSManaged public func addToPages(_ value: Page)
@NSManaged func addToPages(_ value: Page)

@objc(removePagesObject:)
@NSManaged public func removeFromPages(_ value: Page)
@NSManaged func removeFromPages(_ value: Page)

@objc(addPages:)
@NSManaged public func addToPages(_ values: NSOrderedSet)
@NSManaged func addToPages(_ values: NSOrderedSet)

@objc(removePages:)
@NSManaged public func removeFromPages(_ values: NSOrderedSet)
@NSManaged func removeFromPages(_ values: NSOrderedSet)
}
Loading

0 comments on commit c24337e

Please sign in to comment.