Add a code formatter action to our repository #1664
+43,308
−37,137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a code formatter that runs on every pr action.
This is roughly equivalent to what happens in the OneAuth/MSAL-cpp codebase. Every time you check in, we run a formatter on the code and if there is a difference it creates another commit and checks it in. You have to review these commits, because we don't trust the formatter, but with the exception of this giant review they should be small and easy to follow.
In addition to the formatter running, moving lines around broke several suppressions. Rather than move them, I just either fixed them in the case of the extra-string-creation pieces, or added a suppression comment that won't break when the format runs.
The benefits of using code formatters is that they will help with merges. If you run the same code formatter on your branch, then the merge difference will be smaller, particularly when you're messing with import statements and other silly things. This also puts us closer to having AOSP style enforcement.
If you're working on something that's spanning this change, an easy way to work around it if you don't want to just get the command line tool and run it is to just take the formatter yml file into your branch, altered to run on your branch instead of dev, check it in, pull the result, and remove the formatter file.