🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

chore: dedupe imports and simplify expressions - #1780

Merged
AmanGIT07 merged 1 commit into
mainfrom
chore/dedup-imports-and-simplify
Jul 22, 2026
Merged

chore: dedupe imports and simplify expressions#1780
AmanGIT07 merged 1 commit into
mainfrom
chore/dedup-imports-and-simplify

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Summary

Mechanical cleanups with no behavior change: remove duplicate imports and replace expressions with their shorter defined-equivalent forms.

Changes

  • cmd/preferences.go, cmd/root.go, cmd/server.go: cobra was imported twice (bare and as cli) and both names were used in the same file. Keep the cli alias, which the rest of the package uses.
  • internal/api/v1beta1connect/policy_test.go: the mocks package was imported under two names; keep mocks.
  • billing/credit/service_test.go: errors.New(fmt.Sprintf(...))fmt.Errorf(...) (same message, %v kept so wrapping semantics stay unchanged)
  • core/event/service.go: drop a fmt.Sprintf("%s", s) on a value that is already a string
  • core/relation/service.go: the ID regex uses a raw string, removing the double escaping
  • internal/api/v1beta1connect/permission_test.go: copy loop → append(dst, src...)
  • internal/api/v1beta1connect/prospect.go: merge a variable declaration with its assignment
  • internal/store/postgres/null_converters.go, organization_repository.go: drop nil checks that duplicate what len and range already define for nil maps

Test Plan

  • Build and type checking passes
  • Tests pass for every touched package (cmd, billing/credit, core/event, v1beta1connect, postgres)

SQL Safety (if your PR touches *_repository.go or goqu.*)

  • Values flow through ? placeholders, goqu.Ex{}, or goqu.Record{} — never fmt.Sprintf or + building a query that gets executed.
  • ToSQL() callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Never query, _, err := ….
  • No ? placeholders inside single-quoted SQL literals in goqu.L (use make_interval(hours => ?)-style functions instead).
  • Any //nolint:forbidigo or // #nosec G20x annotation has a one-line justification on the same line that a reviewer can verify.

Remove double imports of the same package and replace expressions with
their shorter defined-equivalent forms. No behavior change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jul 21, 2026 7:01am

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ef109512-3d5e-492e-8104-f6094f80ab3f

📥 Commits

Reviewing files that changed from the base of the PR and between 9c2a0b0 and 9198eb8.

📒 Files selected for processing (11)
  • billing/credit/service_test.go
  • cmd/preferences.go
  • cmd/root.go
  • cmd/server.go
  • core/event/service.go
  • core/relation/service.go
  • internal/api/v1beta1connect/permission_test.go
  • internal/api/v1beta1connect/policy_test.go
  • internal/api/v1beta1connect/prospect.go
  • internal/store/postgres/null_converters.go
  • internal/store/postgres/organization_repository.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency when generating onboarding credit transaction identifiers.
    • Preserved empty metadata handling when storing records and recording organization title changes.
  • Refactor

    • Standardized command-line command handling across preferences, server, and root commands without changing available behavior.
  • Tests

    • Updated billing, permissions, and policy test coverage for clearer, more maintainable validation.

Walkthrough

The changes standardize Cobra command aliases, simplify core and persistence metadata handling, adjust onboarding transaction ID input, and update related test setup and expectations.

Changes

Repository cleanup

Layer / File(s) Summary
Standardize CLI command aliases
cmd/preferences.go, cmd/root.go, cmd/server.go
CLI command constructors, return types, argument validators, and callback signatures consistently use the cli alias.
Simplify core service and validation code
core/event/service.go, core/relation/service.go, internal/api/v1beta1connect/prospect.go
Transaction ID input, regex literal construction, and metadata map initialization are simplified without changing surrounding flow.
Simplify persistence metadata handling
internal/store/postgres/null_converters.go, internal/store/postgres/organization_repository.go
Empty metadata uses length-based validation, and audit metadata copying iterates directly over the metadata map.
Update test setup and expectations
billing/credit/service_test.go, internal/api/v1beta1connect/permission_test.go, internal/api/v1beta1connect/policy_test.go
Tests use direct formatted errors, variadic append, and the shared project-service mock type.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: rohilsurana

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 29808915020

Coverage decreased (-0.004%) to 46.197%

Details

  • Coverage decreased (-0.004%) from the base build.
  • Patch coverage: 2 uncovered changes across 2 files (24 of 26 lines covered, 92.31%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
core/relation/service.go 1 0 0.0%
internal/store/postgres/organization_repository.go 2 1 50.0%
Total (8 files) 26 24 92.31%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
internal/store/postgres/organization_repository.go 1 78.92%

Coverage Stats

Coverage Status
Relevant Lines: 38433
Covered Lines: 17755
Line Coverage: 46.2%
Coverage Strength: 13.36 hits per line

💛 - Coveralls

@AmanGIT07
AmanGIT07 requested a review from rohilsurana July 22, 2026 06:51
@AmanGIT07
AmanGIT07 merged commit c043e4e into main Jul 22, 2026
8 checks passed
@AmanGIT07
AmanGIT07 deleted the chore/dedup-imports-and-simplify branch July 22, 2026 08:57
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.

3 participants