Skip to content

Conversation

@jackfirth
Copy link
Owner

Didn't like the look of this rule's changes in herbie-fp/herbie#1401.

@Copilot Copilot AI review requested due to automatic review settings October 5, 2025 13:37
@jackfirth jackfirth added the existing lint Issues or pull requests relating to existing lints label Oct 5, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines the match-conditional-to-when refactoring rule by adding constraints to prevent it from triggering on conditionals with short body expressions. The rule now only suggests converting if and cond expressions to #:when clauses when the body expressions are sufficiently long or complex.

  • Added logic to check body expression length and span before applying the refactoring
  • Updated existing tests to use longer expressions that still trigger the rule
  • Added new negative test cases to verify short conditionals are not refactored

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
default-recommendations/match-shortcuts.rkt Added conditional checks to prevent refactoring when body expressions are short
default-recommendations/match-shortcuts-test.rkt Updated existing tests with longer expressions and added negative test cases

@jackfirth jackfirth merged commit 194312c into master Oct 5, 2025
2 checks passed
@jackfirth jackfirth deleted the better-match-shortcut branch October 5, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

existing lint Issues or pull requests relating to existing lints

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant