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

fix: use %q instead of manual \"%s\" #1723

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

odeke-em
Copy link
Contributor

@odeke-em odeke-em commented Oct 3, 2024

Noticed in a post-codereview of PR #1704 that there was a manual value quoting usinq \"%s\" instead
of the format specifier %q. Manual quoting doesn't work correctly. One can find vestiges of it by

git grep '\\"%s'

Updates #1704

Summary by CodeRabbit

  • New Features
    • Enhanced error message clarity across various methods, improving user experience when handling redemption requests and zone proposals.
  • Bug Fixes
    • Improved error handling and validation checks for zone registration and updates, ensuring more robust functionality.
  • Tests
    • Updated test cases to reflect new error message formats, ensuring consistency and accuracy in testing scenarios.

Noticed in a post-codereview of PR quicksilver-zone#1704 that there
was a manual value quoting usinq `\"%s\"` instead
of the format specifier `%q`. Manual quoting doesn't
work correctly. One can find vestiges of it by

    git grep '\\"%s'

Updates quicksilver-zone#1704
Copy link

vercel bot commented Oct 3, 2024

@odeke-em is attempting to deploy a commit to the quicksilver Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

Walkthrough

The changes in this pull request focus on improving error message formatting across several methods in the interchain staking and participation rewards modules. Specifically, the error messages have been updated to use backticks for string formatting instead of double quotes. Additionally, the logic flow remains intact, with minor adjustments made to enhance clarity in error handling and validation processes. The modifications are primarily cosmetic, aimed at maintaining consistency and readability in error reporting without altering the core functionality.

Changes

File Path Change Summary
x/interchainstaking/keeper/msg_server.go Updated error messages in CancelRedemption, RequeueRedemption, UpdateRedemption, and SignalIntent methods to use %q formatting.
x/interchainstaking/keeper/msg_server_test.go Modified error messages in test cases for consistency, updating to %q formatting and adjusting tests accordingly.
x/interchainstaking/keeper/proposal_handler.go Adjusted error message in HandleRegisterZoneProposal to use %q; added checks in HandleUpdateZoneProposal for connection management.
x/participationrewards/keeper/msg_server.go Changed error message formatting in SubmitClaim method to use %q for invalid zone messages.

Possibly related PRs

  • Unbond recovery #1704: The changes in this PR involve renaming MsgCancelQueuedRedemption to MsgCancelRedemption and updating its functionality, which directly relates to the modifications made in the main PR regarding error message formatting and logic flow in the CancelRedemption method.

Suggested labels

CLI

Suggested reviewers

  • minhngoc274
  • faddat

Poem

In the code where bunnies hop,
Error messages now won't flop.
With quotes that shine, so neat and bright,
Clarity blooms, a lovely sight.
Hooray for changes, small yet grand,
In the land of code, we take a stand! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 03a2194 and 282d564.

📒 Files selected for processing (4)
  • x/interchainstaking/keeper/msg_server.go (4 hunks)
  • x/interchainstaking/keeper/msg_server_test.go (11 hunks)
  • x/interchainstaking/keeper/proposal_handler.go (1 hunks)
  • x/participationrewards/keeper/msg_server.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/interchainstaking/keeper/msg_server_test.go
🔇 Additional comments (6)
x/participationrewards/keeper/msg_server.go (1)

39-39: Approved: Improved error message formatting

The change from \"%s\" to %q for formatting the msg.Zone in the error message is a good improvement. It's more idiomatic in Go and aligns with the PR objectives.

To ensure consistency across the codebase, let's check for any remaining instances of manual quoting:

If any results are found, consider updating them similarly for consistency.

✅ Verification successful

Verification Complete: No Manual Quoting Issues in Internal Codebase

The shell scripts identified instances of manual quoting in the following files:

  • third-party-chains/osmosis-types/osmoutils/accum/prefix.go

These instances are located within external dependencies and do not impact the internal codebase. The approved change to use %q for error message formatting maintains consistency within our codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for remaining instances of manual quoting in error messages

# Test: Look for remaining instances of '\\"%s"' in Go files
rg --type go '\\"%s"'

# Test: Look for other potential manual quoting patterns
rg --type go '"\s*%s\s*"'

Length of output: 316

x/interchainstaking/keeper/msg_server.go (5)

101-101: Improved error message formatting

The changes from \"%s\" to %q in the error messages are consistent with the PR objective and improve readability. This modification enhances the overall code quality without altering the function's logic.

Also applies to: 104-104, 109-109


148-148: Consistent improvement in error message formatting

The changes from \"%s\" to %q in the error messages align with the PR objective and enhance readability. This modification maintains consistency across the codebase and improves the overall quality of error reporting.

Also applies to: 151-151, 155-155


211-211: Continued improvement in error message formatting

The change from \"%s\" to %q in the error message is in line with the PR objective. This modification enhances readability and maintains consistency with the changes made in other functions.


247-247: Consistent error message formatting improvement

The change from \"%s\" to %q in the error message aligns with the PR objective. This modification maintains the consistency of error message formatting throughout the file, enhancing overall code quality.


Line range hint 1-500: Summary of changes and their impact

The changes in this PR consistently replace \"%s\" with %q in error messages across multiple functions (CancelRedemption, RequeueRedemption, UpdateRedemption, and SignalIntent). These modifications improve the readability and consistency of error messages throughout the file.

Key points:

  1. The changes align with the PR objective.
  2. No logical modifications or potential issues have been introduced.
  3. The overall code quality has been enhanced through consistent error message formatting.

These changes contribute to a more maintainable and readable codebase.

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 63.41%. Comparing base (03a2194) to head (282d564).

Files with missing lines Patch % Lines
x/interchainstaking/keeper/proposal_handler.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1723   +/-   ##
=======================================
  Coverage   63.41%   63.41%           
=======================================
  Files         194      194           
  Lines       13436    13436           
=======================================
  Hits         8521     8521           
  Misses       4097     4097           
  Partials      818      818           
Flag Coverage Δ
unittests 63.41% <90.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
x/interchainstaking/keeper/msg_server.go 89.45% <100.00%> (ø)
x/participationrewards/keeper/msg_server.go 74.69% <100.00%> (ø)
x/interchainstaking/keeper/proposal_handler.go 62.62% <0.00%> (ø)

@ajansari95
Copy link
Contributor

ajansari95 commented Oct 9, 2024

@odeke-em can you please just rebase the branch the fix for linting issue is already merged, thank you?

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.

3 participants