Are you over 18 and want to see adult content?
More Annotations
A complete backup of karnival-house.co.uk
Are you over 18 and want to see adult content?
A complete backup of recruitjobs.co.jp
Are you over 18 and want to see adult content?
A complete backup of nice-work.org.uk
Are you over 18 and want to see adult content?
A complete backup of opensocietyfoundations.org
Are you over 18 and want to see adult content?
A complete backup of searchtempest.com
Are you over 18 and want to see adult content?
A complete backup of gunnisoncrestedbutte.com
Are you over 18 and want to see adult content?
A complete backup of boardandvellum.com
Are you over 18 and want to see adult content?
Favourite Annotations
A complete backup of eestorlehoundmi.tk
Are you over 18 and want to see adult content?
A complete backup of nationalwatch.com
Are you over 18 and want to see adult content?
A complete backup of einstein-bern.ch
Are you over 18 and want to see adult content?
A complete backup of houseofmarbles.com
Are you over 18 and want to see adult content?
A complete backup of shirakawa-go.org
Are you over 18 and want to see adult content?
A complete backup of tirana-airport.com
Are you over 18 and want to see adult content?
Text
KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".KTLINT
ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options ). fiber_manual_record. Can I have my own rules on top of ktlint? Absolutely, "no configuration" doesn't mean "no extensibility".__
ktlint
Getting Started Rules FAQ GitHub Getting Started Rules FAQ GitHubktlint
An anti-bikeshedding Kotlin linter with built-in formatter.Getting Started
Command Line Maven GradleINSTALLATION
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.35.0/ktlint && chmod a+x ktlint # you can also download ktlint manually from https://github.com/pinterest/ktlint/releases # another option is "brew install ktlint" # verify PGP signature (optional but recommended) curl -sS https://keybase.io/pinterestandroid/pgp_keys.asc | gpg --import curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.35.0/ktlint.asc gpg --verify ktlint.ascUSAGE
# check the style of all Kotlin files inside the current dir (recursively) # (hidden folders will be skipped)$ ktlint
src/main/kotlin/Main.kt:10:10: Unused import # check only certain locations (prepend ! to negate the pattern) $ ktlint "src/**/*.kt" "!src/**/*Test.kt" # auto-correct style violations # (if some errors cannot be fixed automatically they will be printed to stderr) $ ktlint -F "src/**/*.kt" # print style violations grouped by file $ ktlint --reporter=plain?group_by_file # print style violations as usual + create report in checkstyle format $ ktlint --reporter=plain --reporter=checkstyle,output=ktlint-report-in-checkstyle-format.xml # install git hook to automatically check files for style violations on commit $ ktlint --install-git-pre-commit-hookINTEGRATION
Add the following snippet to pom.xml (insidektlint
USAGE
# check code style (it's also bound to "mvn verify") $ mvn antrun:run@ktlint src/main/kotlin/Main.kt:10:10: Unused import # fix code style deviations (runs built-in formatter) $ mvn antrun:run@ktlint-formatINTEGRATION
PLUGINS (RECOMMENDED) There are few community-driven plugins (in order of appearance): * jlleitschuh/ktlint-gradleGradle plugin that
automatically creates check and format tasks for project Kotlin sources, supports different kotlin plugins and Gradle build caching. * jeremymailen/kotlinter-gradleGradle plugin
featuring incremental build support, file reports, .kt & .kts sourcesupport.
* diffplug/spotless
Spotless is not really a plugin, it's a standalone project that happens to have a built-in ktlint support. In addition to linting/formatting kotlin code it allows you to keep license headers, markdown documentation, etc. in check.WITHOUT PLUGINS
Add the following snippet to build.gradle apply plugin: "java"repositories {
jcenter()
}
configurations {
ktlint
}
dependencies {
ktlint "com.pinterest:ktlint:0.35.0" // additional 3rd party ruleset(s) can be specified here // just add them to the classpath (ktlint 'groupId:artifactId:version') and // ktlint will pick them up}
task ktlint(type: JavaExec, group: "verification") { description = "Check Kotlin code style." main = "com.pinterest.ktlint.Main" classpath = configurations.ktlintargs "src/**/*.kt"
// to generate report in checkstyle format prepend following args: // "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml" // see https://github.com/pinterest/ktlint#usage for more}
check.dependsOn ktlint task ktlintFormat(type: JavaExec, group: "formatting") { description = "Fix Kotlin code style deviations." main = "com.pinterest.ktlint.Main" classpath = configurations.ktlint args "-F", "src/**/*.kt"}
USAGE
# check code style (it's also bound to "gradle check")$ gradle ktlint
src/main/kotlin/Main.kt:10:10: Unused import # fix code style deviations (runs built-in formatter) $ gradle ktlintFormatRules
4 SPACES FOR INDENTATION*.Do.
data class C(
val a: Any,
val b: Any = 0,
val c: Any
) {}
Don't.
data class C(val a: Any,val b: Any = 0,
val c: Any) {
}
* Starting from 0.8.0value of
indent_size specified under section in .editorconfig takes precedence (if any). Official recommendation is to use 4 spaces, though. (see #43for details)
NO SEMICOLONS.
Do.
val v = ""
println(v)
// semicolons used to separate multiple statements on the same line are OK // try avoid though fn({ v -> println(v); v * 10 })Don't.
val v = "";
println(v);
NO WILDCARD / UNUSED IMPORTS.Do.
import io.vertx.core.Vertx import com.google.Guice import com.google.InjectorDon't.
import io.vertx.core.* import com.google.inject.* import pkg.UnusedClass NO CONSECUTIVE BLANK LINES.Do.
class A {}
class B {}
Don't.
// this in not a Python and you are not in PEP 8 realmclass A {}
class B {}
NO TRAILING WHITESPACES.Do.
class A {}
class B {}
Don't.
class A {}⋅⋅⋅class B {}⋅
* If you don't use EditorConfig it's a good time to start.NO UNIT RETURNS.
Do.
fun f() {}
Don't.
fun f(): Unit {}
NO EMPTY CLASS BODIES.Do.
class A
interface B
Don't.
class A {}
interface B {}
CONSISTENT STRING TEMPLATES.Do.
val a = "class = ${String::class}" val b = "not $a"Don't.
val a = "class = ${String::class.toString()}" val b = "not ${a}" CONSISTENT ORDER OF MODIFIERS.Do.
internal abstract class A { protected open val v = "" internal open suspend fun f(v: Any): Any = "" public lateinit var lv: String abstract tailrec fun findFixPoint(x: Double = 1.0): Double}
class B : A() {
public override val v = "" suspend override fun f(v: Any): Any = "" tailrec override fun findFixPoint(x: Double): Double = if (x == Math.cos(x)) x else findFixPoint(Math.cos(x))}
Don't.
abstract internal class A { open protected val v = "" open suspend internal fun f(v: Any): Any = "" lateinit public var lv: String tailrec abstract fun findFixPoint(x: Double = 1.0): Double}
class B : A() {
override public val v = "" override suspend fun f(v: Any): Any = "" override tailrec fun findFixPoint(x: Double): Double = if (x == Math.cos(x)) x else findFixPoint(Math.cos(x))}
CONSISTENT SPACING.
Do.
val short = ""
val long = ""
val v = a - b * c class A : B, C {}if (true) {}
@file:JvmName("Main")class A : B
call(object : C() {}) fun fn(@field:F a: Any, b: Any, c: Any): Any val v: String = str() if (ok) { /* .. */ } fn({ v -> f(v) * g(v) }) emptyList().find { true }!!.hashCode() find { it.default ?: false }?.phoneDon't.
// multiple spaces after "val long" for vertical alignmentval short = ""
val long = ""
// no spacing around operatorsval v=a-b*c
// no space after the comma class A : B,C {} // no spacing after keyword ("if" in this case)if(true) {}
// incorrect spacing around ":" @file: JvmName("Main")class A:B
call(object: C() {}) fun fn(@field: F a:Any, b:Any, c:Any):Any val v:String = str() // missing spacing around "{" and before "}" if (true){/* .. */} // missing spacing after "{" and before "}" fn({v -> f(v) * g(v)}!!) // unnecessary space after "}" emptyList().find { true } !!.hashCode() find { it.default ?: false } ?.phoneFAQ
_FIBER_MANUAL_RECORD_WHY SHOULD I USE KTLINT?SIMPLICITY.
Spending time on configuration (& maintenance down the road) of hundred-line long style config file(s) is counter-productive. Instead of wasting your energy on something that has no business value - focus on what really matters (not debating whether to use tabs or spaces). By using ktlint you put the importance of code clarity and community conventions over personal preferences. This makes things easier for people reading your code as well as frees you from having to document & explain what style potential contributor(s) have to follow. ktlint is a single binary with both linter & formatter included. All you need is to drop it in (no need to get overwhelmed while choosing among dozens of code style options).
_FIBER_MANUAL_RECORD_CAN I HAVE MY OWN RULES ON TOP OF KTLINT? Absolutely, "no configuration" doesn't mean "no extensibility". You can add your own ruleset(s) to discover potential bugs, check foranti-patterns, etc.
See Creating A Ruleseton GitHub.
_FIBER_MANUAL_RECORD_HOW DO I SUPPRESS AN ERROR? This is meant primarily as an escape latch for the rare cases when ktlint is not able to produce the correct result (please report any such instances using GitHub Issues).
To disable a specific rule you'll need to turn on the verbose mode (ktlint --verbose ...). At the end of each line you'll see an error code. Use it as an argument for ktlint-disable directive (shownbelow).
import package.* // ktlint-disable no-wildcard-imports /* ktlint-disable no-wildcard-imports */import package.a.*
import package.b.*
/* ktlint-enable no-wildcard-imports */ To disable all checks: import package.* // ktlint-disable _FIBER_MANUAL_RECORD_HOW DO I GLOBALLY DISABLE A RULE? See the EditorConfigsection on GitHub.
You may also use the --disabled_rules command line flag._favorite_
Details
Copyright © 2024 ArchiveBay.com. All rights reserved. Terms of Use | Privacy Policy | DMCA | 2021 | Feedback | Advertising | RSS 2.0