Skip to content

Commit d5162c6

Browse files
authored
Remove the apply-append-for-loop-to-for-loop lint (#441)
See jackfirst/resyntax#435; this lint tends to produce worse output than the input it started with.
1 parent 1dcb767 commit d5162c6

File tree

2 files changed

+0
-84
lines changed

2 files changed

+0
-84
lines changed

default-recommendations/for-loop-shortcuts-test.rkt

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -643,25 +643,6 @@ test: "for-each and append-map can be replaced by for* with #:when"
643643
------------------------------------------------------------
644644

645645

646-
test: "(apply append ...) with a for loop can be removed"
647-
------------------------------------------------------------
648-
(define formulas
649-
(hash 'water (list 'hydrogen 'oxygen)
650-
'benzene (list 'hydrogen 'carbon)))
651-
(apply append
652-
(for/list ([k (in-hash-keys formulas)])
653-
(hash-ref formulas k)))
654-
------------------------------------------------------------
655-
------------------------------------------------------------
656-
(define formulas
657-
(hash 'water (list 'hydrogen 'oxygen)
658-
'benzene (list 'hydrogen 'carbon)))
659-
(for*/list ([k (in-hash-keys formulas)]
660-
[v (in-list (hash-ref formulas k))])
661-
v)
662-
------------------------------------------------------------
663-
664-
665646
test: "(apply append ...) with a multi-clause for loop can't be removed"
666647
------------------------------------------------------------
667648
(define formulas
@@ -686,46 +667,6 @@ test: "(apply append ...) with a multi-body for loop can't be removed"
686667
------------------------------------------------------------
687668

688669

689-
test: "(apply append ...) with a for* loop can be removed"
690-
------------------------------------------------------------
691-
(define formulas
692-
(hash 'water (list 'hydrogen 'oxygen)
693-
'benzene (list 'hydrogen 'carbon)))
694-
(apply append
695-
(for*/list ([k (in-hash-keys formulas)])
696-
(hash-ref formulas k)))
697-
------------------------------------------------------------
698-
------------------------------------------------------------
699-
(define formulas
700-
(hash 'water (list 'hydrogen 'oxygen)
701-
'benzene (list 'hydrogen 'carbon)))
702-
(for*/list ([k (in-hash-keys formulas)]
703-
[v (in-list (hash-ref formulas k))])
704-
v)
705-
------------------------------------------------------------
706-
707-
708-
test: "(apply append ...) with a multi-clause for* loop can be removed"
709-
------------------------------------------------------------
710-
(define formulas
711-
(hash 'water (list 'hydrogen 'oxygen)
712-
'benzene (list 'hydrogen 'carbon)))
713-
(apply append
714-
(for*/list ([k (in-hash-keys formulas)]
715-
[i (in-range 0 5)])
716-
(hash-ref formulas k)))
717-
------------------------------------------------------------
718-
------------------------------------------------------------
719-
(define formulas
720-
(hash 'water (list 'hydrogen 'oxygen)
721-
'benzene (list 'hydrogen 'carbon)))
722-
(for*/list ([k (in-hash-keys formulas)]
723-
[i (in-range 0 5)]
724-
[v (in-list (hash-ref formulas k))])
725-
v)
726-
------------------------------------------------------------
727-
728-
729670
test: "(apply append ...) with a multi-body for* loop can't be removed"
730671
------------------------------------------------------------
731672
(define formulas

default-recommendations/for-loop-shortcuts.rkt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -424,30 +424,6 @@ return just that result."
424424
(~@ . (~splicing-replacement (last-condition.refactored ...) #:original original-body))))
425425

426426

427-
(define-syntax-class apply-append-refactorable-for-loop
428-
#:attributes (refactored-loop)
429-
#:literals (for/list for*/list)
430-
431-
(pattern (for/list (only-clause) only-body:expr)
432-
#:when (oneline-syntax? #'only-body)
433-
#:with refactored-loop
434-
#'(for*/list (only-clause [v (in-list only-body)])
435-
v))
436-
437-
(pattern ((~and loop-id for*/list) (clause ...) only-body:expr)
438-
#:when (oneline-syntax? #'only-body)
439-
#:with refactored-loop
440-
#'(loop-id (clause ... [v (in-list only-body)]) v)))
441-
442-
443-
(define-refactoring-rule apply-append-for-loop-to-for-loop
444-
#:description "Instead of using `(apply append ...)` to flatten a list of lists, consider using\
445-
`for*/list` to flatten the list."
446-
#:literals (apply append)
447-
(apply append loop:apply-append-refactorable-for-loop)
448-
loop.refactored-loop)
449-
450-
451427
(define-refactoring-rule when-expression-in-for-loop-to-when-keyword
452428
#:description "Use the `#:when` keyword instead of `when` to reduce loop body indentation."
453429
#:literals (when for for*)
@@ -465,7 +441,6 @@ return just that result."
465441
(define-refactoring-suite for-loop-shortcuts
466442
#:rules (andmap-to-for/and
467443
append-map-for/list-to-for*/list
468-
apply-append-for-loop-to-for-loop
469444
apply-plus-to-for/sum
470445
for/fold-building-hash-to-for/hash
471446
for/fold-result-keyword

0 commit comments

Comments
 (0)