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 #688

Closed
wants to merge 1 commit into from
Closed

Automated Resyntax fixes #688

wants to merge 1 commit into from

Conversation

resyntax-ci[bot]
Copy link
Contributor

@resyntax-ci resyntax-ci bot commented Oct 20, 2024

This is an automated change generated by Resyntax.

Pass 1

Applied 17 fixes to drracket-tool-text-lib/drracket/private/syncheck/traversals.rkt

  • Line 3, tidy-require: Keep imports in require sorted and grouped by phase, with collections before files.
  • Line 51, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 684, hash-set!-ref-to-hash-update!: This expression can be replaced with a simpler, equivalent hash-update! expression.
  • Line 713, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 728, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 771, nested-for-to-for*: These nested for loops can be replaced by a single for* loop.
  • Line 785, nested-for-to-for*: These nested for loops can be replaced by a single for* loop.
  • Line 835, nested-for-to-for*: These nested for loops can be replaced by a single for* loop.
  • Line 906, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 972, if-else-false-to-and: This if expression can be refactored to an equivalent expression using and.
  • Line 1074, if-else-false-to-and: This if expression can be refactored to an equivalent expression using and.
  • Line 1098, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 1129, when-expression-in-for-loop-to-when-keyword: Use the #:when keyword instead of when to reduce loop body indentation.
  • Line 1275, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 1366, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 1424, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.
  • Line 1451, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.

Applied 2 fixes to drracket/setup/plt-installer-unit.rkt

  • Line 2, tidy-require: Keep imports in require sorted and grouped by phase, with collections before files.
  • Line 44, let-to-define: Internal definitions are recommended instead of let expressions, to reduce nesting.

Applied 1 fix to drracket/repo-time-stamp/time-stamp.rkt

  • Line 2, tidy-require: Keep imports in require sorted and grouped by phase, with collections before files.

Summary

Fixed 20 issues in 3 files.

  • Fixed 10 occurrences of let-to-define
  • Fixed 3 occurrences of tidy-require
  • Fixed 3 occurrences of nested-for-to-for*
  • Fixed 2 occurrences of if-else-false-to-and
  • Fixed 1 occurrence of hash-set!-ref-to-hash-update!
  • Fixed 1 occurrence of when-expression-in-for-loop-to-when-keyword

This is an automated change generated by Resyntax.

#### Pass 1

Applied 17 fixes to [`drracket-tool-text-lib/drracket/private/syncheck/traversals.rkt`](../blob/HEAD/drracket-tool-text-lib/drracket/private/syncheck/traversals.rkt)

  * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 51, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 684, `hash-set!-ref-to-hash-update!`: This expression can be replaced with a simpler, equivalent `hash-update!` expression.
  * Line 713, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 728, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 771, `nested-for-to-for*`: These nested `for` loops can be replaced by a single `for*` loop.
  * Line 785, `nested-for-to-for*`: These nested `for` loops can be replaced by a single `for*` loop.
  * Line 835, `nested-for-to-for*`: These nested `for` loops can be replaced by a single `for*` loop.
  * Line 906, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 972, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`.
  * Line 1074, `if-else-false-to-and`: This `if` expression can be refactored to an equivalent expression using `and`.
  * Line 1098, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 1129, `when-expression-in-for-loop-to-when-keyword`: Use the `#:when` keyword instead of `when` to reduce loop body indentation.
  * Line 1275, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 1366, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 1424, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 1451, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 2 fixes to [`drracket/setup/plt-installer-unit.rkt`](../blob/HEAD/drracket/setup/plt-installer-unit.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 44, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 1 fix to [`drracket/repo-time-stamp/time-stamp.rkt`](../blob/HEAD/drracket/repo-time-stamp/time-stamp.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

## Summary

Fixed 20 issues in 3 files.

  * Fixed 10 occurrences of `let-to-define`
  * Fixed 3 occurrences of `tidy-require`
  * Fixed 3 occurrences of `nested-for-to-for*`
  * Fixed 2 occurrences of `if-else-false-to-and`
  * Fixed 1 occurrence of `hash-set!-ref-to-hash-update!`
  * Fixed 1 occurrence of `when-expression-in-for-loop-to-when-keyword`
(define is-module?
(syntax-case sexp (module)
[(module . rest
)
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking a close paren on its own line isn't intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely not intentional. Looks like a fmt bug, cc @sorawee.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so the issue is that fmt thinks that this is a normal module formatting, so . is the module name and rest is the module path. The body is missing, so it places the close paren there.

This issue would affect virtually all forms as well. It's not specific to module.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a heuristic that could work well, without requiring formatting rule writers to add more formatting handlers, is to see if a special form has . or not. If there is one, then just treat the form as a function application.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Opened sorawee/fmt#82 to track this problem.

[_ #f]))
(cond
[is-module?
(let ([phase-to-binders (make-hash)]
Copy link
Member

Choose a reason for hiding this comment

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

How come this let didn't go away?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Resyntax hit the 20 fix limit for the pull request and decided not to do any more work, I believe.

(define defs-text (current-annotations))
(when (and source defs-text (syntax-position stx) (syntax-span stx))
(let* ([pos-left (- (syntax-position stx) 1)]
[pos-right (+ pos-left (syntax-span stx))])
Copy link
Member

Choose a reason for hiding this comment

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

This could have been defines, I think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. I think it's just the fix limit that prevented them from being refactored in this PR.

@jackfirth
Copy link
Collaborator

Closing this one because of sorawee/fmt#82. We'll get these files next time chief.

@jackfirth jackfirth closed this Oct 31, 2024
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