Kotlin rules
tx0 checks .kt and .kts files with 280 rules, 38 of them in the default tier. Files that say a tool generated them are skipped. Each rule's page explains what it finds and what it leaves alone.
Default: 38 rules
Bugs and security problems with measured precision. They run without a tx0.toml.
-
tx0/kotlin:accept-any-hostnamedefaultA hostname verifier accepts every host, so a certificate for any name passes
-
tx0/kotlin:assert-on-same-expressiondefaultAn assertion compares an expression with itself, so it always passes or always fails
-
tx0/kotlin:catch-after-broader-catchdefaultA
catchclause follows one for a supertype of its exception, so it never runs -
tx0/kotlin:compare-to-exact-valuedefaultThe result of
compareTois tested for equality with a value other than zero -
tx0/kotlin:compared-with-nandefaultA value is compared with
NaN, which equals nothing, itself included -
tx0/kotlin:cookie-readable-by-scriptsdefaultA cookie is marked as not
HttpOnly, so scripts in the page can read it -
tx0/kotlin:cookie-sent-over-httpdefaultA cookie is marked as not secure, so it is also sent over unencrypted connections
-
tx0/kotlin:decimal-from-binary-fractiondefaultA
BigDecimalis made from a double literal and holds its binary approximation -
tx0/kotlin:duplicate-if-conditiondefaultA condition in a chain of
ifandelse ifrepeats an earlier one, so its branch never runs -
tx0/kotlin:duplicate-key-in-literal-mapdefaultmapOforsetOflists the same literal key or element twice, so one of them is lost -
tx0/kotlin:duplicate-when-conditiondefaultA
whencondition repeats an earlier one, so its branch never runs for that value -
tx0/kotlin:empty-rangedefaultA range of literals is empty because its start is past its end
-
tx0/kotlin:equals-ignores-argumentdefaultequalsreturnstrueorfalsefor every argument -
tx0/kotlin:equals-null-calldefaultequals(null)is false for every receiver that is not null -
tx0/kotlin:equals-without-hashcodedefaultA class overrides
equalswithouthashCode -
tx0/kotlin:exception-not-throwndefaultAn exception object is built and discarded, and nothing raises it
-
tx0/kotlin:flow-emits-from-other-contextdefaultA
flowbuilder emits from insidewithContext, which the flow fails on at run time -
tx0/kotlin:format-argument-countdefaultA format string asks for more or fewer arguments than are passed
-
tx0/kotlin:has-next-calls-nextdefaultAn iterator's
hasNextcallsnext, which moves the iterator instead of only looking -
tx0/kotlin:identical-operandsdefaultBoth operands of an operator or comparison are the same
-
tx0/kotlin:literal-cast-to-other-typedefaultA string literal is cast to a number type, or a number literal to
String, which always fails -
tx0/kotlin:lock-on-literaldefaultsynchronizedlocks a literal, an object that unrelated code may lock too -
tx0/kotlin:misleading-if-indentationdefaultA statement after an
ifwithout braces is indented like theifbranch, but runs unconditionally -
tx0/kotlin:mutation-during-iterationdefaultA collection is changed while a loop iterates over it, which throws
ConcurrentModificationException -
tx0/kotlin:postfix-increment-assigned-backdefaultx = x++assigns the old value back, so the increment is lost -
tx0/kotlin:preferences-edit-not-applieddefaultChanges to
SharedPreferencesare made in an editor that is never applied -
tx0/kotlin:run-blocking-in-coroutinedefaultrunBlockingis called in a coroutine and blocks the thread it runs on -
tx0/kotlin:self-assignmentdefaultAn assignment writes back the value the variable already holds
-
tx0/kotlin:sleep-in-coroutinedefaultThread.sleepblocks the thread of a coroutine instead of suspending it -
tx0/kotlin:synchronized-suspend-functiondefaultA
suspendfunction is marked@Synchronized, whose lock is released at every suspension -
tx0/kotlin:thread-never-starteddefaultA
Threadis created as a statement and never started -
tx0/kotlin:toast-not-showndefaultA
Toastis made and never shown -
tx0/kotlin:trust-all-certificatesdefaultA trust manager accepts every certificate, which turns off TLS server authentication
-
tx0/kotlin:unconditional-self-calldefaultA function calls itself with its own arguments before doing anything else, and never returns
-
tx0/kotlin:unreachable-codedefaultA statement follows a
return,throw,breakorcontinueand never runs -
tx0/kotlin:webview-ignores-certificate-errorsdefaultA
WebViewClientanswers certificate errors by proceeding, which turns off TLS checking for the web view -
tx0/kotlin:webview-mixed-contentdefaultA
WebViewis allowed to load plain HTTP content into HTTPS pages -
tx0/kotlin:world-accessible-filedefaultA file is made readable or writable by every user of the system
Recommended: 114 rules
Likely bugs, resource and performance problems.
-
tx0/kotlin:abs-can-be-negativerecommendedThe absolute value of a hash code or random integer is taken, which is negative for the minimum value
-
tx0/kotlin:allocation-in-drawrecommendedAn object such as a
PaintorRectis created inonDraw,onMeasureoronLayout, which run for every frame -
tx0/kotlin:array-equalityrecommendedArrays are compared with
==, which compares their identity, not their elements -
tx0/kotlin:array-to-stringrecommendedAn array is turned into a string, which shows its type and address, not its elements
-
tx0/kotlin:assert-equals-with-booleanrecommendedassertEqualscompares withtrueorfalse, whichassertTrueandassertFalsesay directly -
tx0/kotlin:assertion-arguments-swappedrecommendedassertEqualsgets the literal expected value second, so a failure reports the values the wrong way round -
tx0/kotlin:async-awaited-at-oncerecommendedasync { }is awaited right away, so nothing runs concurrently with it -
tx0/kotlin:async-taskrecommendedA class extends
AsyncTask, which Android deprecated for leaking and losing work -
tx0/kotlin:atomic-read-then-writerecommendedAn atomic is set to a value computed from its own
get(), which loses updates made in between -
tx0/kotlin:broken-digest-algorithmrecommendedA hash is computed with MD5 or SHA-1, which are broken for security uses
-
tx0/kotlin:catch-that-only-rethrowsrecommendedA
catchblock only throws the caught exception again -
tx0/kotlin:char-literal-to-numberrecommendedA character literal is converted with
toInt()or a similar deprecated function, which gives its code, not its digit -
tx0/kotlin:command-built-from-stringsrecommendedA shell command is built from strings with values in them
-
tx0/kotlin:comparison-result-unusedrecommendedA comparison or type check is a statement of its own, and its result is dropped
-
tx0/kotlin:concurrent-map-check-then-putrecommendedA concurrent map is checked with
containsKeyand then written, which races with other writers -
tx0/kotlin:constant-hash-coderecommendedhashCodereturns the same constant for every object, which puts all of them in one bucket of a hash table -
tx0/kotlin:constant-initialization-vectorrecommendedAn initialization vector is written in the code, so every encryption reuses it
-
tx0/kotlin:constant-saltrecommendedA password is hashed or a key derived with a salt written in the code
-
tx0/kotlin:cors-allows-any-originrecommendedCross-origin requests are allowed from every origin
-
tx0/kotlin:data-class-array-propertyrecommendedA data class has an array property, which its
equalsandhashCodecompare by identity -
tx0/kotlin:date-format-without-localerecommendedA
SimpleDateFormatis created without a locale, so the output changes with the device -
tx0/kotlin:decimal-equality-with-scalerecommended==on aBigDecimaltreats 2.0 and 2.00 as different values -
tx0/kotlin:deprecated-coroutine-test-apirecommendedA test uses
runBlockingTest,TestCoroutineDispatcherorTestCoroutineScope, which the test library replaced -
tx0/kotlin:division-by-literal-zerorecommendedA value is divided by the integer literal
0 -
tx0/kotlin:documented-parameter-missingrecommendedA documentation comment describes a
@paramthat the function or class does not have -
tx0/kotlin:dropped-async-resultrecommendedThe
Deferredofasyncis dropped, so its result is never awaited -
tx0/kotlin:dynamic-dependency-versionrecommendedA dependency version ends in
+or islatest, so each build may resolve a different one -
tx0/kotlin:elvis-returns-nullrecommended?: nullgivesnullwhen the value is alreadynull -
tx0/kotlin:empty-blockrecommendedAn
if,else, loop,init,tryorfinallyblock is empty -
tx0/kotlin:empty-catchrecommendedA
catchblock is empty, so the exception disappears without a trace -
tx0/kotlin:equals-with-narrow-parameterrecommendedequalsis declared with a parameter other thanAny?, which overloads instead of overriding -
tx0/kotlin:executor-never-shut-downrecommendedA local thread pool is created and never shut down, so its threads outlive the function
-
tx0/kotlin:exposed-mutable-state-holderrecommendedA public property holds a
MutableStateFlow,MutableSharedFloworMutableLiveData, so any caller can change the state -
tx0/kotlin:few-key-derivation-iterationsrecommendedA password-based key is derived with fewer than 10,000 iterations
-
tx0/kotlin:float-literal-equalityrecommendedA value is compared with
==to a decimal fraction that no float or double holds exactly -
tx0/kotlin:fragment-transaction-not-committedrecommendedA fragment transaction is begun and never committed
-
tx0/kotlin:fragment-view-observed-with-fragmentrecommendedA fragment observes data for its view with itself as the lifecycle owner, which outlives the view
-
tx0/kotlin:geolocation-granted-to-every-originrecommendedA
WebViewgrants location access to every page that asks -
tx0/kotlin:global-scope-coroutinerecommendedA coroutine is started in
GlobalScope, which no caller can cancel or wait for -
tx0/kotlin:handler-without-looperrecommendedA
Handleris created without aLooper, taking the current thread's implicitly -
tx0/kotlin:hardcoded-credentialrecommendedA password, secret or token is written in the code
-
tx0/kotlin:hardcoded-crypto-keyrecommendedA secret key is built from bytes written in the code
-
tx0/kotlin:identical-if-branchesrecommendedBoth branches of an
ifdo the same thing -
tx0/kotlin:identity-comparison-with-literalrecommended===compares identity with a literal, whose instances may or may not be shared -
tx0/kotlin:if-yields-boolean-literalsrecommendedAn
ifgivestruein one branch andfalsein the other -
tx0/kotlin:insecure-build-repositoryrecommendedA build repository or cache is reached over plain HTTP, so what it hands out can be replaced on the way
-
tx0/kotlin:insecure-temp-filerecommendedA temporary file or directory is created with
kotlin.io'screateTempFileorcreateTempDir, which use default permissions -
tx0/kotlin:integer-literal-division-truncatesrecommendedTwo integer literals are divided and the fraction is lost
-
tx0/kotlin:interrupt-status-lostrecommendedAn
InterruptedExceptionis caught and neither rethrown nor the thread's interrupt flag restored -
tx0/kotlin:job-passed-to-coroutine-builderrecommendedA new
Jobis passed to a coroutine builder, cutting the coroutine off from its parent -
tx0/kotlin:lateinit-never-assignedrecommendedA private
lateinitproperty is read but never assigned in its file -
tx0/kotlin:lifecycle-launch-whenrecommendedlaunchWhenStartedand its kind pause a coroutine instead of cancelling it -
tx0/kotlin:literal-boolean-conditionrecommendedAn
iforwhiletests the literaltrueorfalse -
tx0/kotlin:locale-dependent-case-conversionrecommendedtoUpperCase,toLowerCase,capitalizeordecapitalizeconverts case by the default locale -
tx0/kotlin:lock-without-finallyrecommendedA lock is taken with
lock()and the next statement is not atrythat unlocks it infinally -
tx0/kotlin:loop-ends-in-first-passrecommendedThe body of a loop always ends with
return,breakorthrow, so it runs at most once -
tx0/kotlin:loop-past-last-indexrecommendedA loop runs from 0 up to and including the size, one past the last index
-
tx0/kotlin:nested-implicit-itrecommendedA lambda uses the implicit
itinside another lambda that has an implicitittoo -
tx0/kotlin:nesting-weighted-complexityrecommendedA function is harder to follow than the configured maximum, counting branches by how deeply they are nested
-
tx0/kotlin:null-check-returns-samerecommendedif (x != null) x else nullgives backxin both cases -
tx0/kotlin:odd-check-with-remainderrecommendedx % 2 == 1is false for negative odd numbers, whose remainder is -1 -
tx0/kotlin:override-only-calls-superrecommendedAn override only calls the overridden function with the same arguments
-
tx0/kotlin:pending-intent-without-mutabilityrecommendedA
PendingIntentis created without saying whether it is immutable -
tx0/kotlin:predictable-random-for-secretrecommendedA token, password or key is made from a random generator that is not cryptographically secure
-
tx0/kotlin:print-stack-tracerecommendedprintStackTrace()writes an exception to standard error instead of a log -
tx0/kotlin:private-member-never-usedrecommendedA private function or property is never used in its file
-
tx0/kotlin:protected-in-final-classrecommendedA member of a final class or an object is
protected, which acts asprivatethere -
tx0/kotlin:random-created-per-userecommendedA
Randomis created to draw a single number -
tx0/kotlin:receiver-without-export-flagrecommendedA broadcast receiver is registered without saying whether other apps may send to it
-
tx0/kotlin:recursive-property-accessorrecommendedA property's getter reads the property, or its setter assigns it, instead of
field -
tx0/kotlin:redundant-not-null-assertionrecommended!!is applied to a value that can never be null -
tx0/kotlin:redundant-safe-callrecommended?.is used on a value that can never be null -
tx0/kotlin:regex-compiled-in-looprecommendedA regular expression with a constant pattern is compiled inside a loop
-
tx0/kotlin:repeated-conversionrecommendedA collection is converted twice in a row with the same function, which copies the copy
-
tx0/kotlin:request-path-in-file-accessrecommendedA file is opened or resolved at a path taken from an HTTP request without a check
-
tx0/kotlin:return-from-for-eachrecommendedA
returnwithout a label in aforEachlambda returns from the enclosing function, not from the lambda -
tx0/kotlin:return-in-finallyrecommendedA
finallyblock returns or jumps, which discards an exception in flight -
tx0/kotlin:rsa-without-oaeprecommendedRSA encryption is set up without OAEP padding
-
tx0/kotlin:run-blocking-on-main-threadrecommendedrunBlockingis called on the Android main thread, which freezes the interface while it waits -
tx0/kotlin:run-catching-in-coroutinerecommendedrunCatchingwraps code in a coroutine and turns its cancellation into a failed result -
tx0/kotlin:safe-call-then-not-nullrecommendedA safe call is followed by
!!, which throws when the safe call gavenull -
tx0/kotlin:safe-cast-then-assertrecommended(x as? T)!!turns a failed cast into aNullPointerExceptioninstead of aClassCastException -
tx0/kotlin:secret-in-shared-preferencesrecommendedA password, token or key is stored in plain
SharedPreferences -
tx0/kotlin:secret-written-to-logrecommendedA password, token or secret is written to a log
-
tx0/kotlin:seeded-secure-randomrecommendedA
SecureRandomis seeded with a constant, which makes its output predictable -
tx0/kotlin:self-recursive-equals-or-tostringrecommendedequalsuses==onthis, ortoStringusesthisin a string, and calls itself forever -
tx0/kotlin:sequence-converted-back-at-oncerecommendedA collection is turned into a sequence and straight back into a list, which copies it for nothing
-
tx0/kotlin:sha1prng-secure-randomrecommendedA
SecureRandomis requested with theSHA1PRNGalgorithm, whose output can be predictable when seeded -
tx0/kotlin:shared-date-formatrecommendedA
SimpleDateFormator otherjava.textformat is kept in a shared property, though it is not thread-safe -
tx0/kotlin:short-rsa-keyrecommendedAn RSA or DSA key pair generator is set to fewer than 2048 bits
-
tx0/kotlin:sql-built-from-stringsrecommendedAn SQL query is built from strings with values in them
-
tx0/kotlin:string-grown-in-looprecommendedA string variable is extended with
+=inside a loop, which copies the whole string each time -
tx0/kotlin:suspend-coroutine-scope-extensionrecommendedA
suspendfunction extendsCoroutineScope, mixing two ways to run concurrent work -
tx0/kotlin:suspend-function-returns-flowrecommendedA
suspendfunction returns aFlow, which is cold and needs no suspension to create -
tx0/kotlin:suspend-without-callsrecommendedA
suspendfunction calls nothing, so it can never suspend -
tx0/kotlin:thread-run-instead-of-startrecommendedrun()is called on aThread, which runs the work on the calling thread -
tx0/kotlin:throw-in-equals-hashcode-tostringrecommendedequals,hashCodeortoStringthrows, though callers such as collections and loggers expect them to return -
tx0/kotlin:throw-in-finallyrecommendedA
finallyblock throws, which replaces an exception in flight -
tx0/kotlin:throwaway-coroutine-scoperecommendedA coroutine is started in a scope created on the spot, which nothing keeps to cancel
-
tx0/kotlin:todo-callrecommendedTODO()is called, which throwsNotImplementedErrorwhen the code runs -
tx0/kotlin:typed-array-not-recycledrecommendedStyled attributes are obtained and the
TypedArrayis never recycled -
tx0/kotlin:unary-operator-on-own-linerecommendedA
-or+expression on the line after an assignment is a statement of its own, and its value is dropped -
tx0/kotlin:unclosed-stream-in-chainrecommendedA stream or reader is opened and used in one expression, so nothing ever closes it
-
tx0/kotlin:unused-importrecommendedAn import is not used in the file
-
tx0/kotlin:unused-variablerecommendedA local variable is declared and never read
-
tx0/kotlin:var-could-be-valrecommendedA local
varis never assigned after its declaration -
tx0/kotlin:volatile-compound-updaterecommendedA
@Volatileproperty is updated with++or+=, which is not atomic -
tx0/kotlin:wake-lock-without-timeoutrecommendedA wake lock is acquired without a timeout, so a missed release drains the battery
-
tx0/kotlin:weak-cipherrecommendedA cipher is created with a broken algorithm or ECB mode
-
tx0/kotlin:weak-tls-versionrecommendedA TLS context is created for SSL or TLS 1.0 or 1.1, which are broken
-
tx0/kotlin:webview-debugging-enabledrecommendedRemote debugging of web views is turned on unconditionally
-
tx0/kotlin:webview-file-accessrecommendedA
WebViewis allowed to read local files, or to let pages read them -
tx0/kotlin:xml-parser-without-hardeningrecommendedAn XML parser factory is created and never configured against external entities
-
tx0/kotlin:zip-entry-path-traversalrecommendedA file is created from the name of an archive entry without checking that it stays in the target directory
Strict: 100 rules
Code that can be written more plainly.
-
tx0/kotlin:abstract-class-without-abstract-memberstrictAn abstract class declares no abstract member
-
tx0/kotlin:arithmetic-identitystrictA value is multiplied or divided by 1, or 0 is subtracted from it
-
tx0/kotlin:array-of-boxed-primitivesstrictAn
Array<Int>or similar holds boxed numbers where a primitive array would not -
tx0/kotlin:assert-true-with-comparisonstrictassertTrue(a == b)hides the two values that a failed comparison would show -
tx0/kotlin:biometric-without-crypto-objectstrictBiometric authentication is requested without a
CryptoObject, so its success protects no key -
tx0/kotlin:broadcast-without-permissionstrictAn implicit intent is broadcast without a receiver permission, so any app can receive it
-
tx0/kotlin:case-converted-for-comparisonstrictTwo strings are compared after converting both to the same case
-
tx0/kotlin:catch-generic-exceptionstrictA
catchcatchesExceptionorRuntimeExceptionrather than the failures expected -
tx0/kotlin:catch-programming-errorstrictA
catchcatches an exception that signals a bug, such asNullPointerException -
tx0/kotlin:catch-throwablestrictA
catchcatchesThrowableorError, which includes failures the program cannot handle -
tx0/kotlin:class-namingstrictA class, object or type alias name does not start with an uppercase letter or has underscores
-
tx0/kotlin:cleartext-http-urlstrictA connection goes to an
http://URL, unencrypted -
tx0/kotlin:code-in-commentstrictA comment holds code that was switched off
-
tx0/kotlin:collapsible-ifstrictAn
ifwithoutelseholds only anotherifwithoutelse -
tx0/kotlin:complex-boolean-expressionstrictA condition combines more
&&and||operators than the configured maximum -
tx0/kotlin:console-outputstrictCode prints to standard output or standard error instead of using a logger
-
tx0/kotlin:constant-namingstrictA
const valis not named in upper case with underscores -
tx0/kotlin:contains-on-map-viewstrictkeys.containsorvalues.containsis called where the map answers directly -
tx0/kotlin:csrf-protection-disabledstrictProtection against cross-site request forgery is turned off
-
tx0/kotlin:cyclomatic-complexitystrictA function has more independent paths than the configured maximum
-
tx0/kotlin:dedicated-thread-contextstrictA coroutine dispatcher with threads of its own is created, which has to be closed
-
tx0/kotlin:deep-nestingstrictControl structures are nested deeper than the configured maximum
-
tx0/kotlin:disabled-test-without-reasonstrictA test is disabled with
@Ignoreor@Disabledwithout saying why -
tx0/kotlin:duplicate-when-branchstrictTwo branches of a
whenhave the same body, so their conditions could be one branch -
tx0/kotlin:empty-function-bodystrictA function that is neither an override nor open has an empty body and no comment
-
tx0/kotlin:empty-primary-constructorstrictA class declares an empty primary constructor
() -
tx0/kotlin:equals-unchecked-caststrictequalscasts its argument without checking its type, throwing instead of returningfalse -
tx0/kotlin:exception-without-messagestrictA standard exception is thrown without a message
-
tx0/kotlin:exit-outside-mainstrictThe process is ended outside
main, which skips the caller's cleanup -
tx0/kotlin:explicit-garbage-collectionstrictGarbage collection is requested explicitly
-
tx0/kotlin:explicit-it-parameterstrictA lambda names its only parameter
it, which it is called anyway -
tx0/kotlin:filter-before-predicate-callstrictfilteris followed by a call that takes the same predicate itself -
tx0/kotlin:filter-then-sizestrictfilter { }.sizebuilds a list only to count it, whichcount { }does without the list -
tx0/kotlin:flow-collected-without-lifecyclestrictA flow is collected in
lifecycleScopewithoutrepeatOnLifecycle, so it keeps running while the screen is stopped -
tx0/kotlin:for-each-over-rangestrict(a..b).forEach { }creates a range object where aforloop does not -
tx0/kotlin:function-namingstrictA function name starts with an uppercase letter or has underscores
-
tx0/kotlin:hardcoded-dispatcherstrictA dispatcher is named in place, which tests cannot replace
-
tx0/kotlin:hardcoded-ip-addressstrictA string literal holds a public network address
-
tx0/kotlin:inflate-without-parentstrictA layout is inflated with
nullas parent, so the layout parameters of its root are dropped -
tx0/kotlin:inline-without-function-parameterstrictAn
inlinefunction takes no function and has noreifiedtype parameter -
tx0/kotlin:invalid-regexstrictA regular expression literal is malformed, so compiling it throws
-
tx0/kotlin:java-deserializationstrictObjects are read with Java serialization, which runs code chosen by the data
-
tx0/kotlin:jdbc-index-zerostrictA JDBC parameter or column is addressed with index 0 or less, but they are numbered from 1
-
tx0/kotlin:jvm-assert-callstrictassertis called, which the JVM skips unless assertions are enabled with-ea -
tx0/kotlin:lateinit-compared-with-nullstrictA
lateinitproperty is compared withnull, which it never is, as reading it unassigned throws -
tx0/kotlin:legacy-date-apistrictjava.util.DateorCalendaris used wherejava.timeoffers immutable types -
tx0/kotlin:local-shadows-outer-namestrictA local variable or lambda parameter has the name of a parameter or local variable of the enclosing function
-
tx0/kotlin:long-filestrictA file has more lines of code than the configured maximum
-
tx0/kotlin:long-functionstrictA function has more lines of code than the configured maximum
-
tx0/kotlin:lost-exception-causestrictA
catchblock throws a new exception without the caught one as its cause -
tx0/kotlin:map-index-assertedstrictmap[key]!!asserts a missing key into aNullPointerException, wheregetValuesays which key was missing -
tx0/kotlin:map-then-filter-not-nullstrictmapis followed byfilterNotNull, whichmapNotNulldoes in one pass -
tx0/kotlin:map-then-flattenstrictmapis followed byflatten, whichflatMapdoes without the list in between -
tx0/kotlin:mutable-collection-in-varstrictA
varholds a mutable collection, so it can change in two ways -
tx0/kotlin:mutable-data-class-propertystrictA data class has a
varproperty, so its equality and hash code change over time -
tx0/kotlin:mutable-global-statestrictAn object or the top level holds a public
var, state that any code can change -
tx0/kotlin:negative-size-checkstrictA size or length is compared with 0 in a way that is always true or always false
-
tx0/kotlin:not-null-assertionstrict!!turns a possiblenullinto aNullPointerException -
tx0/kotlin:notify-data-set-changedstrictA list adapter reports that all of its data changed
-
tx0/kotlin:npe-thrown-by-handstrictCode raises
NullPointerExceptionitself instead of naming the missing value -
tx0/kotlin:number-format-without-localestrictNumbers are formatted with
String.formatorformatwithout a locale, so the output changes with the device -
tx0/kotlin:open-redirectstrictA handler redirects to a location taken from the request without a check
-
tx0/kotlin:parameter-count-limitstrictA function or constructor has more parameters than the configured maximum
-
tx0/kotlin:preferences-commit-unused-resultstrictPreference changes are saved with
commit()whose result is ignored, which writes to disk on the calling thread -
tx0/kotlin:public-mutable-collectionstrictA public property holds a mutable collection, so callers can change it behind the class's back
-
tx0/kotlin:redundant-semicolonstrictA
;ends a statement that a line break ends anyway -
tx0/kotlin:redundant-template-bracesstrictA string template puts a simple name in braces
-
tx0/kotlin:redundant-tostring-in-templatestricttoString()is called inside a string template, which converts to a string anyway -
tx0/kotlin:redundant-unit-return-typestrictA function with a block body declares
Unitas its return type -
tx0/kotlin:regex-anchor-binds-one-alternativestrictA ^ or $ in a regular expression applies only to the first or last alternative, not to all of them
-
tx0/kotlin:regex-duplicate-alternativestrictAn alternative of a regular expression repeats an earlier one, so it can never be the one that matches
-
tx0/kotlin:regex-empty-repeatstrictAn unbounded repetition in a regular expression repeats a part that can match nothing
-
tx0/kotlin:regex-exponential-backtrackingstrictA regular expression takes exponential time on some inputs, confirmed with an input that shows it
-
tx0/kotlin:regex-impossible-lookaheadstrictA lookahead in a regular expression contradicts the character that follows it, so the pattern never matches
-
tx0/kotlin:regex-possessive-starvesstrictA possessive quantifier takes the characters that the next part of the regular expression needs, so it never matches
-
tx0/kotlin:regex-unmatchable-anchorstrictA ^ or $ in a regular expression stands where it can never match, so the pattern never matches
-
tx0/kotlin:regex-unmatched-backreferencestrictA pattern refers back to a capture that does not exist yet at that point
-
tx0/kotlin:repeated-string-literalstrictThe same string literal is written several times in a file
-
tx0/kotlin:request-url-fetchedstrictA server connects to an address taken from an incoming request without a check
-
tx0/kotlin:reversed-compound-assignmentstrict=+or=-assigns a signed value where+=or-=was meant -
tx0/kotlin:self-bulk-operationstrictA collection is passed to its own
addAll,removeAll,retainAllorcontainsAll -
tx0/kotlin:shared-external-storagestrictFiles are put in shared external storage, where other apps can read them
-
tx0/kotlin:single-branch-whenstrictA
whenhas a single branch, which reads more simply as anif -
tx0/kotlin:size-compared-with-zerostrictsize,lengthorcount()is compared with zero instead of usingisEmpty() -
tx0/kotlin:sort-to-take-onestrictA collection is sorted only to take its first or last element
-
tx0/kotlin:static-context-referencestrictA
Context, activity, fragment or view is kept in a static property, which leaks it -
tx0/kotlin:swallowed-cancellationstrictA
CancellationExceptionis caught and not thrown again, so the coroutine keeps running -
tx0/kotlin:test-waits-with-sleepstrictA test waits with
Thread.sleep, which makes it slow and flaky -
tx0/kotlin:throw-instead-of-requirestrictAn
ifthrowsIllegalArgumentExceptionorIllegalStateException, whichrequireandchecksay directly -
tx0/kotlin:todo-commentstrictA comment marks work left to do with
TODOorFIXME -
tx0/kotlin:too-many-functionsstrictA class, object or file declares more functions than the configured maximum
-
tx0/kotlin:too-many-returnsstrictA function has more
returnstatements than the configured maximum -
tx0/kotlin:type-check-in-catchstrictA
catchblock tests the type of the caught exception, which separatecatchclauses express directly -
tx0/kotlin:unconfined-dispatcherstrictDispatchers.Unconfinedruns a coroutine on whatever thread resumes it -
tx0/kotlin:unnecessary-letstrictletonly calls a member on its argument, which a plain or safe call does directly -
tx0/kotlin:unspecific-exception-raisedstrictException,RuntimeException,ThrowableorErroris thrown, which callers cannot tell apart -
tx0/kotlin:unused-parameterstrictA parameter of a private function is never read
-
tx0/kotlin:values-instead-of-entriesstrictvalues()of an enum is called, which copies the array of entries each time, whereentriesdoes not -
tx0/kotlin:webview-javascript-enabledstrictJavaScript is enabled in a
WebView, which runs scripts of every page it loads -
tx0/kotlin:webview-javascript-interfacestrictAn object is exposed to the scripts of a
WebView
: 28 rules
-
tx0/kotlin:array-call-in-annotationallAn annotation argument uses
arrayOf(...)where the literal[...]is allowed -
tx0/kotlin:deprecated-without-replacementall@Deprecatedgives noReplaceWith, so callers are not told what to use instead -
tx0/kotlin:else-after-returnallAn
ifbranch ends withreturn,throw,breakorcontinueand is still followed byelse -
tx0/kotlin:elvis-empty-defaultall?: ""or?: emptyList()spells out whatorEmpty()does -
tx0/kotlin:empty-class-bodyallA class, object or interface has an empty body
{} -
tx0/kotlin:enum-entry-namingallAn enum entry is named neither in upper case with underscores nor in upper camel case
-
tx0/kotlin:exception-name-suffixallA class extends an exception type but its name does not end in
ExceptionorError -
tx0/kotlin:file-named-after-other-classallA file holds a single class or object but is named differently
-
tx0/kotlin:function-only-returns-literalallA function without parameters only returns a literal, which a constant says more simply
-
tx0/kotlin:get-or-set-call-for-indexallget(key)orset(key, value)is called by name where the index operator reads more naturally -
tx0/kotlin:indexed-loop-ignores-indexallforEachIndexedormapIndexednames the index_, which the plain function does without -
tx0/kotlin:let-returns-argumentalllet { it }returns its argument unchanged -
tx0/kotlin:local-variable-namingallThe name of a local
valorvarstarts in upper case or contains underscores -
tx0/kotlin:long-lambdaallA lambda has more lines of code than the configured maximum
-
tx0/kotlin:long-lineallA line is longer than the configured maximum
-
tx0/kotlin:negated-emptiness-checkall!x.isEmpty()negates a check that has a positive form,isNotEmpty() -
tx0/kotlin:negated-is-or-inall!(x is T)or!(x in c)negates a check that has a negated form of its own -
tx0/kotlin:null-check-in-requireallrequire(x != null)orcheck(x != null)is written whererequireNotNullorcheckNotNullalso gives the value as non-null -
tx0/kotlin:null-dereference-across-callsallThe result of a call that can return
null, often a Java method, is used without a check -
tx0/kotlin:null-or-empty-by-handallx == null || x.isEmpty()spells outisNullOrEmpty() -
tx0/kotlin:object-instead-of-lambdaallAn object expression implements a single-method Java interface that a lambda could implement
-
tx0/kotlin:package-namingallA package name has uppercase letters or underscores
-
tx0/kotlin:parameter-namingallA function or constructor parameter is not named in lower camel case
-
tx0/kotlin:property-namingallA property of a class is not named in lower camel case
-
tx0/kotlin:star-importallAn import brings in every name of a package with
* -
tx0/kotlin:throw-state-exceptionallthrow IllegalStateException(message)spells out whaterror(message)does -
tx0/kotlin:undocumented-public-declarationallA public class or function at the top level or in a public class has no documentation comment
-
tx0/kotlin:val-could-be-constallA
valin an object or at the top level holds a literal and could be aconst val