Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Clang tidy help

Clang tidy help

Scheduled Pinned Locked Moved Unsolved C++ Gurus
clang-tidybeautifierclang-formatc++
4 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shirl
    wrote on 14 Dec 2020, 08:56 last edited by
    #1

    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 areas

    How 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

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 2 Jan 2021, 08:37 last edited by
      #2

      And you did research and read up on this before asking someone to show you how, right?

      https://clang.llvm.org/extra/clang-tidy/

      1 Reply Last reply
      1
      • E Offline
        E Offline
        Eukaryote
        wrote on 10 Jan 2021, 13:14 last edited by Eukaryote 1 Oct 2021, 13:18
        #3

        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?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shirl
          wrote on 25 Jan 2021, 12:17 last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved