Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated Resyntax fixes #1443

Merged
merged 17 commits into from
Mar 21, 2025
Merged

Automated Resyntax fixes #1443

merged 17 commits into from
Mar 21, 2025

Conversation

resyntax-ci[bot]
Copy link
Contributor

@resyntax-ci resyntax-ci bot commented Mar 21, 2025

Resyntax fixed 50 issues in 18 files.

  • Fixed 13 occurrences of single-clause-match-to-match-define
  • Fixed 8 occurrences of let-to-define
  • Fixed 6 occurrences of define-syntax-syntax-rules-to-define-syntax-rule
  • Fixed 4 occurrences of if-else-false-to-and
  • Fixed 3 occurrences of quasiquote-to-list
  • Fixed 3 occurrences of sort-with-keyed-comparator-to-sort-by-key
  • Fixed 2 occurrences of zero-comparison-to-positive?
  • Fixed 2 occurrences of define-values-values-to-define
  • Fixed 1 occurrence of define-simple-macro-to-define-syntax-parse-rule
  • Fixed 1 occurrence of if-let-to-cond
  • Fixed 1 occurrence of provide-deduplication
  • Fixed 1 occurrence of when-expression-in-for-loop-to-when-keyword
  • Fixed 1 occurrence of for/fold-result-keyword
  • Fixed 1 occurrence of inverted-when
  • Fixed 1 occurrence of map-to-for
  • Fixed 1 occurrence of apply-flattening
  • Fixed 1 occurrence of define-lambda-to-define

resyntax-ci bot added 17 commits March 21, 2025 00:32
This `match` expression can be simplified using `match-define`.
The `define` form supports a shorthand for defining functions.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro.
This `if` expression can be refactored to an equivalent expression using `and`.
This negated `when` expression can be replaced by an `unless` expression.
This expression is equivalent to calling the `positive?` predicate.
The `define-simple-macro` form has been renamed to `define-syntax-parse-rule`.
Providing the same identifier multiple times is unnecessary.
`cond` with internal definitions is preferred over `if` with `let`, to reduce nesting
The `apply` function accepts single arguments in addition to a trailing list argument.
This use of `define-values` is unnecessary.
This `sort` expression can be replaced with a simpler, equivalent expression.
This `map` operation can be replaced with a `for/list` loop.
This quasiquotation is equialent to a simple `list` call.
Only one of the `for/fold` expression's result values is used. Use the `#:result` keyword to return just that result.
Use the `#:when` keyword instead of `when` to reduce loop body indentation.
@samth samth merged commit e72b939 into master Mar 21, 2025
5 checks passed
@samth samth deleted the autofix-29-1 branch March 21, 2025 16:29
Comment on lines 65 to +69
(tc-error (~a "structure type constructor applied to non-regular arguments"
"\n type: " rator
"\n arguments...: " rands)))
"\n type: "
rator
"\n arguments...: "
rands)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sorawee A nice fmt improvement would be to keep description-value pairs adjacent in ~a and similar formatting expressions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly are considered "description-value pairs"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some examples:

  • The field v ... ... argument of raise-arguments-error.
  • Alternating pairs of strings and expressions in the arguments to ~a, ~v, ~s, etc.

That is, cases that construct the <field>: <detail> parts of an error message as described in Error Message Conventions. Not sure how easy it is to detect all of these though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's a good idea for the raise-arguments-error family and the hash family. I don't yet buy that the heuristic described for ~a will work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants