saveourtool/diktat

Detect useless scoped functions

Open

#972 opened on Jul 7, 2021

 (0 comments) (0 reactions) (1 assignee)Kotlin (40 forks)github user discovery
enhancementgood first issuehelp wantedneeded

Repository metrics

Stars
 (571 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Implement the rule, which will detect useless scoped functions, and remove extra actions. For example, in a bundle of let - run it can be quite often met situations, when run contain single statement, which is actually will work without run:

someValue?.let {
                foo()
            }
                ?: run {
                    bar()
                }

Expected behavior

someValue?.let {
                foo()
            }
                ?: bar()

Contributor guide