Skip to content
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

Adopt clang-tidy's readability-else-after-return check #3024

Open
ChrisThrasher opened this issue May 19, 2024 · 4 comments
Open

Adopt clang-tidy's readability-else-after-return check #3024

ChrisThrasher opened this issue May 19, 2024 · 4 comments
Labels
Milestone

Comments

@ChrisThrasher
Copy link
Member

ChrisThrasher commented May 19, 2024

https://clang.llvm.org/extra/clang-tidy/checks/readability/else-after-return.html

We currently disable readability-else-after-return which is a wonderful check that finds easy ways to improve readability, reduce indentation, and reduce line count. It's an all around win to enforce this check and transform SFML to adhere to it. Lots of new code written already adheres to style since the benefits of guard clauses are well established.

clang-tidy offers an automatically fixer for this check so actually writing the PR will be as easy as letting clang-tidy rewrite the codebase.

@ChrisThrasher
Copy link
Member Author

@vittorioromeo and I have discussed this in past PRs and we both prefer this style. I'm happy to write the commit in case we want to look at how the code actually changes. That may help us understand this check and what exactly it will change about SFML.

@ChrisThrasher
Copy link
Member Author

master...ChrisThrasher:SFML:else-after-return

Screenshot 2024-05-19 at 11 41 01 AM

Here's most of what this change will look like. This only took a few minutes of running clang-tidy locally to get this far. If we agree on this I won't rebase this branch but rather just do it all again on the current state of master.

@eXpl0it3r
Copy link
Member

Looks good to me, although I prefer an extra empty line between the statements, e.g.:

if (bla)
    return true;

return false;

@ChrisThrasher
Copy link
Member Author

although I prefer an extra empty line between the statements, e.g.:

Happy to make these tweaks when I get to an actual PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Needs Work
Development

No branches or pull requests

2 participants