Little Go tool to infer an uncrustify config file from an expected format
This tool relies on an uncrustify executable, you must then have an uncrustify version somewhere on your system.
Do the work
uncrustify-infer -u <uncrustify-path> -i <input-file> -o <desired-file> -c <config-path>
<unscrustify-path>path to the uncrustify executable
<input-file>path to a file that is as badly formatted as you can
<desired-file>path to a file that is the equivalent of
<input-file>with the desired format
<config-path>path to output the inferred config file
How it works
It basically tries every value for every configuration rule.
For each rule, it extracts a differential ratio for every possible value and checks against the previous configuration to know whether to apply the rule or go on.
- if the differential ratio is at most equal (no effect) for every possible value than the previous rule, go on
- if the differential ratio decreases (works in our way), apply rule for the most decreased value and go to next rule