Skip to content

remove the local variable and return the result directly #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2019

Conversation

xuejiangtao
Copy link
Contributor

I found a code smell that Local Variables should not be declared and then immediately returned or thrown.
Some developers argue that the practice improves code readability, because it enables them to explicitly name what is being returned. However, this variable is an internal implementation detail that is not exposed to the callers of the method. The method name should be sufficient for callers to know exactly what will be returned.

So I remove the local variable and return the personMapper.count(selectStatement); directly to fix the Code Quality Issue detected by SonarQube.
https://rules.sonarsource.com/java/RSPEC-1488

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e96a77b on xuejiangtao:master into 79513eb on mybatis:master.

@xuejiangtao
Copy link
Contributor Author

@jeffgbutler hello, I found a code smell that Local Variables should not be declared and then immediately returned or thrown.
Some developers argue that the practice improves code readability, because it enables them to explicitly name what is being returned. However, this variable is an internal implementation detail that is not exposed to the callers of the method. The method name should be sufficient for callers to know exactly what will be returned.

So I remove the local variable and return the personMapper.count(selectStatement); directly to fix the Code Quality Issue detected by SonarQube.
https://rules.sonarsource.com/java/RSPEC-1488

@jeffgbutler jeffgbutler merged commit d748511 into mybatis:master May 21, 2019
@jeffgbutler
Copy link
Member

Thanks!

@xuejiangtao
Copy link
Contributor Author

Thanks!

thanks for reviewing and i will do some contributions to improve the Code Quality with fix patch generated by my tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants