TypeART icon indicating copy to clipboard operation
TypeART copied to clipboard

Establish consistent code style

Open ahueck opened this issue 5 years ago • 1 comments
trafficstars

Currently, the code style is an arbitrary mix of camel case and snake case.

General

Apply clang-tidy to enforce proper naming conventions, see clang-tidy identifier naming.

Style

A good style seems to be Googles configuration (with some modifications), see Google cloud cpp clang-tidy:

  - { key: readability-identifier-naming.NamespaceCase,          value: lower_case }
  - { key: readability-identifier-naming.ClassCase,              value: CamelCase  }
  - { key: readability-identifier-naming.StructCase,             value: CamelCase  }
  - { key: readability-identifier-naming.TemplateParameterCase,  value: CamelCase  }
  - { key: readability-identifier-naming.FunctionCase,           value: aNy_CasE  }
  - { key: readability-identifier-naming.VariableCase,           value: lower_case }
  - { key: readability-identifier-naming.ClassMemberCase,        value: lower_case }
  - { key: readability-identifier-naming.ClassMemberSuffix,      value: _          }
  - { key: readability-identifier-naming.PrivateMemberSuffix,    value: _          }
  - { key: readability-identifier-naming.ProtectedMemberSuffix,  value: _          }
  - { key: readability-identifier-naming.EnumConstantCase,         value: CamelCase }
  - { key: readability-identifier-naming.EnumConstantPrefix,       value: k         }
  - { key: readability-identifier-naming.ConstexprVariableCase,    value: CamelCase }
  - { key: readability-identifier-naming.ConstexprVariablePrefix,  value: k         }
  - { key: readability-identifier-naming.GlobalConstantCase,       value: CamelCase }
  - { key: readability-identifier-naming.GlobalConstantPrefix,     value: k         }
  - { key: readability-identifier-naming.MemberConstantCase,       value: CamelCase }
  - { key: readability-identifier-naming.MemberConstantPrefix,     value: k         }
  - { key: readability-identifier-naming.StaticConstantCase,       value: CamelCase }
  - { key: readability-identifier-naming.StaticConstantPrefix,     value: k         }
  - { key: readability-implicit-bool-conversion.AllowIntegerConditions,  value: 1   }
  - { key: readability-implicit-bool-conversion.AllowPointerConditions,  value: 1   }

Modifications

  • (Class) Member suffix _ -> m_
  • Method case: camelCase
TODO
  • [ ] Evaluate out if these modfications make sense.
  • [ ] Extend/complete list of modifications as necessary

ahueck avatar Sep 07 '20 13:09 ahueck

If we decide on a specific code style, I guess it makes sense to add contribution guidelines to the project. This is desirable in any case, but more so, if there are clear guidelines people (us included) can follow, if they wish to contribute.

jplehr avatar Sep 15 '20 15:09 jplehr