Skip to content

refactor: use the built-in max/min to simplify the code#3121

Merged
julienrbrt merged 1 commit intoevstack:mainfrom
eroderust:main
Mar 3, 2026
Merged

refactor: use the built-in max/min to simplify the code#3121
julienrbrt merged 1 commit intoevstack:mainfrom
eroderust:main

Conversation

@eroderust
Copy link
Contributor

@eroderust eroderust commented Mar 3, 2026

Overview

In Go 1.21, the standard library includes built-in max/min function, which can greatly simplify the code.

Summary by CodeRabbit

  • Refactor
    • Improved internal code structure for grace period calculations, streamlining logic while maintaining identical functionality and behavior.

Signed-off-by: eroderust <eroderust@outlook.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9af0f90 and e97af7e.

📒 Files selected for processing (1)
  • block/internal/syncing/syncer.go

📝 Walkthrough

Walkthrough

The gracePeriodForEpoch function in the syncing module was refactored to compute and return the grace period using a single expression that directly applies the minimum clamping operation, replacing the previous multi-step approach without altering behavior or logic.

Changes

Cohort / File(s) Summary
Grace Period Computation Refactor
block/internal/syncing/syncer.go
Simplified gracePeriodForEpoch to return a single min() expression instead of separate compute-clamp-return statements, reducing lines while maintaining identical semantics.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop and a skip, the code now sings,
One line instead of three tangled things,
Min of grace, so clean and tight,
Same old logic, polished bright!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description provides the rationale for the change (Go 1.21 built-in max/min) but lacks specific context about what was changed and lacks linking to an issue despite the template requesting it. Add specific details about which function(s) were refactored and consider linking to a related issue if one exists, or explain why none exists.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: refactoring code to use built-in max/min functions for simplification, which directly matches the single-file changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@julienrbrt julienrbrt merged commit e877782 into evstack:main Mar 3, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants