This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomRuleSetProvider : RuleSetProvider { | |
override fun get() = RuleSet("rules", | |
NoInternalImportRule(), | |
NoVarRule() | |
) | |
} | |
class NoInternalImportRule : Rule("no-internal-import") { | |
override fun visit( | |
node: ASTNode, autoCorrect: Boolean, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task ktlint(type: JavaExec, group: "verification") { | |
description = "Check Kotlin code style." | |
main = "com.pinterest.ktlint.Main" | |
classpath = configurations.ktlint | |
args "src/**/*.kt --reporter=html,artifact=me.cassiano:ktlint-html-reporter:0.2.3,output=${buildDir}/ktlint.html" | |
} | |
check.dependsOn ktlint | |
task ktlintFormat(type: JavaExec, group: "formatting") { | |
description = "Fix Kotlin code style deviations." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/ConduitAPIServer.kt | |
@@ -1,3 +1,4 @@ | |
+/*·Licensed·under·MIT·*/ | |
package·dev.amadeu | |
import·io.ktor.application.* | |
@@ -10,7 +11,7 @@ | |
/** | |
·*·Conduit·API |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ktlint { | |
version = "0.34.0" | |
debug = true | |
verbose = true | |
android = false | |
outputToConsole = true | |
reporters = [ReporterType.CHECKSTYLE] | |
ignoreFailures = true | |
enableExperimentalRules = true | |
filter { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application( | |
_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
) -> Bool { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public final class StandardFileHandle: TextOutputStream { | |
fileprivate let handle: FileHandle | |
public static let error = StandardFileHandle(handle: .standardError) | |
public static let output = StandardFileHandle(handle: .standardOutput) | |
public static let null = StandardFileHandle(handle: .nullDevice) | |
public init(handle: FileHandle) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension URLSession { | |
func load(_ request: URLRequest, | |
_ completionHandler: @escaping (Result<(Data, HTTPURLResponse), ErrorEnvelope>) -> Void) { | |
dataTask(request) { result in | |
DispatchQueue.main.async { completionHandler(transformDataTask(result)) } | |
} | |
} | |
func dataTask(_ request: URLRequest, | |
_ completionHandler: @escaping (Result<(Data, HTTPURLResponse), AnyError>) -> Void) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//swiftlint:disable identifier_name redundant_void_return | |
precedencegroup ForwardApplication { | |
associativity: left | |
} | |
infix operator |>: ForwardApplication | |
public func |> <A, B>(x: A, f: (A) -> B) -> B { | |
return f(x) | |
} | |
public func |> <A: AnyObject>(x: A, f: (A) -> Void) -> Void { | |
f(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Amadeu Cavalcante Filho on 11/05/19. | |
// Copyright © 2019 Amadeu Cavalcante Filho. All rights reserved. | |
// | |
import Foundation | |
public struct Task<T, E: Error> { | |
public typealias Closure = (Controller<T, E>) -> Void | |
private let closure: Closure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func swizzle(_ bundle: Bundle.Type) { | |
[(#selector(bundle.localizedString(forKey:value:table:)), | |
#selector(bundle.rd_localizedString(forKey:value:table:)))] | |
.forEach { original, swizzled in | |
guard let originalMethod = class_getInstanceMethod(bundle, original), | |
let swizzledMethod = class_getInstanceMethod(bundle, swizzled) else { return } | |
let didAddMethod = class_addMethod( |