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

Add a --fix CLI option to automatically attempt to fix syntax errors #39

Open
kehoecj opened this issue Sep 30, 2023 · 2 comments
Open
Assignees
Labels
CLI Update to the CLI enhancement New feature or request validator-core Issues that relate to the core validator functionality

Comments

@kehoecj
Copy link
Contributor

kehoecj commented Sep 30, 2023

Description

Since the primary purpose of this tool right now is to validate configuration file syntax it would be beneficial to have the validator tool to not only identify syntax issues but also fix them. This would be a fairly big undertaking and would likely have to come with "no warranty" - at least until the schema validation changes are incorporated into this tool [Link story here when created]. We'd have to determine if we want to fix the files in place (maybe requiring an extra flag), create new files, or display the changes in stdout like gofmt does by default.

Fixing the syntax errors would likely require implementing a loop that would repeatedly fix then validate until everything was correct. If a fix could not be determined it would provide an error stating why it couldn't be fixed (and revert back to the original file or work out of a temp file and only change the orig file when it passed validation.

A less aggressive implementation could be to output recommendations in the reporter output rather than actually trying to fix things.

@kehoecj kehoecj added the enhancement New feature or request label Sep 30, 2023
@kehoecj kehoecj changed the title Add a --fix CLI option to automatically "attempt" to fix syntax errors Add a --fix CLI option to automatically attempt to fix syntax errors Sep 30, 2023
@kehoecj kehoecj added validator-core Issues that relate to the core validator functionality CLI Update to the CLI hacktoberfest Hacktoberfest 2023 labels Oct 2, 2023
@kehoecj kehoecj removed the hacktoberfest Hacktoberfest 2023 label Oct 17, 2023
@parkerstafford
Copy link
Contributor

I would be more than happy to start working on this if it's still something you'd like to implement.

@kehoecj
Copy link
Contributor Author

kehoecj commented Mar 27, 2024

@parkerstafford Yes go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI Update to the CLI enhancement New feature or request validator-core Issues that relate to the core validator functionality
Projects
None yet
Development

No branches or pull requests

2 participants