generated from jackfirth/racket-package-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
autopilot-candidateThe Copilot Agent should attempt this during a scheduled Autopilot runThe Copilot Agent should attempt this during a scheduled Autopilot runexisting lintIssues or pull requests relating to existing lintsIssues or pull requests relating to existing lints
Description
Resyntax currently refactors this:
(when a
(when b
body ...))into this:
(when (and a b)
body ...)This trades off a slightly more complex conditional expression for reduced nesting and indentation. However, if a and b fit together in one line but aren't trivial, the compound expression can be harder to read, making this tradeoff not obviously better.
This rule should be dialed back a bit. I think it should only apply if there are three or more nested when (or unless) expressions, or if there's only two but one of them already uses and in its condition expression, or if the two condition expressions are plain identifiers. Here's some test cases:
#lang resyntax/test
header: - #lang racket/base
no-change-test: "two when forms"
---
(define (f a b c)
(when (a)
(when (b)
c)))
---
test: "three when forms"
---
(define (f a b c d)
(when (a)
(when (b)
(when (c)
d))))
===
(define (f a b c d)
(when (and (a) (b) (c))
d))
---
test: "two when forms with and"
---
(define (f a b c d)
(when (and (a) (b))
(when (c)
d)))
===
(define (f a b c d)
(when (and (a) (b) (c))
d))
---
test: "two when forms with identifiers"
---
(define (f a b c)
(when a
(when b
c)))
===
(define (f a b c)
(when (and a b)
c))
---Copilot
Metadata
Metadata
Assignees
Labels
autopilot-candidateThe Copilot Agent should attempt this during a scheduled Autopilot runThe Copilot Agent should attempt this during a scheduled Autopilot runexisting lintIssues or pull requests relating to existing lintsIssues or pull requests relating to existing lints