Sonar Lint rule "Methods should not be too complex" (squid:MethodCyclomaticComplexity) has an example of using more than one return statement in the program block. (see https://groups.google.com/forum/#!topic/sonarqube/BtvGoF6Tw7E for the cyclormatic complexity calculation rules)
The returns shortens the codes in a branch, and result with smaller code blocks. For example,
int findBranchNumber(String input) { if ("branch1".equals(input)) { return 1; } if ("branch2".equals(input)) { return 2; } // .... return -1; }
The alternative will use a method variable (in this case) or bigger blocks. Whoever reads the code has to read the whole method before he/she realize only first 3 lines are relevant to the "branch1".
Please advise ...