feat: add a helper for the most recent entries - #286
Conversation
|
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe Cassandra session package adds a private ChangesCassandra session utility
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/cassandra/session.go`:
- Line 195: Resolve the unused private helper lastN before merging: either add
an appropriate caller in the same package or add a same-package test that
exercises it; if neither is needed, remove or defer lastN until a caller is
ready so the unused lint check passes.
- Line 203: Update the suffix slice expression in the surrounding session method
to start at len(s)-n rather than len(s)-n-1, ensuring it returns exactly n
entries when the slice contains more than n elements.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 05d45c10-b755-40c4-8b96-b7ec6b26a26e
📒 Files selected for processing (1)
pkg/cassandra/session.go
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Build, lint and unit tests
- GitHub Check: compatibilitycheck
🧰 Additional context used
📓 Path-based instructions (1)
pkg/**
⚙️ CodeRabbit configuration file
Go backend using the Grafana backend plugin SDK and the gocql driver. Check for Cassandra query safety, connection/session lifecycle, and TLS handling.
Files:
pkg/cassandra/session.go
🪛 golangci-lint (2.12.2)
pkg/cassandra/session.go
[error] 195-195: func lastN is unused
(unused)
| return s | ||
| } | ||
|
|
||
| return s[len(s)-n-1:] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Fix the suffix start index.
Use len(s)-n, not len(s)-n-1. The current code returns n+1 entries when the slice is longer than n.
Proposed fix
- return s[len(s)-n-1:]
+ return s[len(s)-n:]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return s[len(s)-n-1:] | |
| return s[len(s)-n:] |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/cassandra/session.go` at line 203, Update the suffix slice expression in
the surrounding session method to start at len(s)-n rather than len(s)-n-1,
ensuring it returns exactly n entries when the slice contains more than n
elements.
Several places want to show only the tail of a list — the last few keyspaces touched, the last few ids in a debug line. Pull that out so it is written once.
Call sites follow in the next PR.
🤖 Generated with Claude Code
Summary by CodeRabbit