v0.11.2
Aug 1, 2024
81
10
version = 1
[[analyzers]]
name = "kotlin"
[analyzers.meta]
language_version = "1.8"
runtime_version = "17"
Anti-pattern
48
Bug risk
24
Documentation
1
Performance
5
Style
3
Avoid throwing exceptions in non-fallible operations such as equals()
or toString()
.
It is important to ensure that ranges specified in for
loops are valid. Ranges that are empty can lead to unexpected behavior.
Using the not-null assertion operator (!!
) along with the index operator []
or the .get()
method of a map type can result in a NullPointerException
if the key is not present in the map. This is because Map.get()
returns null
if the key is not found. By using the not-null assertion operator, you are explicitly telling the compiler that the result will never be null
, which can lead to a runtime exception if the assumption is incorrect.
Having the file location not matching the declared package is considered bad practice in software development. It can lead to confusion, make code harder to locate and navigate to, hinder collaboration among team members, cause issues with build systems and tools, reduce code portability and reusability, and negatively impact code
forEach
with ranges KT-P1000Using the forEach
method on ranges has a heavy performance cost. Prefer using simple for
loops.