Boeing / config-file-validator

Cross Platform tool to validate configuration files
https://boeing.github.io/config-file-validator/
Apache License 2.0
342 stars 68 forks source link

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

Open kehoecj opened 1 year ago

kehoecj commented 1 year ago

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.

parkerstafford commented 7 months ago

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

kehoecj commented 7 months ago

@parkerstafford Yes go for it!