KT.UNNECESSARY_PARENTHESES

Unnecessary parentheses around expressions

This rule reports unnecessary parentheses around expressions. These unnecessary parentheses can safely be removed.

Noncompliant Code

Copy
val local = (5 + 3)

if ((local == 8)) { }

fun foo() {
    function({ input -> println(input) })
}

Compliant Code

Copy
val local = 5 + 3

if (local == 8) { }

fun foo() {
    function { input -> println(input) }
}

The content on this page is adapted from the Detekt Docs. Copyright ©2022 The Detekt Team. All rights reserved. https://detekt.dev/comments.html