Clang tidy help
-
Hi!
I am a complete beginner and wanted to learn more about Code Beautifier and clang tidy. I have never done this before and need your help. :)
I have a list of formatting rules that I would like to work through with clang tidy.
I have thought of 15 formatting rules that I want to follow:
not use /.../ style comments
make labels easy to see
ensure consistens line endings
Layout boolean expression neatly
balance space around binary operators
no space after non-word prefix operators
no space before postfix operators
avoid more than 60 lines in a block
no more than 60 characters on a comment line
avoid more than 500 to 1000 lines per file
avoid more than 140 character per line
start each statement or declaration on a new line
prefer break, continue, and return to deeper nesting
ident to reflect nesting and continuation of statements and declarations
avoid more than three levels of nesting
balance space around braced, bracketed and parenthesized areasHow are these things possible with clang tidy?
And is it possible to process multiple files or whole directories at once. For example, is it possible to process all *.c files from a given directory with one command?Can you help me please?
Thanks a lot in advance!Best regards
Shirl -
And you did research and read up on this before asking someone to show you how, right?
-
Hi @shirl
I think that what you need is a clang-format, not clang-tidy. clang-tidy is a linter, it doesn't format code.
Useful documentation on clang-format: https://clang.llvm.org/docs/ClangFormat.html
Here https://www.clangformat.com/ you can try different styles and see how they affect your code.
And this part:
avoid more than 60 lines in a block
no more than 60 characters on a comment line
avoid more than 500 to 1000 lines per file
prefer break, continue, and return to deeper nesting
How do you want to enforce it? Line breaks, whitespace can be added, but what do you want to do here? -
Hi @Kent-Dorfman and @Eukaryote ! :)
Of course, I have read and viewed the documentation.
However, I have problems with the realization. I am a beginner and have not yet come into contact with this topic. For this reason, I thought I could find support here.