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

refactor: use slices.Contains #4208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zhuhaicity
Copy link

Overview

This is a new function added in the go1.21 standard library, which can make the code more concise and easy to read.

@zhuhaicity zhuhaicity requested a review from a team as a code owner January 12, 2025 08:10
@zhuhaicity zhuhaicity requested review from cmwaters and rach-id and removed request for a team January 12, 2025 08:10
Copy link
Contributor

coderabbitai bot commented Jan 12, 2025

📝 Walkthrough

Walkthrough

The pull request introduces modifications to the isKnownChainID function in the download_genesis.go file and the startCmd function in the start.go file within the cmd/celestia-appd/cmd directory. Both changes replace custom contains functions with the slices.Contains function from the standard library, streamlining the implementation for checking the presence of a string in a slice. The overall functionality remains unchanged, and there are no impacts on control flow or error handling in related functions.

Changes

File Change Summary
cmd/celestia-appd/cmd/download_genesis.go Replaced custom contains function with slices.Contains from the standard library.
cmd/celestia-appd/cmd/start.go Replaced custom contains function with slices.Contains from the standard library.

No changes were made to exported or public entity declarations.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc09e5b and be37c49.

📒 Files selected for processing (2)
  • cmd/celestia-appd/cmd/download_genesis.go (2 hunks)
  • cmd/celestia-appd/cmd/start.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/celestia-appd/cmd/download_genesis.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (2)
cmd/celestia-appd/cmd/start.go (2)

14-14: LGTM! Good use of standard library.

Using the slices package from Go 1.21 standard library is a good choice for slice operations.


136-138: LGTM! Clean refactor using standard library.

Good replacement of custom contains check with slices.Contains. The change:

  • Improves code readability
  • Reduces maintenance burden by using standard library
  • Maintains the same functionality for public network validation

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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.

rach-id
rach-id previously approved these changes Jan 13, 2025
ninabarbakadze
ninabarbakadze previously approved these changes Jan 13, 2025
rootulp
rootulp previously approved these changes Jan 13, 2025
cmd/celestia-appd/cmd/download_genesis.go Outdated Show resolved Hide resolved
@rootulp rootulp changed the title refactor: using slices.Contains to simplify the code refactor: use slices.Contains Jan 13, 2025
@zhuhaicity zhuhaicity dismissed stale reviews from rootulp, ninabarbakadze, and rach-id via fc09e5b January 14, 2025 13:33
@zhuhaicity
Copy link
Author

Modified. Please review again.

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM if CI passes

@rootulp rootulp enabled auto-merge (squash) January 14, 2025 13:43
Copy link
Member

@ninabarbakadze ninabarbakadze left a comment

Choose a reason for hiding this comment

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

bunch of things failing in the ci

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Looks like contains is used in more than that one location so CI is failing

auto-merge was automatically disabled January 15, 2025 10:44

Head branch was pushed to by a user without write access

@celestia-bot celestia-bot requested a review from rootulp January 15, 2025 10:44
@zhuhaicity
Copy link
Author

Looks like contains is used in more than that one location so CI is failing

Indeed..has been modified.

Please review again.

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM if CI passes

@rootulp rootulp enabled auto-merge (squash) January 15, 2025 14:28
@zhuhaicity
Copy link
Author

LGTM if CI passes

There is an error in ci-release / markdown-linter / markdown-link-check (pull_request), but it does not seem to be related to this PR’s change.

@rootulp
Copy link
Collaborator

rootulp commented Jan 19, 2025

Yea, you can ignore the markdown link check failure.

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.

5 participants