-
Notifications
You must be signed in to change notification settings - Fork 26
Refactor: Preserve original comments and clarify error handling in placeholder schemas #168
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: master
Are you sure you want to change the base?
Conversation
…ndling - Restore and retain all original code comments for schema interfaces and processing functions. - Ensure placeholder methods (Map, struct, slice schema) provide clear panic messages when used, but do not affect user-facing API or primitive processing. - No functional changes to primitive parsing/validation; only code hygiene and documentation clarity improved.
WalkthroughThis update introduces placeholder implementations for map, struct, and slice schemas in the zog package. It adds new schema types and interfaces, each with stub methods that currently panic with "not implemented" messages. A shared error variable for unimplemented functionality is also included, and necessary imports are added. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant zog.Map
participant mapSchema
User->>zog.Map: Call Map(keySchema, valueSchema)
zog.Map->>mapSchema: Return new mapSchema instance
User->>mapSchema: Call Parse/process/validate
mapSchema-->>User: Panic "not implemented"
Poem
✨ 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. 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)
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: 0
🧹 Nitpick comments (3)
zogSchema.go (3)
56-63
: Prefer a single sentinel error over hard-coded stringsThree different “not implemented” panic strings are scattered across the new placeholder methods. This duplicates information and makes future text-search clean-ups harder.
Leverage the already–declaredErrNotImplemented
so the reason (and its wording) is defined in exactly one place.-func (m *mapSchema) process(ctx *p.SchemaCtx) { panic("z.Map() not implemented") } -func (m *mapSchema) validate(ctx *p.SchemaCtx) { panic("z.Map() not implemented") } +func (m *mapSchema) process(ctx *p.SchemaCtx) { panic(ErrNotImplemented) } +func (m *mapSchema) validate(ctx *p.SchemaCtx) { panic(ErrNotImplemented) } ... - panic("z.Map() is not implemented yet. See roadmap in README.md") + panic(ErrNotImplemented)Replicate the same change for
structSchema
andsliceSchema
to keep behaviour consistent.
119-121
:ErrNotImplemented
declared but never referencedOnce the previous comment is applied, this variable will be used.
If you decide to keep the per-method panic strings, either removeErrNotImplemented
or prefix its name with_
to silencego vet
unused-variable warnings.
42-49
: Minor API ergonomics: acceptnil
key/value schema inMap
Even as a stub, passing
nil
for eitherkeySchema
orvalueSchema
currently compiles and panics only later.
Early validation guards make mis-use explicit and cheaper to debug.func Map(keySchema, valueSchema ZogSchema) MapZogSchema { + if keySchema == nil || valueSchema == nil { + panic("z.Map(): keySchema and valueSchema must be non-nil") + } return &mapSchema{ keySchema: keySchema, valueSchema: valueSchema, } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
zogSchema.go
(4 hunks)
🔇 Additional comments (1)
zogSchema.go (1)
85-94
: Confirm there are no existingstructSchema
/sliceSchema
type collisions
structSchema
andsliceSchema
are fairly generic names and may already exist in the package history (or in other files) as concrete implementations rather than placeholders.
Name collisions would lead to compilation errors that are easy to miss in a large codebase.#!/bin/bash # Search the whole repo for duplicate type declarations. rg -n $'type (structSchema|sliceSchema) struct'
This PR refactors the
zogSchema.go
file to maintain all original comments for documentation clarity and future maintainability.Key changes include:
Map
,struct
, andslice
now use clear panic messages for unimplemented methods, providing explicit error signaling.Summary by CodeRabbit
New Features
Chores