Skip to content

Files

Latest commit

 

History

History
27 lines (18 loc) · 662 Bytes

UnnecessaryApply.md

File metadata and controls

27 lines (18 loc) · 662 Bytes

Pattern: Unnecessary apply

Issue: -

Description

apply expressions are used frequently, but sometimes their usage should be replaced with an ordinary method/extension function call to reduce visual complexity.

Example of incorrect code:

config.apply { version = "1.2" } // can be replaced with config.version = "1.2"
config?.apply { environment = "test" } // can be replaced with config?.environment = "test"

Example of correct code:

config.apply {
    version = "1.2"
    environment = "test"
}

Further Reading