Skip to content

Conversation

@Gauteab
Copy link
Contributor

@Gauteab Gauteab commented Oct 4, 2022

Implemented a flag to gren format that checks if files are formatted without modifying them:
image
image
image

Comment on lines 155 to 159
validateFiles :: [FilePath] -> Task.Task Exit.Format ()
validateFiles paths = do
validationResults <- mapM validateFile paths
when (any (== False) validationResults) $
Task.throw Exit.FormatValidateNotCorrectlyFormatted
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently I check all files before throwing an error so you get a full report.
Is it better to just throw on first invalid file?

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I think checking all files is good. I often use gren format --validate in CI settings, so I don't necessarily care about how long the validation takes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, checking all seems best, given that this ought to be fast even with lots of files.

@robinheghan
Copy link
Member

Tagging @avh4 for review.

Copy link
Member

@robinheghan robinheghan left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I'd love @avh4 review before merging.

@Gauteab would you mind adding your name to the CONTRIBUTORS.md document?

Great work! 💯

validateExistingFile path = do
putStr ("Validating " ++ path)
original <- File.readUtf8 path
case formatByteString Parse.Application original of
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to how formatFile does it, when inputs is Project projectType paths (line 152 above), we should use that projectType instead of Parse.Application. That allows special core modules to be parsed properly. (If you try it on the gren/core library, you should see the problem.)

Copy link
Contributor

@avh4 avh4 left a comment

Choose a reason for hiding this comment

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

I think we need to fix https://github.com/gren-lang/compiler/pull/143/files#r987541415 (the comment above about "projectType") but otherwise this looks great!

@robinheghan
Copy link
Member

Thank you, @Gauteab
And thanks for helping out with reviewing this, @avh4

@robinheghan robinheghan merged commit eb177ee into gren-lang:main Oct 5, 2022
@avh4 avh4 mentioned this pull request Nov 28, 2022
31 tasks
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