qulice
qulice copied to clipboard
There is no reason for single return
There is a rule defined in qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml file:
<module name="ReturnCount">
<property name="max" value="1"/>
</module>
This rule however has no real justification. Yes I read the blog post https://www.yegor256.com/2015/08/18/multiple-return-statements-in-oop.html but it's not conclusive. It present the perfect OO approach but then states it's impossible in java because "Java doesn’t have that. Java (and many other pseudo OOP languages) gives us operators" followed by some consideration how the perfect OO language would look like. And the last statement is " let’s stick with just one return".
Why? What's the difference between returning value directly and assigning it to a variable and returning this variable? Those are two very similar ways of writing the same, except the direct return requires less code is more readable.
@krzyk/z please, pay attention to this issue
@golszewski86/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!
@golszewski86 this is a question to @yegor256
More thoughts about the rule https://softwareengineering.stackexchange.com/questions/118703/where-did-the-notion-of-one-return-only-come-from