Add .swiftlint.yml and fix linter warnings/errors
This commit is contained in:
parent
fd631af8a3
commit
0d467edbf8
|
@ -0,0 +1,15 @@
|
|||
disabled_rules:
|
||||
- trailing_comma
|
||||
- identifier_name
|
||||
- private_over_fileprivate
|
||||
- void_return
|
||||
- operator_whitespace
|
||||
- nesting
|
||||
- cyclomatic_complexity
|
||||
|
||||
line_length:
|
||||
- 80
|
||||
- 100
|
||||
|
||||
function_body_length:
|
||||
- 50
|
|
@ -8,6 +8,7 @@ before_install:
|
|||
# - gem install cocoapods --pre # Since Travis is not always on latest version
|
||||
- brew update
|
||||
- brew install swiftformat
|
||||
- brew outdated carthage swiftlint || brew upgrade carthage swiftlint
|
||||
# - brew outdated carthage || brew upgrade carthage
|
||||
# cache: cocoapods
|
||||
# podfile: Example/Podfile
|
||||
|
@ -16,6 +17,7 @@ before_install:
|
|||
# - pod install --project-directory=Example
|
||||
script:
|
||||
- swiftformat --lint --verbose .
|
||||
- swiftlint
|
||||
- xcodebuild test -enableCodeCoverage YES -scheme GluonCore
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
|
|
@ -12,30 +12,45 @@ import UIKit
|
|||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
private typealias Options = [UIApplication.LaunchOptionsKey: Any]
|
||||
|
||||
func application(_: UIApplication, didFinishLaunchingWithOptions _: Options?)
|
||||
-> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillResignActive(_: UIApplication) {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
// Sent when the application is about to move from active to inactive state.
|
||||
// This can occur for certain types of temporary interruptions (such as an
|
||||
// incoming phone call or SMS message) or when the user quits the
|
||||
// application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down
|
||||
// OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
func applicationDidEnterBackground(_: UIApplication) {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
// Use this method to release shared resources, save user data, invalidate
|
||||
// timers, and store enough application state information to restore your
|
||||
// application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called
|
||||
// instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
func applicationWillEnterForeground(_: UIApplication) {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
// Called as part of the transition from the background to the inactive
|
||||
// state; here you can undo many of the changes made on entering the
|
||||
// background.
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive(_: UIApplication) {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
// Restart any tasks that were paused (or not yet started) while the
|
||||
// application was inactive. If the application was previously in the
|
||||
// background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
// Called when the application is about to terminate. Save data if
|
||||
// appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,9 @@ final class GluonViewController: UIViewController {
|
|||
}
|
||||
|
||||
@IBAction func onTap(_: Any) {
|
||||
// let counters = (0..<1_000_000).map { _ in Counter(props: NoProps(), children: []) }
|
||||
// let counters = (0..<1_000_000).map { _ in
|
||||
// Counter(props: NoProps(), children: [])
|
||||
// }
|
||||
print(#file)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,19 @@ import XCTest
|
|||
|
||||
class GluonTest: XCTestCase {
|
||||
override func setUp() {
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
// Put setup code here. This method is called before the invocation of each
|
||||
// test method in the class.
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
// Put teardown code here. This method is called after the invocation of
|
||||
// each test method in the class.
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
// Use XCTAssert and related functions to verify your tests produce the
|
||||
// correct results.
|
||||
}
|
||||
|
||||
func testPerformanceExample() {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
D1E0C83921D782200042A261 /* Frame.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1E0C83821D782200042A261 /* Frame.swift */; };
|
||||
D1E0C83E21D7AC570042A261 /* ControlWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1E0C83D21D7AC570042A261 /* ControlWrapper.swift */; };
|
||||
D1E0C84021D7AD480042A261 /* UIKitHostComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1E0C83F21D7AD480042A261 /* UIKitHostComponent.swift */; };
|
||||
D1E0C84321D7BE9B0042A261 /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1E0C84221D7BE9B0042A261 /* View.swift */; };
|
||||
OBJ_104 /* GluonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_43 /* GluonTests.swift */; };
|
||||
OBJ_105 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_44 /* XCTestManifests.swift */; };
|
||||
OBJ_107 /* GluonTestRenderer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "Gluon::GluonTestRenderer::Product" /* GluonTestRenderer.framework */; };
|
||||
|
@ -111,6 +112,7 @@
|
|||
D1E0C83821D782200042A261 /* Frame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Frame.swift; sourceTree = "<group>"; };
|
||||
D1E0C83D21D7AC570042A261 /* ControlWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ControlWrapper.swift; sourceTree = "<group>"; };
|
||||
D1E0C83F21D7AD480042A261 /* UIKitHostComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKitHostComponent.swift; sourceTree = "<group>"; };
|
||||
D1E0C84221D7BE9B0042A261 /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = "<group>"; };
|
||||
"Gluon::Gluon::Product" /* Gluon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Gluon.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
"Gluon::GluonTestRenderer::Product" /* GluonTestRenderer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GluonTestRenderer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
"Gluon::GluonTests::Product" /* GluonTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = GluonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -238,6 +240,7 @@
|
|||
OBJ_27 /* Label.swift */,
|
||||
OBJ_28 /* StackView.swift */,
|
||||
D1E0C83621D780690042A261 /* Frame.swift */,
|
||||
D1E0C84221D7BE9B0042A261 /* View.swift */,
|
||||
);
|
||||
path = HostComponents;
|
||||
sourceTree = "<group>";
|
||||
|
@ -281,7 +284,7 @@
|
|||
name = Products;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
OBJ_5 /* */ = {
|
||||
OBJ_5 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
OBJ_6 /* Package.swift */,
|
||||
|
@ -291,7 +294,6 @@
|
|||
OBJ_46 /* Products */,
|
||||
);
|
||||
indentWidth = 2;
|
||||
name = "";
|
||||
sourceTree = "<group>";
|
||||
tabWidth = 2;
|
||||
};
|
||||
|
@ -330,6 +332,7 @@
|
|||
buildPhases = (
|
||||
OBJ_55 /* Sources */,
|
||||
OBJ_77 /* Frameworks */,
|
||||
D1E0C84121D7BD360042A261 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
@ -421,7 +424,7 @@
|
|||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = OBJ_5 /* */;
|
||||
mainGroup = OBJ_5;
|
||||
productRefGroup = OBJ_46 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
|
@ -436,6 +439,26 @@
|
|||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
D1E0C84121D7BD360042A261 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
OBJ_103 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
|
@ -477,6 +500,7 @@
|
|||
OBJ_61 /* Default.swift in Sources */,
|
||||
OBJ_62 /* Diffable.swift in Sources */,
|
||||
OBJ_63 /* Event.swift in Sources */,
|
||||
D1E0C84321D7BE9B0042A261 /* View.swift in Sources */,
|
||||
OBJ_64 /* Hooks.swift in Sources */,
|
||||
OBJ_65 /* Button.swift in Sources */,
|
||||
OBJ_66 /* Label.swift in Sources */,
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
// swift-tools-version:4.2
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
// The swift-tools-version declares the minimum version of Swift required to
|
||||
// build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Gluon",
|
||||
products: [
|
||||
// Products define the executables and libraries produced by a package, and make them visible to other packages.
|
||||
// Products define the executables and libraries produced by a package,
|
||||
// and make them visible to other packages.
|
||||
.library(
|
||||
name: "Gluon",
|
||||
targets: ["Gluon"]
|
||||
|
@ -25,8 +27,10 @@ let package = Package(
|
|||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
// Targets are the basic building blocks of a package. A target can define
|
||||
// a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products
|
||||
// in packages which this package depends on.
|
||||
.target(
|
||||
name: "Gluon",
|
||||
dependencies: []
|
||||
|
|
|
@ -20,7 +20,9 @@ final class CompositeComponentWrapper<R: Renderer>: ComponentWrapper<R> {
|
|||
private let parentTarget: R.Target
|
||||
var state = [String: Any]()
|
||||
|
||||
init(_ node: Node, _ type: AnyCompositeComponent.Type, _ parentTarget: R.Target) {
|
||||
init(_ node: Node,
|
||||
_ type: AnyCompositeComponent.Type,
|
||||
_ parentTarget: R.Target) {
|
||||
self.type = type
|
||||
self.parentTarget = parentTarget
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// View.swift
|
||||
// Gluon
|
||||
//
|
||||
// Created by Max Desiatov on 29/12/2018.
|
||||
//
|
||||
|
||||
public struct View: HostComponent {
|
||||
public typealias Children = [Node]
|
||||
|
||||
public let props: Props
|
||||
public let children: [Node]
|
||||
|
||||
public struct Props: Equatable {}
|
||||
}
|
|
@ -5,8 +5,6 @@
|
|||
// Created by Max Desiatov on 12/10/2018.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Generic undo-redo manager that doesn't require rollback implementation in
|
||||
/// `apply` of a wrapped store. It saves previous snapshots of state in a stack
|
||||
/// and undo/redo actions allow traversing the state history. This might be
|
||||
|
@ -76,7 +74,8 @@ public protocol Store {
|
|||
// }
|
||||
//
|
||||
//typealias Dispatch<Action> = (Action) -> ()
|
||||
//typealias Dispatcher<S: Store> = (state: S.State, dispatch: Dispatch<S.Action>)
|
||||
//typealias Dispatcher<S: Store> =
|
||||
// (state: S.State, dispatch: Dispatch<S.Action>)
|
||||
|
||||
// FIXME: when contexts are available read state and dispatch
|
||||
// from the context and pass it to the mapper
|
||||
|
|
|
@ -84,12 +84,3 @@ enum ComponentType: Equatable {
|
|||
return type
|
||||
}
|
||||
}
|
||||
|
||||
public struct View: HostComponent {
|
||||
public typealias Children = [Node]
|
||||
|
||||
public let props: Props
|
||||
public let children: [Node]
|
||||
|
||||
public struct Props: Equatable {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue