This file contains 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 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 android.app.IntentService; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Build; | |
import com.crashlytics.android.answers.Answers; | |
import com.crashlytics.android.answers.CustomEvent; | |
import com.klinker.android.send_message.ApnUtils; | |
import com.klinker.android.send_message.Message; |
This file contains 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 SwiftUI | |
import UIKit | |
class CustomLargeTitleNavigationBar: UINavigationBar { | |
private lazy var view: UIView = { | |
let view = UIView() | |
view.backgroundColor = .red | |
view.translatesAutoresizingMaskIntoConstraints = false | |
view.widthAnchor.constraint(equalToConstant: 200).isActive = true |
This file contains 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 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
dependencies { | |
//... Other dependencies | |
// Ktlint | |
ktlintRuleset project(":custom-ktlint-rules") | |
} |
This file contains 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
spotless { | |
kotlin { | |
ktlint("$ktlint_version") | |
licenseHeader '/* Licensed under MIT */' | |
} | |
} |
This file contains 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
plugins { | |
id "kotlin" | |
id 'application' | |
id "com.diffplug.gradle.spotless" version "$spotless_version" | |
} |
This file contains 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
plugins { | |
id "kotlin" | |
id 'application' | |
id "org.jlleitschuh.gradle.ktlint" version "$ktlint_plugin_version" | |
} | |
ktlint { | |
version = "$ktlint_version" | |
debug = false | |
verbose = false |
This file contains 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 NoVarRule : Rule("no-var") { | |
override fun visit( | |
node: ASTNode, | |
autoCorrect: Boolean, | |
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit | |
) { | |
if (node.elementType == VAR_KEYWORD) { | |
emit(node.startOffset, "😱 Unexpected var, use val instead 🏄", false) | |
} |
This file contains 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, |
NewerOlder