Skip to content

Unwanted suggestion from string-append-with-format-to-format #607

@jackfirth

Description

@jackfirth

Problem summary

In racket/drracket#771, Resyntax suggested replacing (string-append ... (format ...)) with (format ...), but this produced very unpleasant code because the other arguments to string-append were also (format ...) expressions. The string-append-with-format-to-format rule shouldn't fire on expressions that append multiple format subexpressions together.

Test case for code that shouldn't be refactored

#lang resyntax/test

test: "this code should not be refactored"
--------------------
#lang racket
(string-append (format "foo: ~a" 42) (format ("bar: ~a" 42))
--------------------

Unwanted suggestion

#lang racket
(format "~a\n~a~a~a\n\nCollections:\n~a\n~a"
        (send environment get-value)
        (format "Human Language: ~a\n" (send human-language get-value))
        (format "(current-memory-use) ~a\n" (send memory-use get-value))
        (format "raco pkg (show):\n~a\n" (send (send pkg-info get-editor) get-text))
        (send (send collections get-editor) get-text)
        (apply string-append
               (for/list ([extra (in-list extras)])
                 (format "~a: ~a\n" (car extra) (send (cdr extra) get-value)))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexisting lintIssues or pull requests relating to existing lints

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions