Skip to content
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

chore: deprecate Case2Camel #600

Merged
merged 3 commits into from
Aug 17, 2024
Merged

chore: deprecate Case2Camel #600

merged 3 commits into from
Aug 17, 2024

Conversation

hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Aug 14, 2024

📑 Description

Summary by CodeRabbit

  • New Features
    • Updated command stub generation to use snake case formatting for placeholders, enhancing consistency across the application.
  • Bug Fixes
    • Improved matching logic in data processing by adjusting string transformation methods, which may impact case sensitivity and format handling.
  • Documentation
    • Added deprecation notices for older string transformation methods to guide users towards modern alternatives.

✅ Checks

  • Added test cases for my code

@hwbrzzl hwbrzzl requested a review from a team as a code owner August 14, 2024 10:28
Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Walkthrough

The changes across the codebase primarily involve modifications to string transformation methods, shifting from camel case formatting to snake case and studly case formats. This adjustment impacts how identifiers and placeholders are represented in various functions, potentially altering naming conventions and integration with other systems. The new string manipulation methods are intended to standardize key formats, enhancing consistency throughout the application.

Changes

File Change Summary
database/gorm/cursor.go, event/console/listener_make_command.go, queue/console/job_make_command.go, validation/console/filter_make_command.go, validation/console/rule_make_command.go Updated populateStub methods to replace str.Camel2Case with str.Of(...).Snake().String() for converting structName placeholders to snake case.
database/gorm/event.go, foundation/console/package_make_command_stubs.go, support/console/console.go Changed string transformations from camel case to snake case or studly case in various functions for key formatting, impacting output consistency.
support/str/str.go Marked Case2Camel and Camel2Case as deprecated, encouraging the use of str.Of(name).Studly().String() and str.Of(name).Snake().String() instead.

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.53%. Comparing base (b3dc342) to head (76325df).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #600   +/-   ##
=======================================
  Coverage   69.53%   69.53%           
=======================================
  Files         181      181           
  Lines       11121    11121           
=======================================
  Hits         7733     7733           
  Misses       2811     2811           
  Partials      577      577           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2e271fa and 1698743.

Files selected for processing (9)
  • database/gorm/cursor.go (1 hunks)
  • database/gorm/event.go (2 hunks)
  • event/console/listener_make_command.go (1 hunks)
  • foundation/console/package_make_command_stubs.go (3 hunks)
  • queue/console/job_make_command.go (1 hunks)
  • support/console/console.go (1 hunks)
  • support/str/str.go (2 hunks)
  • validation/console/filter_make_command.go (1 hunks)
  • validation/console/rule_make_command.go (1 hunks)
Additional comments not posted (12)
support/console/console.go (2)

51-51: Verify the impact of changing file path format.

The GetFilePath method now uses snake_case for file names instead of CamelCase. Ensure that any code relying on specific file naming conventions is updated accordingly.

Verification successful

File path format change to snake_case verified successfully.

The GetFilePath method's change to snake_case for file names does not appear to affect any dependencies expecting CamelCase. The usage of GetFilePath is consistent with the new naming convention across the codebase.

  • The method is primarily used for file creation, and no evidence of dependencies on CamelCase was found.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of GetFilePath and ensure compatibility with snake_case naming.

# Test: Search for all usages of GetFilePath. Expect: No dependencies on CamelCase file names.
rg --type go -A 5 'GetFilePath'

Length of output: 8464


58-58: Verify the impact of changing struct name format.

The GetStructName method now uses studly caps instead of CamelCase. Verify that this change does not disrupt any existing functionality or naming conventions.

Verification successful

Change to Studly Caps Verified

The change to using studly caps in the GetStructName method does not disrupt existing functionality or naming conventions. The codebase does not have dependencies on the previous CamelCase format related to this method.

  • The GetStructName method is used in contexts that align with the studly caps format.
  • Tests confirm the expected behavior of the method.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of GetStructName and ensure compatibility with studly caps naming.

# Test: Search for all usages of GetStructName. Expect: No dependencies on CamelCase struct names.
rg --type go -A 5 'GetStructName'

Length of output: 8357


Script:

#!/bin/bash
# Search for references to CamelCase naming conventions in the codebase to ensure no dependencies exist.
rg --type go 'CamelCase'

Length of output: 135

queue/console/job_make_command.go (1)

66-66: Verify the impact of changing "DummyName" format in stubs.

The populateStub method now uses snake_case for "DummyName". Ensure that this change aligns with the expected naming conventions in the generated stubs.

Verification successful

Verification Successful: Snake_case Change for "DummyName" is Consistent

The change to use snake_case for "DummyName" in the populateStub method is consistently applied across various commands, such as RuleMakeCommand, FilterMakeCommand, JobMakeCommand, and others. There are no dependencies or expectations for CamelCase "DummyName" that conflict with this change. The modification aligns with the expected naming conventions in the generated stubs.

  • Verified in files like validation/console/rule_make_command.go, queue/console/job_make_command.go, event/console/listener_make_command.go, etc.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of populateStub and ensure compatibility with snake_case for "DummyName".

# Test: Search for all usages of populateStub. Expect: No dependencies on CamelCase "DummyName".
rg --type go -A 5 'populateStub'

Length of output: 18564

validation/console/rule_make_command.go (1)

66-66: Verify the impact of changing "DummyName" format in stubs.

The populateStub function now uses snake_case for "DummyName". Ensure that this change aligns with the expected naming conventions in the generated stubs.

Verification successful

The change to snake_case for "DummyName" is consistent across the codebase. The populateStub function consistently replaces "DummyName" with a snake_case version of the struct name in all relevant files. There are no dependencies on "DummyName" being in CamelCase or any other specific format.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of populateStub and ensure compatibility with snake_case for "DummyName".

# Test: Search for all usages of populateStub. Expect: No dependencies on CamelCase "DummyName".
rg --type go -A 5 'populateStub'

Length of output: 18564

validation/console/filter_make_command.go (1)

66-66: Verify the impact of changing DummyName to snake case.

The conversion from camel case to snake case for DummyName may affect existing integrations or expectations in the codebase.

Verification successful

No Impact from Changing DummyName to Snake Case

The change to convert DummyName to snake case is consistent with existing patterns in the codebase, particularly in contexts where snake case is already used, such as database operations. There is no evidence of dependencies on camel case that would be affected by this change.

  • The usage of snake-cased names in database/gorm/event.go aligns with the new pattern.
  • Other files using populateStub also replace DummyName with snake-cased names without issues.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `populateStub` method to ensure the change from camel case to snake case does not break existing functionality.

# Test: Search for the `populateStub` method usage. Expect: No breaking changes due to the format change.
rg --type go -A 5 'populateStub'

Length of output: 18564


Script:

#!/bin/bash
# Description: Search for usages of snake-cased struct names to verify if camel case was previously expected.

# Test: Find occurrences where the snake-cased struct names are used.
rg --type go 'str\.Of\(\w+\)\.Snake\(\)\.String\(\)'

Length of output: 758

event/console/listener_make_command.go (1)

66-66: Verify the impact of changing DummyName to snake case.

The change from camel case to snake case for DummyName might affect existing integrations or expectations in the codebase.

Verification successful

Change to Snake Case for DummyName is Consistent with Current Practices

The transition to using snake case for DummyName aligns with the current codebase practices, as indicated by the deprecation notice and consistent use in file paths and stubs. There is no evidence of dependencies on camel case formatting. This change should not impact existing integrations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `populateStub` method to ensure the change from camel case to snake case does not break existing functionality.

# Test: Search for the `populateStub` method usage. Expect: No breaking changes due to the format change.
rg --type go -A 5 'populateStub'

Length of output: 18564


Script:

#!/bin/bash
# Search for the usage of snake-cased "DummyName" to check for dependencies on its format.
rg --type go 'str\.Of\(.*\)\.Snake\(\)\.String\(\)'

Length of output: 888

foundation/console/package_make_command_stubs.go (1)

66-66: Verify the impact of changing DummyCamelName to studly case.

The conversion from camel case to studly case for DummyCamelName may alter the expected format in generated code, potentially affecting existing code that relies on the previous format.

Also applies to: 95-95, 121-121

Verification successful

Change to Studly Case for DummyCamelName is Localized

The conversion of DummyCamelName to studly case is confined to the foundation/console/package_make_command_stubs.go file. There is no evidence of usage outside this file, indicating that the change should not impact other parts of the codebase.

  • Lines affected: 66, 95, 121 in foundation/console/package_make_command_stubs.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `DummyCamelName` in the codebase to ensure the change from camel case to studly case does not break existing functionality.

# Test: Search for occurrences of `DummyCamelName` in the codebase. Expect: No breaking changes due to the format change.
rg --type go -A 5 'DummyCamelName'

Length of output: 2658

database/gorm/cursor.go (1)

