-
Notifications
You must be signed in to change notification settings - Fork 273
refactor: use a more modern writing style to simplify code #1854
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: deepdring <[email protected]>
WalkthroughRefactors internal logic in two areas: replaces a manual map-copy loop with maps.Copy in app/app.go, and simplifies context height calculation in x/cronos/rpc/api.go using max(blockNumber-1, 1). No public APIs changed; behavior preserved. Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
app/app.go (1)
1346-1348
: Prefer maps.Clone and pre-size; consider deep-copying slice values if immutability is desired.Functional behavior is fine and matches the prior shallow-copy semantics. For clarity and a tiny perf win, either use maps.Clone or pre-size the map when using maps.Copy. If external callers must not mutate the inner []string, switch to a deep copy.
Use maps.Clone (simplest):
func GetMaccPerms() map[string][]string { - dupMaccPerms := make(map[string][]string) - maps.Copy(dupMaccPerms, maccPerms) - return dupMaccPerms + return maps.Clone(maccPerms) }Or keep maps.Copy but pre-size:
-dupMaccPerms := make(map[string][]string) +dupMaccPerms := make(map[string][]string, len(maccPerms)) maps.Copy(dupMaccPerms, maccPerms)If you want immutability guarantees, deep copy the slice values:
func GetMaccPerms() map[string][]string { out := make(map[string][]string, len(maccPerms)) for k, v := range maccPerms { out[k] = append([]string(nil), v...) } return out }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
app/app.go
(2 hunks)x/cronos/rpc/api.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
@thomas-nguy Hi. Cloud you please review this PR? |
Optimize code using a more modern writing style. Official support from Go, for more details visit https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize.
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)
Summary by CodeRabbit