azure-sdk-for-cpp icon indicating copy to clipboard operation
azure-sdk-for-cpp copied to clipboard

Clang-format bot?

Open antkmsft opened this issue 2 years ago • 3 comments

Sometimes I submit a PR, and it fails due to clang-format issues.

Would it be too expensive to implement a bot that runs clang-format and makes a suggestion comments for the PR right away? The machine knows what is wrong, so it knows how to fix it. And with clang-format, it will be what I will do myself as a dev 99% of the time.

The same bot can also do the same types of suggestions for the lack of end-of-line symbol at the end of file.

Later, we can add a check for the copyright header, and the bot could be proposing edits as well.

It does not have to be a github bot - if we can achieve the same using some other mechanism, that is great too.

antkmsft avatar Dec 07 '22 17:12 antkmsft

Why require a PR to do this? I would prefer to make it easy to run clang in a dev environment. Perhaps could be an option in our cmake?

RickWinter avatar Dec 08 '22 17:12 RickWinter

We already have it on a good level - CI error gives you command line for clang-format, and tells you the files that need to be formatted.

I was just thinking, if it knows what has failed, it could suggest the edits.

But your feedback is valid - I understand that I am asking for bells and whistles here, it is ok to deprioritize or Won't-Fix.

antkmsft avatar Dec 09 '22 23:12 antkmsft

It could suggest changes as PR comments (do not commit), and then it is up to you to either commit them from the UI, or resolve comments without merging. As a PR author, I would typically add them to batch in the UI, commit at once (from the UI as well), and then "git pull" locally, just as you do with the code suggestion comments from humans.

antkmsft avatar Feb 13 '24 22:02 antkmsft