-
Wanted to get some insight on why diktat recommends against custom getters and setters. Is there something wrong with the following? private val delegate: Delegate
get() = holder.delegateFactory(tenantResolver.currentTenant()) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We have described that case in https://github.com/cqfn/diKTat/blob/master/info/guide/diktat-coding-convention.md#-618-avoid-using-custom-getters-and-setters we think that in case the developer needs some custom logic - he can create a new method with a proper name. In this case the logic is not confusing for the user of the library. If the user calls GETTER he expects simply to get the value without any side effects and complex computations. BUT, you can always disable that rule in config or SUPPRESS using a |
Beta Was this translation helpful? Give feedback.
We have described that case in https://github.com/cqfn/diKTat/blob/master/info/guide/diktat-coding-convention.md#-618-avoid-using-custom-getters-and-setters
we think that in case the developer needs some custom logic - he can create a new method with a proper name. In this case the logic is not confusing for the user of the library. If the user calls GETTER he expects simply to get the value without any side effects and complex computations.
BUT, you can always disable that rule in config or SUPPRESS using a
@Supress
annotation in code