28-28: Verify the impact of changing string transformation logic.

The transformation of mapKey from camel case to studly case could affect how keys are matched against field names. Ensure that this change does not introduce unexpected behavior in scenarios where case sensitivity and format are critical.

database/gorm/event.go (2)

335-335: Verify the impact of changing struct name to database column name conversion to snake case.

The change in structNameToDbColumnName to use snake case might affect database schema interactions. Ensure that this change aligns with database schema requirements and does not introduce inconsistencies.

Verification successful

Change to Snake Case Conversion is Verified

The change to convert struct names to snake case for database column names is covered by existing tests in database/gorm/event_test.go. These tests ensure that the conversion aligns with expected database schema interactions, using snake case by default unless an explicit column name is provided. This change is verified and does not introduce inconsistencies.

  • Tests in database/gorm/event_test.go confirm the behavior of structNameToDbColumnName.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changing struct name to database column name conversion to snake case.

# Test: Search for the usage of `structNameToDbColumnName` to identify potential impacts.
rg --type go -A 5 $'structNameToDbColumnName'

Length of output: 1468


56-56: Verify the impact of changing key formatting to snake case.

The change from camel case to snake case in DestOfMap could affect how keys are utilized later in the application. Ensure that all components interacting with these keys are compatible with the new format.

Verification successful

Key Formatting Change to Snake Case is Handled Properly

The conversion of key formatting to snake case is managed by the toDBColumnName function, which is used throughout the event.go file. This function ensures that keys are consistently formatted for database operations. Additionally, tests in event_test.go indicate that this functionality is verified. Thus, the change should not adversely affect the application.

  • The toDBColumnName function maps keys to their database column names, ensuring consistency.
  • Tests confirm the expected behavior of key formatting.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changing key formatting to snake case in `DestOfMap`.

# Test: Search for the usage of `DestOfMap` to identify potential impacts.
rg --type go -A 5 $'DestOfMap'

Length of output: 1226


Script:

#!/bin/bash
# Search for any functions or methods that might be using keys from `DestOfMap` in a specific format.
rg --type go -A 5 'toDBColumnName'

Length of output: 3476

support/str/str.go (2)

967-968: Deprecation notice: Transition to new methods.

The Case2Camel function is deprecated. Users should transition to str.Of(name).Studly().String(). Ensure that all usages of this function are updated to the new method.

Verification successful

Deprecation notice verified: No usages found outside tests.

The Case2Camel function is only used in test files (support/str/str_test.go). There are no usages in the main codebase, indicating that the transition to str.Of(name).Studly().String() is likely complete. You may consider removing or updating the tests once the function is fully deprecated.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of deprecated `Case2Camel` function.

# Test: Search for the usage of `Case2Camel` to identify potential impacts.
rg --type go -A 5 $'Case2Camel'

Length of output: 1049


989-990: Deprecation notice: Transition to new methods.

The Camel2Case function is deprecated. Users should transition to str.Of(name).Snake().String(). Ensure that all usages of this function are updated to the new method.

Verification successful

Deprecation notice verified: No active usage of Camel2Case found outside tests.

The Camel2Case function is not used outside of test files, confirming that the transition to str.Of(name).Snake().String() has been implemented. The deprecation notice is effectively addressed.

  • The function is only referenced in support/str/str_test.go for testing purposes.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of deprecated `Camel2Case` function.

# Test: Search for the usage of `Camel2Case` to identify potential impacts.
rg --type go -A 5 $'Camel2Case'

Length of output: 778


Script:

#!/bin/bash
# Description: Search for any additional usages of `Camel2Case` outside of test files.

# Test: Search for the usage of `Camel2Case` in non-test files to identify potential impacts.
rg --type go -A 5 'Camel2Case' --glob '!*.test.go'

Length of output: 798

@hwbrzzl hwbrzzl closed this Aug 14, 2024
@hwbrzzl hwbrzzl reopened this Aug 14, 2024
Copy link
Member

@kkumar-gcc kkumar-gcc left a comment

Choose a reason for hiding this comment

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

Great! Are we using these method other than this repo?

@hwbrzzl
Copy link
Contributor Author

hwbrzzl commented Aug 17, 2024

Great! Are we using these method other than this repo?

Yes, maybe, so I don't remove it directly.

@hwbrzzl hwbrzzl merged commit ac56c80 into master Aug 17, 2024
18 checks passed
@hwbrzzl hwbrzzl deleted the bowen/optimize-make-command-1 branch August 17, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants