Reputation: 2819
I have a research project with several files (~100). The code has been written over the years without any specific style. Each developer (mostly master students that come, code and leave) used their own "style", if any.
Now, I'm trying to maintain the code in a way to make new people that join us follow certain rules. I found that Google published some style-guide. Luckily enough they published also a python script, that is easy to use.
The problem is, the script gives me for each file a tone of silly errors like
Missing space after , [whitespace/comma] [3]
or
Missing space before { [whitespace/braces] [5]
My question is: Is it somehow possible to automatize the correction of such "errors"? That mean running a script over a file that eliminates automatically all those errors.
Upvotes: 13
Views: 11088
Reputation: 15018
To update this answer for those of you using vscode
, there's an extension there called clang-format
and in the settings there is the parameter
Clang-format › Language › Cpp: Style
clang-format fallback style for C++, left empty to use clang-format.style
Typing google
in the text box should enable application of the Google formatting rules.
Upvotes: 1
Reputation: 35944
clang-format
might be useful, as it can be run with an option to use Google style rules:
clang-format -style=Google ...
See e.g. http://clang.llvm.org/docs/ClangFormatStyleOptions.html
Upvotes: 15