Skip to content

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

@danielozyurt

Description

@danielozyurt

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions