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

Unwrap spooky one-liners into readable code #256

Open
shpaass opened this issue Sep 2, 2024 · 0 comments
Open

Unwrap spooky one-liners into readable code #256

shpaass opened this issue Sep 2, 2024 · 0 comments
Labels
todo This ticket has a corresponding TODO in the code

Comments

@shpaass
Copy link
Owner

shpaass commented Sep 2, 2024

Sometimes I encounter something like

AFunctionCall(soFarSoGood ?? throw ACustomException($"With a long {Formatted.Explanation}. Which is still fine, but"), hereGoes ?? (anHonestToGoodness ? ternaryOnTheSameLine : throw WithAnotherCustomException($"And another {Long.Formatted} message. On the same line.");

Both the length and the complexity of the expression hurt the readability of the code.

I try to keep the lines below 120 characters, so they fit into a GitHub Files Changed screen.
I also try to keep the code readable, so the example above needs to be refactored into several ifs. That refactor needs to be tested or checked thoroughly, so it's not a quick fix.

That's why I create this ticket, so we can comment the places in the code that require attention in this regard. The places which we could not refactor at the moment.

@shpaass shpaass added the todo This ticket has a corresponding TODO in the code label Sep 20, 2024
@shpaass shpaass changed the title [Todo] Unwrap spooky one-liners into readable code Unwrap spooky one-liners into readable code Sep 20, 2024
shpaass added a commit that referenced this issue Oct 5, 2024
The idea was to make this part of code more readable. For this, the
following steps were taken:
1. Split booleans into one equality or expression per boolean.
2. Explain with local names what the booleans check.
3. Put on-select actions as a local function too.
4. Align parameters Google-style.

I also added blank lines around some code blocks.

QA: tested on a pY project that the corresponding window selects and
deselects things as usual.

This ticket is a part of #256.
It doesn't fix it, but it works towards addressing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
todo This ticket has a corresponding TODO in the code
Projects
None yet
Development

No branches or pull requests

1 participant