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

Merged
merged 10 commits into from
Dec 4, 2024
Merged

Automated Resyntax fixes #699

merged 10 commits into from
Dec 4, 2024

Conversation

resyntax-ci[bot]
Copy link
Contributor

@resyntax-ci resyntax-ci bot commented Dec 1, 2024

Resyntax fixed 20 issues in 4 files.

  • Fixed 5 occurrences of let-to-define
  • Fixed 5 occurrences of instantiate-to-new
  • Fixed 3 occurrences of cond-let-to-cond-define
  • Fixed 2 occurrences of tidy-require
  • Fixed 1 occurrence of let-values-then-call-to-call-with-values
  • Fixed 1 occurrence of nested-for-to-for*
  • Fixed 1 occurrence of unused-definition
  • Fixed 1 occurrence of sort-with-keyed-comparator-to-sort-by-key
  • Fixed 1 occurrence of if-else-false-to-and

resyntax-ci bot added 10 commits December 1, 2024 00:11
Keep imports in `require` sorted and grouped by phase, with collections before files.
This `if` expression can be refactored to an equivalent expression using `and`.
This definition is not used.
The `instantiate` form is for mixing positional and by-name constructor arguments. When no positional arguments are needed, use `new` instead.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
These nested `for` loops can be replaced by a single `for*` loop.
This `sort` expression can be replaced with a simpler, equivalent expression.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
The `instantiate` form is for mixing positional and by-name constructor arguments. When no positional arguments are needed, use `new` instead.
This `let-values` expression can be replaced with a simpler, equivalent `call-with-values` expression.

(set! update-label
(λ (s)
(if (and s (not (null? s)))
Copy link
Member

Choose a reason for hiding this comment

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

this should have become a cond?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The let* expression in the true branch can't be refactored into definitions because of the shadowing it's doing in the binding for lines, so Resyntax won't refactor this if into a cond. It only does that for ifs with lets when the let is refactorable.

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 not seeing a shadowing binding for lines. When I put lines just behind the λ, I get a free id error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh drat I misread this bit below:

Screenshot 2024-12-01 at 11 21 12 AM

I checked out the code and ran Resyntax over it manually and it did indeed fix this code, so I think the issue is it just ran up against the fix limit.

(get-snip-hspace))
this-major)))])))
(define level (car levels))
(car level)
Copy link
Member

Choose a reason for hiding this comment

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

woah, another unused thing!

[else
(set! last-size this-size)
(set!
last-name
Copy link
Member

Choose a reason for hiding this comment

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

this is probably a bad place to break a set!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree (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.

I also agree! Will fix.

@rfindler
Copy link
Member

rfindler commented Dec 1, 2024

There was a big change in the middle of standalone-module-browser.rkt that the diff wasn't very informative so I couldn't really be sure nothing is wrong.

@rfindler
Copy link
Member

rfindler commented Dec 1, 2024

(but things look good to me overall)

@jackfirth
Copy link
Collaborator

There was a big change in the middle of standalone-module-browser.rkt that the diff wasn't very informative so I couldn't really be sure nothing is wrong.

Does reviewing the change on a commit-by-commit basis help? It seems the large diff came as a result of some let-to-define rewrites that had to reindent a lot of code.

@rfindler
Copy link
Member

rfindler commented Dec 1, 2024

There was a big change in the middle of standalone-module-browser.rkt that the diff wasn't very informative so I couldn't really be sure nothing is wrong.

Does reviewing the change on a commit-by-commit basis help? It seems the large diff came as a result of some let-to-define rewrites that had to reindent a lot of code.

It looks like 8ad65d5 is just as non-easy to review as the whole thing, at least when I view it in github's ui. Is there a better way?

@sorawee
Copy link
Contributor

sorawee commented Dec 1, 2024

@rfindler perhaps you are viewing the diff with the "Unified" layout? Can you switch to the "Split" layout and see if it helps? Below is how the "Split" layout displays to me, which is quite reasonable.

Screenshot 2024-12-01 at 7 31 10 AM

@rfindler
Copy link
Member

rfindler commented Dec 1, 2024

@rfindler perhaps you are viewing the diff with the "Unified" layout? Can you switch to the "Split" layout and see if it helps? Below is how the "Split" layout displays to me, which is quite reasonable.
Screenshot 2024-12-01 at 7 31 10 AM

That's what I see. Perhaps I'm too picky, but let me ask you: how many of the 125 lines starting with the one numbered 365 actually changed and how many are just indentation shifts?

@sorawee
Copy link
Contributor

sorawee commented Dec 1, 2024

Ah, if you don't want to see reindentation, you can select "Hide whitespace". It looks like the GitHub UI is buggy, and the change will not take effect immediately. You need to additionally refresh the page once.

After doing that, here's how it looks for me.

Screenshot 2024-12-01 at 7 39 07 AM

@rfindler
Copy link
Member

rfindler commented Dec 1, 2024

Oh! Thanks! That works! (It sometimes shows the whitespace changes highlighted (like in the last line of your most recent screenshot) and I was missing those, but this works well. I'll try to remember to use that!

@jackfirth jackfirth merged commit 2ecb61b into master Dec 4, 2024
3 checks passed
@jackfirth jackfirth deleted the autofix-70-1 branch December 4, 2024 21:39
mflatt pushed a commit to mflatt/drracket that referenced this pull request Dec 27, 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