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

feat: Check that enum from_int functions are correct. #212

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Dec 18, 2023

This is the first "semantic formatter" style linter. It's pretty simple and just checks that all enumerators are present and there is a sane default in the ${enum}_from_int functions. There is no compiler warning we can use for this, because the int can contain anything. Currently, if there is an enumerator ending in _INVALID, then that is the default, otherwise the first enumerator is the default for invalid int values.


This change is Reviewable

@iphydf iphydf added this to the v0.0.9 milestone Dec 18, 2023
@iphydf iphydf marked this pull request as ready for review December 18, 2023 12:28
@iphydf iphydf force-pushed the enum-from-int branch 3 times, most recently from 77fc957 to bacecee Compare December 18, 2023 13:14
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 18, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 18, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
Copy link
Member

@JFreegman JFreegman left a comment

Choose a reason for hiding this comment

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

Reviewed 20 of 20 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained

This is the first "semantic formatter" style linter. It's pretty simple
and just checks that all enumerators are present and there is a sane
default in the `${enum}_from_int` functions. There is no compiler
warning we can use for this, because the int can contain anything.
Currently, if there is an enumerator ending in `_INVALID`, then that is
the default, otherwise the first enumerator is the default for invalid
int values.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 18, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
@toktok-releaser toktok-releaser merged commit c36fa4e into TokTok:master Dec 19, 2023
7 checks passed
@iphydf iphydf deleted the enum-from-int branch December 19, 2023 01:40
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
iphydf added a commit to iphydf/c-toxcore that referenced this pull request Dec 19, 2023
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
freylax pushed a commit to nodecum/c-toxcore that referenced this pull request Jan 13, 2024
These functions are a bit clearer and don't need to change if enum
values change.

See TokTok/hs-tokstyle#212 for the relevant
linter implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants