Am I on the right track for a Racket analyzer?
I’m looking at using GitHub - jackfirth/resyntax: A Racket refactoring engine, a Racket refactoring recommendations package that has been used on several Racket community repos to date.
resyntax analyze --file-path <file-path>
prints out each rule, a rule description, the code in question, and then the recommended code edits. In the snippet below, the rules are let-to-define
and nested-if-to-cond
resyntax analyze --file example.rkt
resyntax: --- analyzing code ---
resyntax: analyzing /Users/anagy/Documents/example.rkt
resyntax: --- displaying results ---
resyntax: /Users/anagy/Documents/example.rkt [let-to-define]
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
3 (define (swap x y)
4 (let ([t (unbox x)])
5 (set-box! x (unbox y))
6 (set-box! y t)))
3 (define (swap x y)
4 (define t (unbox x))
5 (set-box! x (unbox y))
6 (set-box! y t))
resyntax: /Users/anagy/Documents/example.rkt [nested-if-to-cond]
This `if`-`else` chain can be converted to a `cond` expression.
8 (if 'cond 'then (if 'cond2 'then2 'else))
8 (cond
9 ['cond 'then]
10 ['cond2 'then2]
11 [else 'else])
I’d pull out the rule name, description, and affected code, leaving behind the recommended edit. Each set can be passed as parameters to a generic Markdown file rather than mapping each rule to its own Markdown file in website/copy
.
I can leave out the recommended code edits but use the rest to provide analyzer feedback. To avoid generating a Markdown file for each rule, I’d just pass everything as parameters to a single generic Markdown file.