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

matchtree: switch to enum for matches signature #691

Merged
merged 1 commit into from
Nov 16, 2023
Merged

Conversation

keegancsmith
Copy link
Member

@keegancsmith keegancsmith commented Nov 14, 2023

The pair of bools (matches, sure) often was quite hard to reason about. I think this came down to them often not being named at return sites, the names itself being too concise and that two booleans represents 4 possible states, but we only had two possible states.

This commit uses a more verbose enum instead of booleans. From reading the diff back I find the code easier to reason about, so I think this is a good change.

Test Plan: go test ./...

@keegancsmith keegancsmith requested review from camdencheek and a team November 14, 2023 12:58
Copy link
Member

@camdencheek camdencheek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the more verbose enums. Way easier to read than trying to remember which bool means what exactly.

The pair of bools (matches, sure) often was quite hard to reason about.
I think this came down to them often not being named at return sites,
the names itself being too concise and that two booleans represents 4
possible states, but we only had two possible states.

This commit uses a more verbose enum instead of booleans. From reading
the diff back I find the code easier to reason about, so I think this is
a good change.

Test Plan: go test ./...
@keegancsmith keegancsmith changed the title rfc: switch to enum for matches signature matchtree: switch to enum for matches signature Nov 15, 2023
@keegancsmith
Copy link
Member Author

Alright I have added a bunch of documentation and re-reviewed the code to make sure it is correct. Looking for more eyes :)

@keegancsmith keegancsmith marked this pull request as ready for review November 15, 2023 08:33
Copy link
Member

@stefanhengl stefanhengl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me! Do we have tests targeting the state explicitly?

@keegancsmith
Copy link
Member Author

Code looks good to me! Do we have tests targeting the state explicitly?

No, but all these code paths get covered normally. I can do a coverage test? But indeed a change like this is a bit scary so I personally reviewed it like three times :)

@keegancsmith keegancsmith merged commit 8801747 into main Nov 16, 2023
8 checks passed
@keegancsmith keegancsmith deleted the k/enum branch November 16, 2023 14:00
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