-
Notifications
You must be signed in to change notification settings - Fork 38
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
Refactor: Reduce Return Statements Across Multiple Functions #191
base: main
Are you sure you want to change the base?
Refactor: Reduce Return Statements Across Multiple Functions #191
Conversation
Thank you for the pull request!The Scribe team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Android rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you! Maintainer checklist |
Hi @andrewtavis , I managed to solve the following lint issues from earlier:
"TooGenericExceptionCaught" in Activity.kt (line 87) and ContextStorage.kt (line 427). Thanks for your help! |
…the no of return statements
CC @angrezichatterbox: Any suggestions here? @KesharwaniArpita, let us work on this from here, thanks :) |
Sure!! Thanks for your support here @andrewtavis and @angrezichatterbox . Is there anything I could've done better here? |
val trimmedText = textBeforeCursor.trim() | ||
val lastChar = trimmedText.lastOrNull() | ||
return lastChar != '.' | ||
val textBeforeCursor = inputConnection.getTextBeforeCursor(Int.MAX_VALUE, 0).orEmpty().trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using isEmpty()
, I recommend performing a simple null check in the return statement. This adjustment should help avoid any errors.
Additionally, I suggest running the application in Android Studio or following the steps outlined in the new PR template, specifically ./gradlew lintKotlin detekt test
. This could help catch potential issues early on. If you are facing any difficulties in running the application do tell. Happy to help :)
Thank you!
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the comment be opened and closed properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix this and the above and we'll see what the state of it all is :)
Contributor checklist
Description
This pull request removes the
ReturnCount
rule indetekt.yml
, refactors several functions in the codebase to reduce the number of return statements. The aim is to improve readability, maintainability, and consistency in error handling while ensuring that each function maintains its original functionality. The changes ensure a maximum of two return points for better flow and clarity.Changes Made
Reducing the number of return statements in functions enhances code quality by:
Please review the changes and provide any feedback or suggestions for further improvement. Your input is greatly appreciated!
Related issue