2 The Resyntax Command-Line Interface
Resyntax provides a command-line resyntax tool for analyzing and refactoring code. The tool has two commands: resyntax analyze for analyzing code without changing it, and resyntax fix for fixing code by applying Resyntax’s suggestions.
Note that at present, Resyntax is limited in what files it can fix. Resyntax only analyzes files with the .rkt extension where #lang racket/base is the first line in file.
2.1 Running resyntax analyze
The resyntax analyze command accepts flags for specifying what modules to analyze. After analysis, suggestions are printed in the console. Any of the following flags can be specified any number of times:
--file ‹file-path› —
A file to anaylze. --directory ‹directory-path› —
A directory to anaylze, including subdirectories. --package ‹package-name› —
An installed package to analyze. --local-git-repository ‹repository-path› ‹base-ref› —
A local Git repository to analyze the changed files of. Only files which have changed relative to ‹base-ref› are analyzed. Base references must be given in the form remotename/branchname, for example origin/main or upstream/my-feature-branch. --refactoring-suite ‹module-path› ‹suite-name› —
A refactoring suite to use instead of Resyntax’s default recommendations. Custom refactoring suites can be created with define-refactoring-suite.
2.2 Running resyntax fix
The resyntax fix command accepts the same flags as resyntax analyze for specifying what modules to fix. After analysis, fixes are applied and a summary is printed.
--file ‹file-path› —
A file to fix. --directory ‹directory-path› —
A directory to fix, including subdirectories. --package ‹package-name› —
An installed package to fix. --local-git-repository ‹repository-path› ‹base-ref› —
A local Git repository to fix the changed files of. Only files which have changed relative to ‹base-ref› are fixed. Base references must be given in the form remotename/branchname, for example origin/main or upstream/my-feature-branch. --refactoring-suite ‹module-path› ‹suite-name› —
A refactoring suite to use instead of Resyntax’s default recommendations. Custom refactoring suites can be created with define-refactoring-suite.
If two suggestions try to fix the same code, one of them will be rejected. At present, the best way to handle overlapping fixes is to run Resyntax multiple times until no fixes are rejected.