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(textual): Add Enum value renderer #13853

Merged
merged 10 commits into from
Nov 23, 2022
Merged

feat(textual): Add Enum value renderer #13853

merged 10 commits into from
Nov 23, 2022

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Nov 14, 2022

Description

Closes: #12712


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Nov 14, 2022

Codecov Report

Merging #13853 (24c4d00) into main (2739f83) will increase coverage by 0.11%.
The diff coverage is 70.00%.

❗ Current head 24c4d00 differs from pull request most recent head 14998d7. Consider uploading reports for the commit 14998d7 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13853      +/-   ##
==========================================
+ Coverage   56.25%   56.37%   +0.11%     
==========================================
  Files         667      677      +10     
  Lines       56576    57011     +435     
==========================================
+ Hits        31829    32142     +313     
- Misses      22165    22249      +84     
- Partials     2582     2620      +38     
Impacted Files Coverage Δ
tx/textual/valuerenderer/enum.go 67.85% <67.85%> (ø)
tx/textual/valuerenderer/valuerenderer.go 73.33% <100.00%> (ø)
tx/textual/valuerenderer/dec.go 50.00% <0.00%> (ø)
tx/textual/valuerenderer/int.go 50.00% <0.00%> (ø)
tx/textual/valuerenderer/message.go 64.22% <0.00%> (ø)
tx/textual/valuerenderer/string.go 66.66% <0.00%> (ø)
tx/textual/valuerenderer/duration.go 78.22% <0.00%> (ø)
tx/textual/valuerenderer/coins.go 73.17% <0.00%> (ø)
tx/textual/valuerenderer/timestamp.go 89.28% <0.00%> (ø)
... and 3 more

Comment on lines -166 to -172
- String case convention: snake case to sentence case
- Allow optional annotation for textual name (TBD)
- Algorithm:
- convert enum name (`VoteOption`) to snake_case (`VOTE_OPTION`)
- truncate that prefix + `_` from the enum name if it exists (`VOTE_OPTION_` gets stripped from `VOTE_OPTION_YES` -> `YES`)
- convert rest to sentence case: `YES` -> `Yes`
- in summary: `VOTE_OPTION_YES` -> `Yes`
Copy link
Contributor Author

@amaury1093 amaury1093 Nov 14, 2022

Choose a reason for hiding this comment

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

I removed all string transformation we initially had. It can be ambiguous even for Format.

Take:

enum AbC {
  D = 1;
  AB_C_D = 2;
}

I propose to go with simplicity with no transformation.

@amaury1093 amaury1093 marked this pull request as ready for review November 14, 2022 12:46
@amaury1093 amaury1093 requested a review from a team as a code owner November 14, 2022 12:46
amaury1093 and others added 2 commits November 22, 2022 16:31
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
Copy link
Member

@kocubinski kocubinski left a comment

Choose a reason for hiding this comment

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

LGTM

@amaury1093 amaury1093 enabled auto-merge (squash) November 23, 2022 08:50
@sonarqubecloud
Copy link

[Cosmos SDK] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

81.0% 81.0% Coverage
0.0% 0.0% Duplication

@amaury1093 amaury1093 merged commit fe5b0ff into main Nov 23, 2022
@amaury1093 amaury1093 deleted the am/12712-textual-enums branch November 23, 2022 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TEXTUAL Value Renderers for Protobuf Enums
5 participants