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

Merged
merged 9 commits into from
Nov 24, 2024
Merged

Automated Resyntax fixes #698

merged 9 commits into from
Nov 24, 2024

Conversation

resyntax-ci[bot]
Copy link
Contributor

@resyntax-ci resyntax-ci bot commented Nov 24, 2024

Resyntax fixed 20 issues in 1 file.

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

Keep imports in `require` sorted and grouped by phase, with collections before files.
Use the `#:when` keyword instead of `when` to reduce loop body indentation.
…t-lambda`

The lambda can be removed from the failure result in this `hash-ref` expression.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
This expression can be replaced with a simpler, equivalent `hash-update!` expression.
This `if` expression can be refactored to an equivalent expression using `and`.
`cond` with internal definitions is preferred over `if` with `let`, to reduce nesting
These nested `for` loops can be replaced by a single `for*` loop.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
(parameterize ([current-eventspace progress-eventspace])
(queue-callback (λ () (send progress-frame show #f))))
(when success?
(let ()
Copy link
Member

Choose a reason for hiding this comment

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

This let was in the original, but shouldn't it have gone away?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup. I just checked using #lang resyntax/test that Resyntax can refactor this code, so I think the only reason it didn't happen was the fix limit.

frame)]
[alignment '(left center)]))
(define root-message
(instantiate message% ()
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it just didn't kick in, but this could be new.

Copy link
Member

Choose a reason for hiding this comment

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

(and a few others nearby)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a rule for that, actually. Filed jackfirth/resyntax#418.

;; note: the preference drracket:module-browser:name-length is also used for
;; the View|Show Module Browser version of the module browser
;; here we just treat any pref value except '3' as if it were for the long names.
(let ([selection (send module-browser-name-length-choice get-selection)])
Copy link
Member

Choose a reason for hiding this comment

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

probably another one that didn't kick in, but it feels like it would be nice to limit the changes by region instead of by number of changes maybe?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm considering redoing how the limiting works. It's hard to tell when something isn't being refactored because it hit the limit or because the refactoring rule didn't catch it.

@@ -582,7 +574,7 @@
[parent menu]
[label (choice->label-string choice)]
[callback (λ (item evt)
(hash-set! selected choice (not (hash-ref selected choice)))
(hash-update! selected choice (λ (v) (not v)))
Copy link
Member

Choose a reason for hiding this comment

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

maybe just not?

Copy link
Member

Choose a reason for hiding this comment

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

(I don't really like hash-update and hash-update!, for the same reason that I really like for loops over map and friends. Not a big deal.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rfindler
Copy link
Member

LGTM, overall.

frame)]
[alignment '(left center)]))
(define root-message
(instantiate message% ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a rule for that, actually. Filed jackfirth/resyntax#418.

@@ -582,7 +574,7 @@
[parent menu]
[label (choice->label-string choice)]
[callback (λ (item evt)
(hash-set! selected choice (not (hash-ref selected choice)))
(hash-update! selected choice (λ (v) (not v)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines +1050 to +1052
(cond
[(null? levels) (void)]
[else
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is equivalent to (unless (null? levels) ...). Filed jackfirth/resyntax#420.

;; note: the preference drracket:module-browser:name-length is also used for
;; the View|Show Module Browser version of the module browser
;; here we just treat any pref value except '3' as if it were for the long names.
(let ([selection (send module-browser-name-length-choice get-selection)])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm considering redoing how the limiting works. It's hard to tell when something isn't being refactored because it hit the limit or because the refactoring rule didn't catch it.

(parameterize ([current-eventspace progress-eventspace])
(queue-callback (λ () (send progress-frame show #f))))
(when success?
(let ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup. I just checked using #lang resyntax/test that Resyntax can refactor this code, so I think the only reason it didn't happen was the fix limit.

@jackfirth jackfirth merged commit dfcea1f into master Nov 24, 2024
3 checks passed
@shhyou shhyou deleted the autofix-69-1 branch January 12, 2025 23:14
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.

2 participants