Skip to content

Conversation

@gocanto
Copy link
Collaborator

@gocanto gocanto commented Oct 16, 2025

Summary

  • rename all Go functions prefixed with Make to use a New prefix instead
  • update references across handlers, middleware, kernel, and supporting packages to reflect the new constructor names
  • refresh documentation references so guidance matches the updated function names

Testing

  • go test ./...

https://chatgpt.com/codex/tasks/task_e_68f0a27ee468833381cd365441b9cada

Summary by CodeRabbit

  • Refactor
    • Standardized constructor/factory naming across the codebase (Make* → New*), updated docs and tests to match. No functional or behavioral changes; existing features and APIs behave the same for end users.

@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This PR renames exported constructor/factory functions from the MakeX naming pattern to NewX across the codebase, updating all call sites, tests, and documentation to use the New* identifiers. No behavioral, parameter, or return-type changes are introduced.

Changes

Cohort / File(s) Summary
Core app & kernel
main.go, metal/kernel/... (metal/kernel/app.go, metal/kernel/factory.go, metal/kernel/ignite.go, metal/kernel/kernel_test.go)
Renamed core constructors: MakeApp, MakeEnv, MakeLogs, MakeSentry, MakeDbConnectionNewApp, NewEnv, NewLogs, NewSentry, NewDbConnection; updated internal calls and tests.
Database & seeder
database/... (database/connection.go, database/connection_test.go, database/truncate.go, database/truncate_test.go, database/seeder/..., database/repository/...)
Renamed connection/truncate/seed constructors and pagination: MakeConnection, MakeTruncate, Make*Seed, MakePaginationNewConnection, NewTruncate, New*Seed, NewPagination; updated call sites and tests.
Handlers & router
handler/..., metal/router/router.go, metal/router/...
Renamed all handler constructors and related helpers: Make*Handler, MakeFromNew*Handler, NewFrom; updated router wiring to use NewApiHandler and new handler builders.
Middleware & auth
pkg/middleware/..., pkg/auth/...
Renamed middleware/token/auth constructors: MakePublicMiddleware, MakeTokenMiddleware, MakeTokensHandlerNewPublicMiddleware, NewTokenMiddleware, NewTokensHandler; updated tests.
Endpoint & response utilities
pkg/endpoint/...
Renamed MakeApiHandler, MakeResponseFrom, MakeNoCacheResponseNewApiHandler, NewResponseFrom, NewNoCacheResponse; updated tests and usages.
Portal utilities
pkg/portal/...
Renamed portal constructors: MakeDefaultClient, MakePassword, MakeStringable, MakeValidatorFromNewDefaultClient, NewPassword, NewStringable, NewValidatorFrom; updated call sites and tests.
Logging & media
pkg/llogs/files_logs.go, pkg/media/...
Renamed MakeFilesLogsNewFilesLogs and MakeMediaNewMedia; updated tests and usages.
CLI (metal/cli)
metal/cli/... (metal/cli/main.go, metal/cli/accounts/..., metal/cli/posts/..., metal/cli/panel/..., metal/cli/seo/..., metal/cli/clitest/...)
Renamed CLI factories and helpers from Make*New* (handlers, menu, test helpers, client/validator usages); updated tests and helper functions.
Handler tests & test helpers
handler/tests/db.go, .../*_test.go
Renamed test helpers and test call sites (MakeTestDB, MakeTestConnection, MakeTestEnvNewTestDB, NewTestConnection, NewTestEnv) and updated error messages.
Docs
docs/... (docs/middleware/token_middleware.md, docs/sentry_analysis.md)
Updated documentation references from Make* to New* constructor names.

Sequence Diagram(s)

(omitted — changes are identifier renames across existing control flows; control flow itself is unchanged)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Reasoning: Widespread but homogeneous renames across many packages and tests; review requires ensuring no symbol was missed and that public API consumers are aligned, but logic density per file is low.

Possibly related PRs

Poem

🐰 I hopped from Make to New today —

each constructor found a brighter way.
From Connection, Media, seeds, and more,
I nudged their names and bounded o'er.
New things sprout where old ones used to play.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "chore: Rename Make* constructors to New*" accurately and specifically describes the primary change throughout the entire changeset. The raw summary confirms that every file modification involves renaming exported constructor functions from the Make* naming convention to the New* convention, along with updating all corresponding call sites and documentation references. The title is concise, clear, uses no vague language or noise, and a developer scanning commit history would immediately understand this is a systematic refactoring of constructor naming patterns.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gus/rename-functions-from-make-to-new-2025-10-16

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 and usage tips.

@gocanto gocanto marked this pull request as draft October 16, 2025 07:56
@gemini-code-assist
Copy link

Summary of Changes

Hello @gocanto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a significant refactoring effort to standardize constructor naming conventions throughout the Go codebase. By consistently using the 'New' prefix for constructor functions, the change aims to improve code readability, maintainability, and adherence to Go best practices. This is a purely cosmetic and organizational change, with no alteration to the underlying logic or functionality of the application.

Highlights

  • Constructor Renaming: All Go functions prefixed with 'Make' have been renamed to use the 'New' prefix, aligning with idiomatic Go constructor naming conventions.
  • Codebase-Wide Updates: References to these constructors have been updated across various parts of the application, including handlers, middleware, the kernel, database repositories, and supporting packages.
  • Documentation Refresh: Relevant documentation references have been refreshed to reflect the updated function names, ensuring consistency in guidance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great initiative to align the codebase with idiomatic Go conventions by renaming Make* constructors to New*. The changes are extensive and have been applied consistently across the codebase, including source files, tests, and documentation. I've only found a few minor inconsistencies in test error messages that could be updated for full consistency. Overall, this is a solid and well-executed refactoring.

@gocanto gocanto removed the codex label Oct 16, 2025
@gocanto gocanto marked this pull request as ready for review October 16, 2025 08:43
@gocanto gocanto changed the title Rename Make* constructors to New* chore: Rename Make* constructors to New* Oct 16, 2025
@gocanto gocanto marked this pull request as draft October 16, 2025 08:57
@gocanto gocanto marked this pull request as ready for review October 17, 2025 01:23
Copy link

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (8)
database/seeder/importer/runner_test.go (1)

714-716: LGTM!

The constructor call and error message have been correctly updated to reflect the new naming convention.

metal/cli/seo/testhelpers_test.go (1)

105-107: LGTM!

The constructor call and error message have been correctly updated to reflect the new naming convention.

database/seeder/seeds/seeder_test.go (1)

64-67: LGTM!

The constructor call and error message have been correctly updated to reflect the new naming convention.

database/connection_test.go (1)

72-74: LGTM!

The constructor call and error message have been correctly updated to reflect the new naming convention.

database/repository/repository_test.go (1)

68-71: LGTM!

The constructor call and error message have been correctly updated to reflect the new naming convention.

metal/cli/clitest/helpers.go (1)

63-65: LGTM! Call site and error message correctly updated.

Both the function call and error message have been updated to reflect the new NewConnection naming.

metal/cli/accounts/handler_test.go (1)

11-15: LGTM! Test setup correctly updated.

All constructor calls and the error message have been updated to use the new New* naming convention.

metal/cli/accounts/factory_test.go (1)

10-15: LGTM! Test function and setup correctly updated.

The test name, constructor calls, and error message have all been updated to reflect the new New* naming convention.

🧹 Nitpick comments (1)
pkg/media/media_test.go (1)

28-28: Optional: Consider more descriptive error messages.

While "new: %v" is consistent with the function rename, slightly more descriptive messages could improve test failure diagnostics.

Example alternatives:

-		t.Fatalf("new: %v", err)
+		t.Fatalf("NewMedia failed: %v", err)

Or:

-		t.Fatalf("new: %v", err)
+		t.Fatalf("failed to create media: %v", err)

Note: The current error messages have already been updated per previous review suggestions, so this is purely a nice-to-have refinement.

Also applies to: 79-79

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f31990 and 821928d.

📒 Files selected for processing (13)
  • database/connection_test.go (1 hunks)
  • database/repository/repository_test.go (1 hunks)
  • database/repository/testhelpers_test.go (1 hunks)
  • database/seeder/importer/runner_test.go (1 hunks)
  • database/seeder/seeds/seeder_test.go (2 hunks)
  • handler/tests/db.go (2 hunks)
  • metal/cli/accounts/factory_test.go (2 hunks)
  • metal/cli/accounts/handler_test.go (1 hunks)
  • metal/cli/clitest/helpers.go (3 hunks)
  • metal/cli/seo/testhelpers_test.go (1 hunks)
  • pkg/auth/handler_test.go (4 hunks)
  • pkg/llogs/files_logs_test.go (1 hunks)
  • pkg/media/media_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • database/repository/testhelpers_test.go
  • handler/tests/db.go
🧰 Additional context used
🧬 Code graph analysis (11)
pkg/llogs/files_logs_test.go (1)
pkg/llogs/files_logs.go (1)
  • NewFilesLogs (19-44)
database/seeder/importer/runner_test.go (1)
database/connection.go (1)
  • NewConnection (19-32)
metal/cli/accounts/factory_test.go (3)
metal/cli/clitest/helpers.go (2)
  • NewTestConnection (16-76)
  • NewTestEnv (78-80)
database/model.go (1)
  • APIKey (27-39)
metal/cli/accounts/factory.go (1)
  • NewHandler (19-34)
metal/cli/seo/testhelpers_test.go (1)
database/connection.go (1)
  • NewConnection (19-32)
pkg/media/media_test.go (1)
pkg/media/media.go (1)
  • NewMedia (30-58)
database/repository/repository_test.go (1)
database/connection.go (1)
  • NewConnection (19-32)
pkg/auth/handler_test.go (1)
pkg/auth/handler.go (1)
  • NewTokensHandler (16-26)
database/connection_test.go (1)
database/connection.go (1)
  • NewConnection (19-32)
metal/cli/clitest/helpers.go (2)
database/connection.go (2)
  • Connection (12-17)
  • NewConnection (19-32)
metal/env/env.go (1)
  • Environment (9-17)
metal/cli/accounts/handler_test.go (2)
metal/cli/clitest/helpers.go (2)
  • NewTestConnection (16-76)
  • NewTestEnv (78-80)
metal/cli/accounts/factory.go (1)
  • NewHandler (19-34)
database/seeder/seeds/seeder_test.go (2)
database/connection.go (1)
  • NewConnection (19-32)
database/seeder/seeds/factory.go (1)
  • NewSeeder (17-22)
🔇 Additional comments (8)
pkg/llogs/files_logs_test.go (2)

19-19: LGTM! Constructor renaming is correct.

The function call has been properly updated from MakeFilesLogs to NewFilesLogs, consistent with the PR's renaming objectives. The function signature matches the implementation shown in the relevant code snippets.


22-22: LGTM! Error message updated to match new function name.

The error message has been appropriately updated from "make logs" to "new logs", addressing the previous review feedback and maintaining consistency with the renamed constructor.

pkg/auth/handler_test.go (1)

12-12: LGTM! Rename refactoring completed consistently.

All constructor calls and error messages have been correctly updated from Make* to New* throughout the test file. The test function name TestNewTokensHandlerError (line 35) also reflects the new naming convention. The changes align with the PR objective and the past review comments have been addressed.

Also applies to: 15-15, 35-36, 50-50, 53-53, 74-74, 77-77

database/seeder/seeds/seeder_test.go (1)

95-95: LGTM!

The seeder factory call has been correctly updated from MakeSeeder to NewSeeder, consistent with the codebase-wide renaming pattern.

metal/cli/clitest/helpers.go (2)

16-16: LGTM! Function rename follows Go conventions.

The rename from MadeTestConnection to NewTestConnection aligns with idiomatic Go constructor naming patterns.


78-80: LGTM! Function rename follows Go conventions.

The rename from MadeTestEnv to NewTestEnv aligns with idiomatic Go constructor naming patterns.

metal/cli/accounts/factory_test.go (1)

33-40: LGTM! Test function correctly updated.

The test name and all constructor calls have been updated to use the new New* naming convention.

pkg/media/media_test.go (1)

21-87: LGTM! Rename is complete and consistent.

All references to MakeMedia have been correctly updated to NewMedia throughout the test file, including:

  • Test function names (TestNewMediaAndUpload, TestNewMediaErrors)
  • All function calls with correct signature matching
  • Error messages updated to reflect the new constructor name

The changes follow Go naming conventions and previous review feedback has been implemented.

@gocanto gocanto merged commit 7ea2c83 into main Oct 17, 2025
5 checks passed
@gocanto gocanto deleted the gus/rename-functions-from-make-to-new-2025-10-16 branch October 17, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants