resyntax icon indicating copy to clipboard operation
resyntax copied to clipboard

Add --output-summary-stats-only option to resyntax analyze

Open Copilot opened this issue 3 months ago • 0 comments

Adds statistics mode for analyzing rule usefulness across large codebases. Addresses #28.

Changes

  • Add --output-summary-stats-only flag to resyntax analyze command
  • When no --refactoring-rule filter: prints matches grouped by rule
  • When --refactoring-rule filter given: prints matches grouped by file

Example

# Matches per rule
$ resyntax analyze --directory src --output-summary-stats-only
resyntax: --- summary statistics (matches per rule) ---

  nested-and-to-flat-and: 42 matches
  nested-or-to-flat-or: 17 matches

  Total: 59 matches across 2 rules

# Matches per file (with rule filter)
$ resyntax analyze --directory src --refactoring-rule nested-and-to-flat-and --output-summary-stats-only
resyntax: --- summary statistics (matches per file) ---

  src/foo.rkt: 25 matches
  src/bar.rkt: 17 matches

  Total: 42 matches
Original prompt

This section details on the original issue you should resolve

<issue_title>Statistics mode</issue_title> <issue_description>It's hard to tell whether a rule will actually be useful. It should be possible to run rules over a large corpus of existing code and gather statistics about how many times they'd be applied, possibly with a sample of application sites. Ideally this would be easy for people other than me to use, in order to help others come up with good rules. Possible corpus candidates include:

  • Racket itself. Already installed, so no need to download anything (assuming the source code is still around for macro expansion purposes).
  • Scribble. It's big, old, it's a single package (scribble-lib), and it hasn't seen much maintenance love over the years.
  • The entire package catalog.</issue_description>

Comments on the Issue (you are @copilot in this section)

@jackfirth Now that the `--refactoring-rule` option is implemented to filter the refactoring suite down to a specific rule, this would be even more useful. This should be implemented with a `--output-summary-stats-only` CLI option for `resyntax analyze` which should print out the total number of matches per rule, if no `--refactoring-rule` filter is given. If that filter _is_ given, then it should print out the number of matches of that rule _per file_.
  • Fixes jackfirth/resyntax#18

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Nov 28 '25 17:11 Copilot