resyntax
resyntax copied to clipboard
Lint for `with-output-to-string`
#lang resyntax/test
test: "with-output-to-string should be used when equivalent"
--------------------
#lang racket
(define (f)
(define os (open-output-string))
(parameterize ([current-output-port os])
(displayln "foo")
(get-output-string os)))
--------------------
--------------------
#lang racket
(define (f)
(with-output-to-string (λ () (displayln "foo"))))
--------------------
This should also work for slight variations of the above that are still equivalent, like if (get-output-string os) is outside the parameterize expression.
Unfortunately, this refactoring can only work in #lang racket because in #lang racket/base it requires importing racket/string.
Nit: with-output-to-string is from racket/port not racket/string