-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/fix 018 #14
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
Feat/fix 018 #14
Conversation
WalkthroughThe PR increments the counter file from 18 to 19 and changes ID allocation logic: Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🔇 Additional comments (1)
Comment |
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: 0
🧹 Nitpick comments (2)
pkg/storage.go (1)
97-132: Implementation looks solid—correctly skips occupied IDs and fills gaps.The loop-based approach to find the next available ID is straightforward and handles both skipping occupied IDs and filling gaps in the sequence. The logic correctly:
- Iterates from the current counter value until an available ID is found
- Updates the counter to
availableID + 1- Returns the first available ID
The implementation aligns well with the test coverage in
storage_test.go.Optional: Consider adding a safeguard against unbounded iteration.
While unlikely in practice, if there are a very large number of consecutive occupied IDs (e.g., due to manual counter manipulation), the loop could iterate many times. Consider adding a maximum iteration limit or logging a warning after a certain threshold.
Example safeguard:
// Find the next available ID by checking if current ID exists availableID := currentID + maxIterations := 10000 + iterations := 0 for { + if iterations >= maxIterations { + return 0, fmt.Errorf("too many occupied IDs; exhausted search after %d iterations", maxIterations) + } formattedID := FormatID(availableID) _, _, err := FindIssueFile(formattedID) if err != nil { // ID not found, so it's available break } // ID exists (in either open or closed), try next one availableID++ + iterations++ }.issues/open/018-increment-counter.md (1)
16-19: Specify language for fenced code block.The fenced code block should specify a language identifier (e.g.,
bashorshell) for better rendering and to satisfy the markdownlint rule MD040.Apply this diff:
-``` +```bash $ gi create aa Error: failed to save issue: issue 003 exists in closed directory, cannot save to open</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: Path: .coderabbit.yaml **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between d5614077260fb36e9f04ba12ad8ded100666bd20 and 20f3565a566a7fcef48adf68fa3a6d3b992964c4. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `.issues/.counter` (1 hunks) * `.issues/open/018-increment-counter.md` (1 hunks) * `pkg/storage.go` (2 hunks) * `pkg/storage_test.go` (1 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🧬 Code graph analysis (2)</summary> <details> <summary>pkg/storage.go (1)</summary><blockquote> <details> <summary>pkg/parser.go (1)</summary> * `FormatID` (108-110) </details> </blockquote></details> <details> <summary>pkg/storage_test.go (1)</summary><blockquote> <details> <summary>pkg/storage.go (8)</summary> * `InitializeRepo` (22-95) * `NewIssue` (382-397) * `SaveIssue` (135-163) * `OpenDir` (14-14) * `ClosedDir` (15-15) * `IssuesDir` (13-13) * `CounterFile` (16-16) * `GetNextID` (98-132) </details> </blockquote></details> </details><details> <summary>🪛 markdownlint-cli2 (0.18.1)</summary> <details> <summary>.issues/open/018-increment-counter.md</summary> 16-16: Fenced code blocks should have a language specified (MD040, fenced-code-language) </details> </details> </details> <details> <summary>🔇 Additional comments (3)</summary><blockquote> <details> <summary>pkg/storage_test.go (2)</summary><blockquote> `119-165`: **Excellent test coverage for occupied ID skipping.** This test thoroughly validates that `GetNextID()` correctly skips occupied IDs (1, 2, 3) across both open and closed directories, returns the next available ID (4), and updates the counter appropriately (5). --- `167-222`: **Excellent test coverage for gap-filling behavior.** This test comprehensively validates that `GetNextID()` correctly identifies and fills gaps in the ID sequence. The three successive calls verify: 1. Finding the first gap (ID 2) 2. Finding the second gap (ID 4) 3. Continuing past the last occupied ID (returns 6 after 5) This ensures the implementation handles sparse ID sequences correctly. </blockquote></details> <details> <summary>.issues/.counter (1)</summary><blockquote> `1-1`: **Counter progression looks correct.** The increment from 18 to 19 is consistent with the creation of issue 018 documented in this PR. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Summary by CodeRabbit
Bug Fixes
Tests
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.