refactor: currencies service pkg#4638
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (19)
💤 Files with no reviewable changes (2)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (15)
📝 WalkthroughWalkthroughThe currencies package now uses split ChangesCurrencies domain, service, and handler refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
73d9a3c to
d953ff4
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
openmeter/currencies/service.go (1)
40-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWrap these validators with
models.NewNillableGenericValidationError.
ListCurrenciesInput,CreateCurrencyInput,CreateCostBasisInput, andListCostBasesInputshould returnmodels.NewNillableGenericValidationError(errors.Join(errs...))instead of a rawerrors.Join(...).OrderBy.Validate()should use the same validation error type for the invalid case too.🤖 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 `@openmeter/currencies/service.go` around lines 40 - 46, The validation paths are returning raw errors instead of the project’s nillable generic validation type. Update the validation logic in ListCurrenciesInput, CreateCurrencyInput, CreateCostBasisInput, and ListCostBasesInput so they wrap the joined validation errors with models.NewNillableGenericValidationError, and make OrderBy.Validate return that same error type for invalid values instead of a plain fmt.Errorf. Use the existing validation helpers and the OrderBy.Validate method as the main points to adjust.Source: Coding guidelines
🤖 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 `@openmeter/currencies/currency.go`:
- Around line 12-19: CurrencyType.Validate currently fails fast by returning a
plain fmt.Errorf in the default branch, but it should follow the project
validation pattern. Update Validate() to build a var errs []error, append the
invalid-type error when t is not CurrencyTypeCustom or CurrencyTypeFiat, and
return models.NewNillableGenericValidationError(errors.Join(errs...)) instead of
returning immediately.
In `@openmeter/currencies/service/service_test.go`:
- Around line 71-73: `New` now returns an error, so the test helper and any
other `New(...)` call sites in this file must be updated to handle the second
return value. In `newTestService`, create the service and error from
`New(&fakeAdapter{custom: custom})`, then assert the error is nil with
`require.NoError(t, err)` before returning the service; apply the same pattern
to the other `New` usages in this test file.
---
Nitpick comments:
In `@openmeter/currencies/service.go`:
- Around line 40-46: The validation paths are returning raw errors instead of
the project’s nillable generic validation type. Update the validation logic in
ListCurrenciesInput, CreateCurrencyInput, CreateCostBasisInput, and
ListCostBasesInput so they wrap the joined validation errors with
models.NewNillableGenericValidationError, and make OrderBy.Validate return that
same error type for invalid values instead of a plain fmt.Errorf. Use the
existing validation helpers and the OrderBy.Validate method as the main points
to adjust.
🪄 Autofix (Beta)
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: 5bfddfd7-8889-4a81-8fe8-5975ce6bd14a
📒 Files selected for processing (17)
api/v3/handlers/currencies/create.goapi/v3/handlers/currencies/create_cost_basis.goapi/v3/handlers/currencies/get_cost_bases.goapi/v3/handlers/currencies/handler.goapi/v3/handlers/currencies/list.goapp/common/currency.gocmd/server/wire.gocmd/server/wire_gen.goopenmeter/currencies/adapter/adapter.goopenmeter/currencies/adapter/currencies.goopenmeter/currencies/costbasis.goopenmeter/currencies/currency.goopenmeter/currencies/models.goopenmeter/currencies/repository.goopenmeter/currencies/service.goopenmeter/currencies/service/service.goopenmeter/currencies/service/service_test.go
💤 Files with no reviewable changes (2)
- openmeter/currencies/adapter/currencies.go
- openmeter/currencies/models.go
Greptile SummaryThis PR refactors the
Confidence Score: 4/5Safe to merge with one fix: validation error messages now carry a redundant "validation error:" prefix because Validate() wraps errors before the service layer wraps them again. The refactor is mechanical and well-executed overall. The one present defect is that
Important Files Changed
|
d953ff4 to
965f005
Compare
965f005 to
c2f124c
Compare
Overview
Refactor
currenciesservice package to be more aligned with the project. No functional changes.Summary by CodeRabbit