chore: use file.PutContent replace deprecated file.Create#901
chore: use file.PutContent replace deprecated file.Create#901hwbrzzl merged 30 commits intogoravel:masterfrom kuafuRace:replace-fileCreate
file.PutContent replace deprecated file.Create#901Conversation
- Add `env:encrypt` command to generate `.env.encrypted` - Add `env:decrypt` command to generate `.env` from `.env.encrypted`
- Add `env:encrypt` command to generate `.env.encrypted` - Add `env:decrypt` command to generate `.env` from `.env.encrypted`
- Add `env:encrypt` command to generate `.env.encrypted` - Add `env:decrypt` command to generate `.env` from `.env.encrypted`
…t encryption key
…ile.PutContent` method
….PutContent` method
….PutContent` method
…d decryption commands
WalkthroughThis pull request updates the codebase to replace calls to Changes
Possibly related PRs
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 golangci-lint (1.62.2)Error: can't load config: the Go language version (go1.23) used to build golangci-lint is lower than the targeted Go version (1.24.0) ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
|
Ready Review |
file.PutContent replace deprecated file.Createfile.PutContent replace deprecated file.Create
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
database/console/seeder_make_command.go (1)
52-54: Consider consistent error handling across commands.While the change to
file.PutContentis correct, the error handling differs from other similar commands. Other commands log the error usingctx.Error()before returning, but this one directly returns the error.Consider applying this change for consistency:
if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil { + ctx.Error(err.Error()) - return err + return nil }auth/console/policy_make_command.go (1)
52-54: Consider consistent error handling across commands.While the change to
file.PutContentis correct, the error handling differs from other similar commands. Other commands log the error usingctx.Error()before returning, but this one directly returns the error.Consider applying this change for consistency:
if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil { + ctx.Error(err.Error()) - return err + return nil }database/console/observer_make_command.go (1)
52-54: Consider consistent error handling.The error handling here differs from other similar commands. Other commands log the error and return nil, while this one returns the error directly.
Consider applying this change for consistency:
if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil { - return err + ctx.Error(err.Error()) + return nil }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (35)
auth/console/jwt_secret_command_test.go(2 hunks)auth/console/policy_make_command.go(1 hunks)console/console/key_generate_command_test.go(2 hunks)console/console/make_command.go(1 hunks)database/console/factory_make_command.go(1 hunks)database/console/model_make_command.go(1 hunks)database/console/observer_make_command.go(1 hunks)database/console/seeder_make_command.go(1 hunks)database/migration/migrator.go(1 hunks)event/console/event_make_command.go(1 hunks)event/console/listener_make_command.go(1 hunks)foundation/application_test.go(1 hunks)foundation/console/about_command_test.go(1 hunks)foundation/console/env_decrypt_command_test.go(4 hunks)foundation/console/env_encrypt_command_test.go(5 hunks)foundation/console/package_make_command.go(1 hunks)foundation/console/test_make_command.go(1 hunks)foundation/console/vendor_publish_command.go(1 hunks)foundation/console/vendor_publish_command_test.go(3 hunks)http/console/controller_make_command.go(1 hunks)http/console/middleware_make_command.go(1 hunks)http/console/request_make_command.go(1 hunks)http/context.go(1 hunks)log/logrus_writer_test.go(1 hunks)mail/console/mail_make_command.go(1 hunks)queue/console/job_make_command.go(1 hunks)queue/task_test.go(1 hunks)session/driver/file.go(1 hunks)support/console/console_test.go(2 hunks)support/docker/container.go(1 hunks)support/file/file_test.go(2 hunks)testing/http/assertable_json_test.go(11 hunks)translation/file_loader_test.go(1 hunks)validation/console/filter_make_command.go(1 hunks)validation/console/rule_make_command.go(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- foundation/console/about_command_test.go
- testing/http/assertable_json_test.go
🧰 Additional context used
🪛 Gitleaks (8.21.2)
foundation/console/env_decrypt_command_test.go
18-18: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🔇 Additional comments (35)
http/context.go (1)
25-26: LGTM! Improved readability with better receiver naming.The change from
rtocas the receiver variable name is a good improvement, as it better represents the context receiver and follows common Go conventions.Also applies to: 34-36, 39-40, 43-44
queue/task_test.go (1)
23-23: LGTM! Successfully replaced deprecated method.The change from
file.Createtofile.PutContentaligns with the PR objective and maintains the same functionality.auth/console/jwt_secret_command_test.go (1)
24-24: LGTM! Successfully replaced deprecated method in test functions.The change from
file.Createtofile.PutContentin both test functions aligns with the PR objective while maintaining the same test behavior.Also applies to: 47-47
event/console/event_make_command.go (1)
48-48: LGTM! Successfully replaced deprecated method in command handler.The change from
file.Createtofile.PutContentin theHandlemethod aligns with the PR objective while maintaining the same functionality and error handling.session/driver/file.go (1)
89-89:Details
❓ Verification inconclusive
LGTM! Correctly replaced deprecated method.
The change from
file.Createtofile.PutContentmaintains the same functionality while using the updated method.Let's verify the deprecation notice for
file.Create:
🏁 Script executed:
#!/bin/bash # Search for deprecation notice in file package rg -A 2 "Create.*\[Deprecated\]" || rg -A 2 "@deprecated.*Create"Length of output: 66
LGTM with a manual deprecation check required.
The change from
file.Createtofile.PutContentpreserves the intended functionality and thread safety. However, our automated search did not find any deprecation notice forfile.Create. Please manually verify whetherfile.Createis marked as deprecated in the file package documentation to ensure the correctness of this update.console/console/make_command.go (1)
46-46: LGTM! Consistent with the deprecation update.The replacement maintains the same error handling and functionality while using the updated method.
foundation/console/test_make_command.go (1)
53-53: LGTM! Properly updated to use non-deprecated method.The change maintains consistency with other files while preserving error handling and functionality.
database/console/model_make_command.go (1)
52-52: LGTM! Successfully updated to non-deprecated method.The change aligns with the updates in other files while maintaining proper error handling.
mail/console/mail_make_command.go (1)
52-52: LGTM! Appropriate use offile.PutContent.The change from
file.Createtofile.PutContentis correctly implemented, maintaining the same error handling pattern.http/console/middleware_make_command.go (1)
48-48: LGTM! Appropriate use offile.PutContent.The change from
file.Createtofile.PutContentis correctly implemented, maintaining the same error handling pattern.queue/console/job_make_command.go (1)
49-49: LGTM! Correctly replaced deprecated method.The change from
file.Createtofile.PutContentis appropriate and maintains the same functionality.validation/console/rule_make_command.go (1)
49-49: LGTM! Correctly replaced deprecated method.The change from
file.Createtofile.PutContentis appropriate and maintains the same functionality.database/console/factory_make_command.go (1)
52-52: LGTM! Correctly replaced deprecated method.The change from
file.Createtofile.PutContentis appropriate and maintains the same functionality.http/console/request_make_command.go (1)
48-48: LGTM: Appropriate replacement of deprecated method.The change from
file.Createtofile.PutContentis correctly implemented with proper error handling.validation/console/filter_make_command.go (1)
49-49: LGTM: Consistent implementation of file handling update.The replacement of
file.Createwithfile.PutContentis properly implemented.http/console/controller_make_command.go (2)
58-58: LGTM: Well-implemented file handling update.The change from
file.Createtofile.PutContentis correctly implemented with proper error handling.
1-1:Details
✅ Verification successful
Verify complete replacement of deprecated method.
Let's ensure all instances of
file.Createhave been replaced throughout the codebase.
🏁 Script executed:
#!/bin/bash # Search for any remaining instances of file.Create ast-grep --pattern 'file.Create($$$)'Length of output: 39
Below is an additional verification step using
rg(ripgrep) to ensure no instances offile.Createremain in the codebase. Please run this command and verify the output manually:Once confirmed that no instances of
file.Createappear, you can consider the deprecated method fully replaced.
🏁 Script executed:
#!/bin/bash # Re-verify using ripgrep for any occurrences of file.Create (case-insensitive) rg --ignore-case 'file\.Create' .Length of output: 35
Replacement verified for deprecated method usage.
All instances of
file.Createhave been successfully replaced throughout the codebase. Both the AST-based search and the ripgrep verification confirmed that no references tofile.Createremain.foundation/console/package_make_command.go (1)
84-84: LGTM! Successfully replaced deprecated method.The change from
file.Createtofile.PutContentis correctly implemented while maintaining the same error handling and functionality.support/file/file_test.go (1)
24-24: LGTM! Test cases updated correctly.The test cases have been properly updated to use
PutContentinstead ofCreate. The comprehensive test coverage inTestPutContentensures the reliability of this change.Also applies to: 54-54
console/console/key_generate_command_test.go (1)
33-33: LGTM! Test cases updated correctly.The key generation test cases have been properly updated to use
PutContentinstead ofCreate. The test coverage remains comprehensive, including environment-specific behavior and error cases.Also applies to: 76-76
translation/file_loader_test.go (1)
27-34: LGTM! Test setup updated correctly.The translation file loader test setup has been properly updated to use
PutContentinstead ofCreate. The test coverage remains comprehensive, including various file types, permissions, and error cases.support/docker/container.go (1)
160-160: LGTM: Successfully replaced deprecated method.The change from
file.Createtofile.PutContentmaintains the same functionality while using the updated API.foundation/console/env_decrypt_command_test.go (2)
16-18: LGTM: Improved test data organization.Moving test data to constants improves maintainability and reusability.
🧰 Tools
🪛 Gitleaks (8.21.2)
18-18: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
29-31: LGTM: Successfully replaced deprecated method.The change from
file.Createtofile.PutContentmaintains the same functionality while using the updated API.foundation/console/env_encrypt_command_test.go (2)
17-18: LGTM: Improved test data organization.Moving test data to constants improves maintainability and reusability.
30-31: LGTM: Successfully replaced deprecated method.The change from
file.Createtofile.PutContentmaintains the same functionality while using the updated API.support/console/console_test.go (2)
93-93: LGTM: Successfully replaced deprecated method.The change from
file.Createtofile.PutContentmaintains the same functionality while using the updated API.
103-103: LGTM: Successfully replaced deprecated method.The change from
file.Createtofile.PutContentmaintains the same functionality while using the updated API.foundation/console/vendor_publish_command.go (1)
243-243: LGTM: Successfully replaced deprecated method.The change from
file.Createtofile.PutContentaligns with the PR objective and maintains the existing error handling.database/migration/migrator.go (1)
41-41: LGTM: Successfully replaced deprecated method.The change from
supportfile.Createtosupportfile.PutContentis correctly implemented and maintains the existing error handling for migration file creation.foundation/console/vendor_publish_command_test.go (3)
37-37: LGTM: Successfully updated test file creation.Test setup correctly uses
file.PutContentfor creating test files inTestGetSourceFiles.Also applies to: 39-39
67-67: LGTM: Successfully updated test file creation.Test setup correctly uses
file.PutContentfor creating test files inTestGetSourceFilesForDir.Also applies to: 69-69, 71-71, 73-73, 75-75
277-277: LGTM: Successfully updated test file creation.Test setup correctly uses
file.PutContentfor creating test files inTestPublish.Also applies to: 279-279, 281-281, 283-283
foundation/application_test.go (1)
47-47: LGTM: Successfully updated test environment file creation.The change from
file.Createtofile.PutContentis correctly implemented for creating the test.envfile.log/logrus_writer_test.go (1)
609-609: LGTM! The change fromfile.Createtofile.PutContentis appropriate.The replacement aligns with the PR objective to update deprecated method calls, and the implementation maintains proper error handling.
| if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Maintain consistent error handling across commands.
Other command handlers log errors using ctx.Error() before returning. Consider updating the error handling to match:
if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil {
- return err
+ ctx.Error(err.Error())
+ return nil
}📝 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.
| if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil { | |
| return err | |
| } | |
| if err := file.PutContent(m.GetFilePath(), r.populateStub(r.getStub(), m.GetPackageName(), m.GetStructName())); err != nil { | |
| ctx.Error(err.Error()) | |
| return nil | |
| } |
📑 Description
use
file.PutContentreplace deprecatedfile.CreateSummary by CodeRabbit
✅ Checks