diff --git a/default-recommendations/list-shortcuts-test.rkt b/default-recommendations/list-shortcuts-test.rkt index 8ebe744..571dfc2 100644 --- a/default-recommendations/list-shortcuts-test.rkt +++ b/default-recommendations/list-shortcuts-test.rkt @@ -139,6 +139,24 @@ test: "unnecessary quasiquotation with constants refactorable to list" ------------------------------ +test: "unnecessary splicing quasiquotation refactorable to append" +------------------------------ +(define (f xs ys zs) + `(,@xs ,@ys ,@zs)) +------------------------------ +------------------------------ +(define (f xs ys zs) + (append xs ys zs)) +------------------------------ + + +test: "splicing quasiquotation with other subterms not refactorable to append" +------------------------------ +(define (f xs ys zs) + `(a ,@xs b ,@ys c ,@zs d)) +------------------------------ + + test: "ignored map expression refactorable to for-each" ------------------------------ (define (f func xs ys zs) diff --git a/default-recommendations/list-shortcuts.rkt b/default-recommendations/list-shortcuts.rkt index 6f502c9..311239e 100644 --- a/default-recommendations/list-shortcuts.rkt +++ b/default-recommendations/list-shortcuts.rkt @@ -113,11 +113,18 @@ (define-refactoring-rule quasiquote-to-list #:description "This quasiquotation is equialent to a simple `list` call." - #:literals (quasiquote unquote) + #:literals (quasiquote) (quasiquote (arg:unquoted ...)) (list arg.expr ...)) +(define-refactoring-rule quasiquote-to-append + #:description "This quasiquotation is equialent to calling `append`." + #:literals (quasiquote unquote-splicing) + (quasiquote ((unquote-splicing arg) ...)) + (append arg ...)) + + (define-definition-context-refactoring-rule ignored-map-to-for-each #:description "The result of this `map` expression is unused. Consider using `for-each` instead." #:literals (map) @@ -134,5 +141,6 @@ filter-to-remv* first-reverse-to-last ignored-map-to-for-each + quasiquote-to-append quasiquote-to-list sort-with-keyed-comparator-to-sort-by-key))