Skip to content

feat: [#463] The validation module supports custom filter#589

Merged
krishankumar01 merged 5 commits intomasterfrom
kkumar-gcc/#463
Aug 9, 2024
Merged

feat: [#463] The validation module supports custom filter#589
krishankumar01 merged 5 commits intomasterfrom
kkumar-gcc/#463

Conversation

@krishankumar01
Copy link
Member

@krishankumar01 krishankumar01 commented Aug 8, 2024

📑 Description

Closes goravel/goravel#463

Summary by CodeRabbit

  • New Features

    • Introduced a new command to create filter classes, enhancing developer productivity.
    • Added flexible filter creation options, including a --force flag for overwriting existing filters.
    • Expanded command set with the registration of the new filter command.
  • Bug Fixes

    • Updated dependencies, improving performance and possibly resolving issues from prior versions.
  • Tests

    • Added comprehensive tests for the new filter command, ensuring correct behavior in various scenarios.
  • Documentation

    • Enhanced documentation for the Stubs type to clarify new functionalities related to rules and filters.

✅ Checks

  • Added test cases for my code

@krishankumar01 krishankumar01 requested a review from a team as a code owner August 8, 2024 16:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

The recent changes enhance the validation module by introducing a command for creating custom filters, improving developer productivity. A new FilterMakeCommand is added, allowing users to generate filter classes via a console command. Additionally, updates to the Stubs type streamline the management of rules and filters, while existing functionality in the RuleMakeCommand has been refined for better alignment with the new features.

Changes

Files Change Summary
go.mod Updated dependency version for github.com/klauspost/cpuid/v2 from v2.2.5 to v2.2.7.
validation/console/filter_make_command.go Introduced FilterMakeCommand, enabling the creation of filter classes with methods for command signature, execution, and handling file paths.
validation/console/filter_make_command_test.go Added tests for FilterMakeCommand, covering conditions like empty names, valid creation, duplicate handling, and custom path generation.
validation/console/rule_make_command.go Modified getStub method in RuleMakeCommand to return a rule stub instead of a request stub.
validation/console/stubs.go Renamed Request() to Rule() in Stubs and added a new Filter() method for generating filter definitions.
validation/service_provider.go Registered the new FilterMakeCommand in the ServiceProvider to enhance command availability in the application.

Assessment against linked issues

Objective Addressed Explanation
Support custom filter creation (#463)
Provide a console command for filters
Ensure proper error handling in commands

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.

@codecov
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 69.64286% with 17 lines in your changes missing coverage. Please review.

Project coverage is 70.05%. Comparing base (56327a8) to head (7142511).

Files Patch % Lines
validation/console/filter_make_command.go 64.44% 15 Missing and 1 partial ⚠️
validation/service_provider.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #589      +/-   ##
==========================================
- Coverage   70.06%   70.05%   -0.01%     
==========================================
  Files         181      182       +1     
  Lines       11234    11288      +54     
==========================================
+ Hits         7871     7908      +37     
- Misses       2789     2805      +16     
- Partials      574      575       +1     

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

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Great 👍

}

func (r Stubs) Request() string {
func (r Stubs) Rule() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch

return "DummyName"
}

// Handle The filter function to apply.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it better to add the detailed description here?

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, we should include

Copy link
Contributor

Choose a reason for hiding this comment

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

There seem many repeat codes in the make commands, we need to reconstruct it in a suitable time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I do it in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can be another.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok

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 1b8498e and e1896c4.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • go.mod (1 hunks)
  • validation/console/filter_make_command.go (1 hunks)
  • validation/console/filter_make_command_test.go (1 hunks)
  • validation/console/rule_make_command.go (1 hunks)
  • validation/console/stubs.go (2 hunks)
  • validation/service_provider.go (1 hunks)
Additional comments not posted (7)
validation/service_provider.go (1)

27-27: LGTM! The new command registration is appropriate.

The addition of FilterMakeCommand enhances the functionality by allowing the creation of custom filters.

validation/console/filter_make_command_test.go (1)

16-43: Comprehensive test coverage for FilterMakeCommand.

The tests effectively cover different scenarios, ensuring robust functionality.

validation/console/stubs.go (2)

Line range hint 6-31:
Renaming Request to Rule is appropriate.

The change reflects a more specific focus on rule-based operations.


33-78: The Filter method is well-documented and enhances functionality.

The detailed comments provide clear guidance on implementing custom filters.

validation/console/rule_make_command.go (1)

61-61: Verify the impact of the stub change.

The getStub method now returns Stubs{}.Rule() instead of Stubs{}.Request(). Ensure that this change aligns with the intended functionality and verify its impact on the system.

validation/console/filter_make_command.go (1)

1-101: New command for filter creation looks good.

The FilterMakeCommand introduces a new command for creating filter classes, consistent with the existing command patterns. Ensure that it integrates well with the overall system and verify its functionality.

Verification successful

FilterMakeCommand is well integrated and tested.

The FilterMakeCommand is registered in validation/service_provider.go and has corresponding tests in validation/console/filter_make_command_test.go, indicating proper integration and functionality verification.

  • validation/service_provider.go: Registers FilterMakeCommand.
  • validation/console/filter_make_command_test.go: Contains tests for FilterMakeCommand.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration and functionality of the `FilterMakeCommand`.

# Test: Search for the `FilterMakeCommand` usage and ensure it is correctly integrated.
rg --type go -A 5 $'FilterMakeCommand'

Length of output: 4671

go.mod (1)

110-110: Verify compatibility of the updated dependency.

The github.com/klauspost/cpuid/v2 package has been updated from v2.2.5 to v2.2.7. Ensure compatibility and check for any breaking changes or new features.

Verification successful

Compatibility Verified for github.com/klauspost/cpuid/v2 Update

The update from v2.2.5 to v2.2.7 includes enhancements such as new feature detections for AMD and Intel processors, workflow updates, and documentation changes. No breaking changes were identified. Please review the new features to ensure they align with your codebase requirements.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the compatibility of the updated `cpuid` dependency.

# Test: Check the changelog or release notes for `v2.2.7` to identify any breaking changes or new features.
# Note: This is a placeholder for manual verification, as changelogs are not accessible via shell scripts.
echo "Please manually verify the changelog for github.com/klauspost/cpuid/v2 v2.2.7"

Length of output: 164


Script:

#!/bin/bash
# Fetch the commit history for the cpuid repository between v2.2.5 and v2.2.7
# to identify any changes that might affect compatibility.

# Clone the repository to a temporary directory
git clone --quiet https://github.com/klauspost/cpuid.git cpuid_repo

# Navigate into the repository
cd cpuid_repo

# Fetch the commit log between the specified tags
git log v2.2.5..v2.2.7 --oneline

# Clean up by removing the cloned repository
cd ..
rm -rf cpuid_repo

Length of output: 535

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

👍

@krishankumar01 krishankumar01 merged commit e303e5b into master Aug 9, 2024
@krishankumar01 krishankumar01 deleted the kkumar-gcc/#463 branch August 9, 2024 04:04
ahmed3mar added a commit to ahmed3mar/framework that referenced this pull request Feb 7, 2025
hwbrzzl added a commit that referenced this pull request Feb 28, 2025
* fix: [#589] Context in PrepareForValidation always nil

* update mod
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.

✨ [Feature] The validation module supports custom filter

2 participants