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

chore(x/gov): clean validation code #18449

Merged
merged 1 commit into from
Nov 12, 2023

Conversation

emidev98
Copy link
Contributor

@emidev98 emidev98 commented Nov 12, 2023

Description

Based on the following comment from odeke-em in another PR #18448 (comment). I decided to clean also this code.

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
  • run make lint and make test
  • 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)

Summary by CodeRabbit

  • Refactor
    • Simplified the validation process for proposal lengths in the governance module, enhancing efficiency and readability.

@emidev98 emidev98 requested a review from a team as a code owner November 12, 2023 14:50
Copy link
Contributor

coderabbitai bot commented Nov 12, 2023

Walkthrough

Walkthrough

The changes in the codebase primarily focus on refactoring the error checks for metadata, summary, and title lengths in the Keeper struct within the x/gov/keeper/keeper.go file. The modifications aim to simplify the logic for checking the length of each parameter and eliminate redundant checks for empty strings.

Changes

File Change Summary
.../keeper/keeper.go The validateProposalLengths and assertion functions in the Keeper struct have been refactored. The changes involve simplifying the logic for checking the length of metadata, summary, and title parameters, and removing redundant checks for empty strings.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b494d6a and 5adb2be.
Files selected for processing (1)
  • x/gov/keeper/keeper.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • x/gov/keeper/keeper.go

@emidev98 emidev98 changed the title chore: clean gov code chore(x/gov): clean gov code Nov 12, 2023
@emidev98 emidev98 changed the title chore(x/gov): clean gov code chore(x/gov): clean validation code Nov 12, 2023
@@ -193,22 +193,22 @@ func (k Keeper) ModuleAccountAddress() sdk.AccAddress {
// validateProposalLengths checks message metadata, summary and title
// to have the expected length otherwise returns an error.
func (k Keeper) validateProposalLengths(metadata, title, summary string) error {
if err := k.assertMetadataLength(metadata); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

How come the spacing was wrong?
I believe we have gofmt as linter.
I'll need to check when reviewing the linters config. Nothing for you to do here, just noting.

@julienrbrt julienrbrt added this pull request to the merge queue Nov 12, 2023
Merged via the queue into cosmos:main with commit caf7630 Nov 12, 2023
62 of 64 checks passed
@emidev98 emidev98 deleted the clean/gov/checks branch November 12, 2023 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants