Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working from home

Amadeu Cavalcante amadeu01

:octocat:
Working from home
View GitHub Profile
View content.swift
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
@amadeu01
amadeu01 / build.gradle
Created Oct 4, 2019
Added custom ruleset
View build.gradle
dependencies {
//... Other dependencies
// Ktlint
ktlintRuleset project(":custom-ktlint-rules")
}
View build.gradle
spotless {
kotlin {
ktlint("$ktlint_version")
licenseHeader '/* Licensed under MIT */'
}
}
View gradle.build
plugins {
id "kotlin"
id 'application'
id "com.diffplug.gradle.spotless" version "$spotless_version"
}
View build.gradle
plugins {
id "kotlin"
id 'application'
id "org.jlleitschuh.gradle.ktlint" version "$ktlint_plugin_version"
}
ktlint {
version = "$ktlint_version"
debug = false
verbose = false
View custom_no_var.kt
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)
}
@amadeu01
amadeu01 / customRule.kt
Created Sep 14, 2019
Custom Rule for ktlint
View customRule.kt
class CustomRuleSetProvider : RuleSetProvider {
override fun get() = RuleSet("rules",
NoInternalImportRule(),
NoVarRule()
)
}
class NoInternalImportRule : Rule("no-internal-import") {
override fun visit(
node: ASTNode, autoCorrect: Boolean,
@amadeu01
amadeu01 / build.gradle
Created Aug 21, 2019
Set ktlint with html reporter
View build.gradle
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."
@amadeu01
amadeu01 / spotlessKotlin.txt
Created Aug 21, 2019
spotless kotlin lint
View spotlessKotlin.txt
src/ConduitAPIServer.kt
@@ -1,3 +1,4 @@
+/*·Licensed·under·MIT·*/
package·dev.amadeu
import·io.ktor.application.*
@@ -10,7 +11,7 @@
/**
·*·Conduit·API
@amadeu01
amadeu01 / build.gradle
Created Aug 21, 2019
Gradle config for ktlint
View build.gradle
ktlint {
version = "0.34.0"
debug = true
verbose = true
android = false
outputToConsole = true
reporters = [ReporterType.CHECKSTYLE]
ignoreFailures = true
enableExperimentalRules = true
filter {
You can’t perform that action at this time.