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

Check formatting #5760

Merged
merged 2 commits into from Nov 3, 2022
Merged

Conversation

tsnobip
Copy link
Contributor

@tsnobip tsnobip commented Oct 28, 2022

Fixes #4780.

This PR also fixes a few bugs:

  • the last line of rescript format usage was not being displayed
  • there was a mix of sync and async functions with side effects which led to conditions (hasError) not waiting for the variable to be indeed properly set

hasError = true;
var incorrectlyFormattedFiles = 0;
try {
const _promises = await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

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

I noticed - and this applies to the old as well as the new implementation - that bsc -format is run in parallel for all files.

Not sure how far this will scale. Maybe this should be changed to processing in batches, but that's probably out of the scope of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say it's indeed out of scope of this PR, especially if we don't have any report of issues caused by this.

if (!write) {
process.stdout.write(stdout);
try {
const formatted = child_process.execFileSync(bsc_exe, flags);
Copy link
Member

Choose a reason for hiding this comment

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

As discussed on Discord, please add a comment explaining why processing is sync here, but async above.

Copy link
Member

Choose a reason for hiding this comment

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

Side comment: do we have a discord community channel? 😲

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattdamon108 haha no dm

Copy link
Member

Choose a reason for hiding this comment

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

@tsnobip Ah! haha

Copy link
Member

Choose a reason for hiding this comment

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

@mattdamon108 What's your Discord handle?

Copy link
Member

Choose a reason for hiding this comment

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

@cknitt moondaddi#2730

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed on Discord, please add a comment explaining why processing is sync here, but async above.

now that I think about it, I don't know if the asynchronous processing we had before actually created any issue? I'll indeed add some comments about my reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rewrote it to use the same logic, there's no reason why the output would be mixed anyway.

@tsnobip tsnobip requested a review from cknitt November 3, 2022 10:10
scripts/rescript_format.js Outdated Show resolved Hide resolved
scripts/rescript_format.js Outdated Show resolved Hide resolved
@tsnobip tsnobip requested a review from cknitt November 3, 2022 13:31
@cknitt
Copy link
Member

cknitt commented Nov 3, 2022

Ah, I forgot: @tsnobip could you also add an entry to the changelog?

@tsnobip tsnobip changed the base branch from master to 10.1_release November 3, 2022 18:04
@tsnobip
Copy link
Contributor Author

tsnobip commented Nov 3, 2022

Ah, I forgot: @tsnobip could you also add an entry to the changelog?

@cknitt done and I rebased on 10.1 so we can release it right away.

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.

[Feature request] Add support for checking format
4 participants