Inspectopedia Help

Style issues

'String.format' call can be replaced with string templates   New in this release

Reports String.format calls that can be replaced with string templates.

'arrayOf' call can be replaced with array literal [...]   New in this release

Reports arrayOf calls that can be replaced with array literals [...].

'assert' call can be replaced with '!!' or '?:'   New in this release

Reports assert calls that check a not null value of the declared variable.

'associate' can be replaced with 'associateBy' or 'associateWith'   New in this release

Reports calls to associate() and associateTo() that can be replaced with associateBy() or associateWith().

'copy' method of data class is called without named arguments   New in this release

Reports calls to a data class' copy() method without named arguments.

'filterIsInstance' call with a class literal argument   New in this release

Reports calls of the Kotlin standard library function filterIsInstance with a class literal argument.

'if' condition can be replaced with lambda call   New in this release

Reports isEmpty, isBlank, isNotEmpty, or isNotBlank calls in an if statement to assign a default value.

'map.get()' with not-null assertion operator (!!)   New in this release

Reports map.get()!! that can be replaced with map.getValue(), map.getOrElse(), and so on.

'map.put()' can be converted to assignment   New in this release

Reports map.put function calls that can be replaced with indexing operator ([]).

'protected' visibility is effectively 'private' in a final class   New in this release

Reports protected visibility used inside of a final class.

'rangeTo' or the '..' call should be replaced with '..<'   New in this release

Reports calls to rangeTo or the .

'rangeTo' or the '..' call should be replaced with 'until'   New in this release

Reports calls to rangeTo or the .

'readLine' can be replaced with 'readln' or 'readlnOrNull'   New in this release

Reports calls to readLine() that can be replaced with readln() or readlnOrNull().

'substring' call should be replaced with 'dropLast' call   New in this release

Reports calls like s.substring(0, s.length - x) that can be replaced with s.dropLast(x).

'substring' call should be replaced with 'substringAfter'   New in this release

Reports calls like s.substring(s.indexOf(x)) that can be replaced with s.substringAfter(x).

'substring' call should be replaced with 'substringBefore'   New in this release

Reports calls like s.substring(0, s.indexOf(x)) that can be replaced with s.substringBefore(x).

'substring' call should be replaced with 'take' call   New in this release

Reports calls like s.substring(0, x) that can be replaced with s.take(x).

'substring' call should be replaced with indexing operator   New in this release

Reports calls like "abc".substring(0, 1) that can be replaced with "abc"[0].

'to' call should be replaced with infix form   New in this release

Reports to function calls that can be replaced with the infix form.

'when' that can be simplified by introducing an argument   New in this release

Reports a when expression that can be simplified by introducing a subject argument.

Accessor call that can be replaced with property access syntax   New in this release

Reports Java get and set method calls that can be replaced with the Kotlin synthetic properties.

Assert boolean could be replaced with assert equality   New in this release

Reports calls to assertTrue() and assertFalse() that can be replaced with assert equality functions.

Assignment can be replaced with operator assignment  

Reports modifications of variables with a simple assignment (such as y = y + x) that can be replaced with an operator assignment.

Boolean expression can be simplified  

Reports boolean expression parts that can be reduced to constants.

Boolean literal argument without parameter name   New in this release

Reports call arguments with Boolean type without explicit parameter names specified.

Boxed properties should be replaced with unboxed   New in this release

Reports boxed Range.start and Range.endInclusive properties.

Call chain on collection could be converted into 'Sequence' to improve performance   New in this release

Reports call chain on a Collection that should be converted into Sequence.

Call chain on collection type can be simplified   New in this release

Reports two-call chains replaceable by a single call.

Call of 'toString' could be replaced with string template   New in this release

Reports toString function calls that can be replaced with a string template.

Can be replaced with binary operator   New in this release

Reports function calls that can be replaced with binary operators, in particular comparison-related ones.

Can be replaced with function reference   New in this release

Reports function literal expressions that can be replaced with function references.

Can be replaced with lambda   New in this release

Reports a function reference expression that can be replaced with a function literal (lambda).

Cascade 'if' can be replaced with 'when'   New in this release

Reports if statements with three or more branches that can be replaced with the when expression.

Class member can have 'private' visibility   New in this release

Reports declarations that can be made private to follow the encapsulation principle.

Collection count can be converted to size   New in this release

Reports calls to Collection<T>.count().

Convert Pair constructor to 'to' function   New in this release

Reports a Pair constructor invocation that can be replaced with a to() infix function call.

Convert to primary constructor   New in this release

Reports a secondary constructor that can be replaced with a more concise primary constructor.

Convert try / finally to use() call   New in this release

Reports a try-finally block with resource.close() in finally which can be converted to a resource.use() call.

Equality check can be used instead of elvis for nullable boolean check   New in this release

Reports cases when an equality check should be used instead of the elvis operator.

Explicit 'get' or 'set' call   New in this release

Reports explicit calls to get or set functions which can be replaced by an indexing operator [].

Expression body syntax is preferable here   New in this release

Reports return expressions (one-liners or when) that can be replaced with expression body syntax.

Fully qualified name can be replaced with existing import alias   New in this release

Reports fully qualified names that can be replaced with an existing import alias.

Function should have 'operator' modifier   New in this release

Reports a function that matches one of the operator conventions but lacks the operator keyword.

Function with '= { ... }' and inferred return type   New in this release

Reports functions with = { ..

Guard clause can be replaced with Kotlin's function call   New in this release

Reports guard clauses that can be replaced with a function call.

If-Null return/break/... foldable to '?:'   New in this release

Reports an if expression that checks variable being null or not right after initializing it that can be converted into an elvis operator in the initializer.

If-Then foldable to '?.'   New in this release

Reports if-then expressions that can be folded into safe-access (?.) expressions.

If-Then foldable to '?:'   New in this release

Reports if-then expressions that can be folded into elvis (?:) expressions.

Implicit 'this'   New in this release

Reports usages of implicit this.

Java Collections static method call can be replaced with Kotlin stdlib   New in this release

Reports a Java Collections static method call that can be replaced with Kotlin stdlib.

Java Map.forEach method call should be replaced with Kotlin's forEach   New in this release

Reports a Java Map.forEach method call that can be replaced with Kotlin's forEach.

Java methods should be replaced with Kotlin analog   New in this release

Reports a Java method call that can be replaced with a Kotlin function, for example, System.out.println().

Join declaration and assignment   New in this release

Reports property declarations that can be joined with the following assignment.

Lambda argument inside parentheses   New in this release

Reports lambda expressions in parentheses which can be moved outside.

Library function call could be simplified   New in this release

Reports library function calls which could be replaced by simplified one.

Local 'var' is never modified and can be declared as 'val'   New in this release

Reports local variables declared with the var keyword that are never modified.

Loop can be replaced with stdlib operations   New in this release

Reports for loops that can be replaced with a sequence of stdlib operations (like map, filter, and so on).

Main parameter is not necessary   New in this release

Reports main function with an unused single parameter.

Manually incremented index variable can be replaced with use of 'withIndex()'   New in this release

Reports for loops with a manually incremented index variable.

Might be 'const'   New in this release

Reports top-level val properties in objects that might be declared as const for better performance and Java interoperability.

Multiple operators with different precedence  

Reports binary expressions that consist of different operators without parentheses.

Negated boolean expression can be simplified   New in this release

Reports negated boolean expressions that can be simplified.

Negated call can be simplified   New in this release

Reports negation isEmpty() and isNotEmpty() for collections and String, or isBlank() and isNotBlank() for String.

Nested lambda has shadowed implicit parameter   New in this release

Reports nested lambdas with shadowed implicit parameters.

Non-canonical modifier order   New in this release

Reports modifiers that do not follow the order recommended by the style guide.

Non-idiomatic 'is' type check for an object   New in this release

Reports non-idiomatic is type checks for an object.

Not-null assertion can be replaced with 'return'   New in this release

Reports not-null assertion (!!) calls that can be replaced with the elvis operator and return (?: return).

Object literal can be converted to lambda   New in this release

Reports anonymous object literals implementing a Java interface with a single abstract method that can be converted into a call with a lambda expression.

Optionally expected annotation has no actual annotation   New in this release

Reports optionally expected annotations without actual annotation in some platform modules.

Range can be converted to indices or iteration   New in this release

Reports until and rangeTo operators that can be replaced with Collection.indices or iteration over collection inside for loop.

Redundant 'asSequence' call   New in this release

Reports redundant asSequence() call that can never have a positive performance effect.

Redundant 'else' in 'if'   New in this release

Reports redundant else in if with return.

Redundant 'runCatching' call   New in this release

Reports runCatching calls that are immediately followed by getOrThrow.

Remove unnecessary parentheses   New in this release

Reports redundant empty parentheses in annotation entries.

Replace 'mapIndexed' with List generator   New in this release

Reports a mapIndexed call that can be replaced by List generator.

Replace 'until' with '..<' operator   New in this release

Reports until that can be replaced with ..< operator.

Return or assignment can be lifted out   New in this release

Reports if, when, and try statements that can be converted to expressions by lifting the return statement or an assignment out.

Safe cast with 'return' should be replaced with 'if' type check   New in this release

Reports safe cast with return that can be replaced with if type check.

Scope function can be converted to another one   New in this release

Reports scope functions (let, run, apply, also) that can be converted between each other.

Scope function with nested forEach can be simplified   New in this release

Reports forEach functions in the scope functions such as also or apply that can be simplified.

Size check can be replaced with 'isNotEmpty()'   New in this release

Reports size checks of Collections/Array/String that should be replaced with isNotEmpty().

Size zero check can be replaced with 'isEmpty()'   New in this release

Reports size == 0 checks on Collections/Array/String that should be replaced with isEmpty().

String concatenation that can be converted to string template   New in this release

Reports string concatenation that can be converted to a string template.

Suspicious 'asDynamic' member invocation   New in this release

Reports usages of asDynamic function on a receiver of dynamic type.

Trailing comma recommendations   New in this release

Reports trailing commas that do not follow the recommended style guide.

Two comparisons should be converted to a range check   New in this release

Reports two consecutive comparisons that can be converted to a range check.

Type parameter can have 'in' or 'out' variance   New in this release

Reports type parameters that can have in or out variance.

Unlabeled return inside lambda   New in this release

Reports unlabeled return expressions inside inline lambda.

Use destructuring declaration   New in this release

Reports declarations that can be destructured.

Variable declaration could be moved inside 'when'   New in this release

Reports variable declarations that can be moved inside a when expression.

Verbose nullability and emptiness check   New in this release

Reports combination of null and emptiness checks that can be simplified into a single check.

Last modified: 11 September 2024