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

feat: skip warning for searches #428

Merged
merged 11 commits into from
Jul 20, 2024
Merged

feat: skip warning for searches #428

merged 11 commits into from
Jul 20, 2024

Conversation

morgante
Copy link
Contributor

@morgante morgante commented Jul 19, 2024

Fixes #427

Summary by CodeRabbit

  • New Features
    • Introduced the grit-pattern-matcher dependency to enhance pattern matching capabilities.
    • Added a new public module analysis and a function has_rewrite to identify rewrite operations in patterns.
  • Bug Fixes
    • Improved logic for checking uncommitted changes before file rewriting, reducing unnecessary prompts for users.
  • Tests
    • Added new tests to ensure the correct behavior of pattern application and rewrite functionality.

Greptile Summary

This is an auto-generated summary

The pull request focuses on enhancing walking patterns by integrating new pattern matching capabilities and refining existing logic.

  • crates/cli/Cargo.toml: Added grit-pattern-matcher dependency to improve pattern matching in the CLI tool.
  • crates/cli_bin/tests/apply.rs: Introduced no_search_warning test to ensure no warnings are triggered for search operations without rewrites.
  • crates/core/src/pattern_compiler/not_compiler.rs: Modified iter method calls to include an empty slice, ensuring correct iteration logic.
  • crates/grit-pattern-matcher/src/pattern/ast_node_pattern.rs: Updated children method signature in AstNodePattern to accept PatternDefinition references, enhancing pattern matching flexibility.

@morgante morgante marked this pull request as ready for review July 20, 2024 07:09
@morgante morgante requested a review from a team as a code owner July 20, 2024 07:09
Copy link

grit-app bot commented Jul 20, 2024

On commit 39762d6, Grit tried to heal these tests:

Job Original Status Final Status
main / Rust tests (marzano) ❌ Failed ❗ Failed on attempt #3 after trying strategies ai, rerun

Tip

You can view and edit CI healing settings on the Grit App.

@morgante morgante changed the title chore: work on walking patterns feat: skip warning for searches Jul 20, 2024
Copy link
Contributor

coderabbitai bot commented Jul 20, 2024

Walkthrough

Walkthrough

The changes introduced in this diff primarily enhance the functionality of the CLI and core components by integrating the grit-pattern-matcher and refining the behavior of pattern rewrites in the application. The logic surrounding user prompts for uncommitted changes has been streamlined to reduce unnecessary warnings, especially when no rewrites are present. This ensures that user experience is improved while maintaining robust pattern matching capabilities.

Changes

Files Change Summary
crates/cli/Cargo.toml Added dependency on grit-pattern-matcher package.
crates/cli/src/commands/apply_pattern.rs Refactored run_apply_pattern to consolidate checks for uncommitted changes and rewrite necessity.
crates/cli_bin/tests/apply.rs Introduced no_search_warning test to validate behavior when no rewrites are present.
crates/core/src/analysis.rs Added new test functions to evaluate has_rewrite functionality for pattern recognition.
crates/core/src/problem.rs Changed visibility of pattern_definitions field from pub(crate) to pub.
crates/grit-pattern-matcher/src/analysis.rs Introduced has_rewrite function to detect pattern rewrites.
crates/grit-pattern-matcher/src/lib.rs Created new analysis module and re-exported has_rewrite function.
crates/grit-pattern-matcher/src/pattern/... Updated various methods to accept and utilize definitions parameter for enhanced pattern handling.

Assessment against linked issues

Objective Addressed Explanation
Remove rewrite warning for all search queries (#427)

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 39762d6 and 30c04e0.

Files selected for processing (2)
  • crates/core/src/analysis.rs (2 hunks)
  • crates/grit-pattern-matcher/src/analysis.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crates/grit-pattern-matcher/src/analysis.rs
Additional context used
Learnings (1)
Common learnings
Learnt from: morgante
URL: https://github.com/getgrit/gritql/pull/231

Timestamp: 2024-04-15T05:47:47.743Z
Learning: User morgante prefers not to be asked for documentation.
Additional comments not posted (9)
crates/core/src/analysis.rs (9)

260-281: LGTM!

The test_is_rewrite function correctly validates the rewrite functionality for the pattern console.log to console.error.


284-307: LGTM!

The test_is_not_rewrite function correctly validates that the pattern excluding certain messages does not trigger a rewrite.


310-334: LGTM!

The test_is_rewrite_with_pattern_call function correctly validates the rewrite functionality when a pattern definition is invoked.


337-365: LGTM!

The test_is_rewrite_with_yaml function correctly validates the rewrite functionality in YAML language contexts.


368-395: LGTM!

The test_is_rewrite_with_insert function correctly validates the rewrite functionality with insert operations in YAML language contexts.


Line range hint 194-203:
LGTM!

The test_non_async function correctly validates that the pattern without async calls is identified as non-async.


Line range hint 205-214:
LGTM!

The test_async_direct_call function correctly validates that the pattern with a direct async call is identified as async.


Line range hint 216-227:
LGTM!

The test_inline_indirect_call function correctly validates that the pattern with an inline indirect async call is identified as async.


Line range hint 229-243:
LGTM!

The test_async_module_indirect function correctly validates that the pattern with an indirect async call through a module is identified as async.


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.

@morgante morgante merged commit 5923f64 into main Jul 20, 2024
10 checks passed
@morgante morgante deleted the smart-walk branch July 20, 2024 07:43
@github-actions github-actions bot mentioned this pull request Jul 20, 2024
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

println!("stderr: {:?}", stderr);

// Expect it to fail
assert!(output.status.success(), "Command should have passed");
Copy link

Choose a reason for hiding this comment

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

Spelling: The assertion message should indicate that the command should have passed, not failed.

@github-actions github-actions bot mentioned this pull request Sep 11, 2024
@github-actions github-actions bot mentioned this pull request Oct 10, 2024
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.

Remove rewrite warning for all search queries
1 participant