Skip to content

Consider adding a Clang-Tidy configuration to enforce some coding conventions #272

Description

Take your project DirectXTK as an example, in which you have set these conventions:

PascalCase for class names, methods, functions, and enums.
camelCase for class member variables, struct members
UPPERCASE for preprocessor defines (and nameless enums)

To enforce these naming conventions, you can add readability-* to the checks as shown below:

Checks: >
  -*,
  readability-*

Then add some of these check options:

CheckOptions:
  readability-identifier-naming.ClassCase: 'CamelCase'
  readability-identifier-naming.ClassMethodCase: 'CamelCase'
  readability-identifier-naming.FunctionCase: 'CamelCase'
  readability-identifier-naming.EnumCase: 'CamelCase'
  readability-identifier-naming.ClassMemberCase: 'camelBack'
  readability-identifier-naming.MemberCase: 'camelBack'
  readability-identifier-naming.MacroDefinitionCase: 'UPPER_CASE'
  readability-identifier-naming.EnumConstantCase: 'UPPER_CASE'

Microsoft Visual Studio supports Clang-Tidy and Clang-Format out of the box.

P.S.: while EditorConfig is fine, I think you can enforce more specific code-style conventions, such as east const and west const with Clang-Format.

Using Clang-Tidy (and perhaps also Clang-Format) could help maintain greater code consistency.

Reference:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions