Skip to content
Snippets Groups Projects

Wrong formatting settings clang-tidy in C++ template project

Merged Hannes Feldt requested to merge CWG-48-fix_clang-tidy into main
2 unresolved threads

Closes CWG-48

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
1 Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming,readability-braces-around-statements'
2 2 CheckOptions:
3 3 - key: readability-identifier-naming.ClassCase
4 4 value: CamelCase
5 5 - key: readability-identifier-naming.EnumCase
6 6 value: CamelCase
7 - key: readability-identifier-naming.UnionCase
8 value: CamelCase
9 # Within ASTRON no specific casing is used. Feel free to adjust
10 # following casings to camelBack for existing projects or
11 # personal/team preferences.
  • Comment on lines +9 to +11

    It's been a while since I did active C++ development within ASTRON. But we used to have some standards:

    • Class names in CamelCase
    • (Member) function names in snakeCase
    • Class variables start their name with the prefix its (or their for static class variables)

    Insights may have changed, though. @wever should now about current SKA conventions (which are not necessarily ASTRON's conventions).

  • In team Schaap we use GoogleStyle, which has its own naming conventions. https://google.github.io/styleguide/cppguide.html#Naming

    GoogleStyle is on of the SKA style guides too,

  • Author Developer

    @wever the google style is using CamelCase (or PascalCase) for methods. I can add that to the comment or even set is as a default if we want to go into that direction.

    @loose For function names do you mean snake_case or camelBack (sometimes named camelCase)? About the prefixes: if we wont to go into that direction we ofc can add that as well but probably should first decide on a (common) style.

  • I meant camelBack (I thought that was usually referred to as snakeCase).

  • I think referring to a style-guide can't hurt. Google's is quite nice. (I really like they provide rationales for their choices, so you can see whether their reasoning applies to your organization.)

    If there is no ASTRON sanctioned style we can make the default Google-style and hope others will start to use the same style. I really like it when code has a consistent style, that makes understanding it a lot easier.

  • For what it's worth. Here's our (20 year old!) ASTRON coding standard. coding_standard_C++_v2.1.pdf

  • Interesting, at that time ASTRON still used CVS ;-) But indeed this document is quite dated and it's not provided to new developers during their onboarding.

    I wouldn't be against reviving this document.

  • We could pick this up in the CI/CD group. Maybe good to discuss within Team Schaap too.

  • Hannes Feldt changed this line in version 2 of the diff

    changed this line in version 2 of the diff

  • Please register or sign in to reply
  • .editorconfig 0 → 100644
    7 end_of_line = lf
    8 indent_style = space
    9 insert_final_newline = true
    10 trim_trailing_whitespace = true
    11 indent_size = 4
    12
    13 # Tab indentation (no size specified)
    14 [Makefile]
    15 indent_style = tab
    16
    17 [{CMakeLists.txt,*.cmake,*.rst}]
    18 indent_size = 2
    19 indent_style = space
    20
    21 [*.{py,c,h,hpp,cc,cpp}]
    22 max_line_length = 80
    • Comment on lines +21 to +22

      Don't we use black for formatting Python code? That tool defaults to a line length of 88.

    • In team Schaap we this:

      # Use line length 79, which complies with PEP-8.
      BLACK="black -l 79"
    • TBH, with indentation of 4, I find a line length of 80 quite limiting. I know that pylint uses 100 by default, and (like I said) black uses 88. Even that is already somewhat limiting. I don't think readability always improves with a lot of line wrapping :disappointed:

    • I agree that the tools are never 100% great, much better that a programmer. In C++ I tend to use trailing // or clang-format: off for the few parts the tool does not work great.

      I still like 80 characters combined with 4 column tabs. IMO when 80 columns becomes too small it quite often means the indention level is high and that might be a sign your function is too complex. (It somewhat depends on the domain, in team Schaap we iterate over 3 dimensional arrays on a regular basis.)

    • Author Developer

      In our python template we use different tools with different settings. One of them is pep8 which indeed uses 79 characters.

    • Hannes Feldt changed this line in version 3 of the diff

      changed this line in version 3 of the diff

    • Please register or sign in to reply
  • Hannes Feldt added 1 commit

    added 1 commit

    • 89ff1995 - Set function case to CamelCase

    Compare with previous version

  • Hannes Feldt added 1 commit

    added 1 commit

    Compare with previous version

  • Hannes Feldt mentioned in commit 75c686ae

    mentioned in commit 75c686ae

  • merged

  • Please register or sign in to reply
    Loading