Skip to content

Commit

Permalink
style(cxx-cuda): add clang-tidy configuration
Browse files Browse the repository at this point in the history
- Create .clang-tidy files for both C++ and CUDA project templates
- Enable a comprehensive set of lint checks for code quality and style
- Configure naming conventions for various identifier types
- Set thresholds for function complexity and bug detection
- Encourage modern C++ practices and core guidelines
- Address security and performance concerns in the codebase
  • Loading branch information
pplmx committed Dec 25, 2024
1 parent 37d3264 commit 4856615
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 0 deletions.
79 changes: 79 additions & 0 deletions template/cuda/{{cookiecutter.project_slug}}/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Checks: >
-*, # Disable all checks by default
bugprone-*,
readability-*,
performance-*,
modernize-*,
cppcoreguidelines-*,
clang-analyzer-*,
portability-*,
security-*,
misc-*,
google-*,
CheckOptions:
# Naming conventions
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.MethodCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: m_camelBack
- key: readability-identifier-naming.StaticMemberCase
value: s_camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: g_lower_case
- key: readability-identifier-naming.NamespaceCase
value: lower_case

# Function complexity
- key: readability-function-cognitive-complexity.Threshold
value: 35

# Bug detection
- key: bugprone-argument-comment
value: 1
- key: bugprone-branch-clone
value: 1
- key: bugprone-use-after-move
value: 1

# Modern practices
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-auto
value: 1
- key: modernize-avoid-bind
value: 1

# Core guidelines
- key: cppcoreguidelines-no-malloc
value: 1
- key: cppcoreguidelines-pro-type-cstyle-cast
value: 1
- key: cppcoreguidelines-special-member-functions
value: 1

# Security
- key: security-undefined-bool-conversion
value: 1
- key: security-implicit-int-float-conversion
value: 1

# Performance
- key: performance-unnecessary-copy-initialization
value: 1
- key: performance-for-range-copy
value: 1
- key: performance-move-const-arg
value: 1
79 changes: 79 additions & 0 deletions template/cxx/{{cookiecutter.project_slug}}/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Checks: >
-*, # Disable all checks by default
bugprone-*,
readability-*,
performance-*,
modernize-*,
cppcoreguidelines-*,
clang-analyzer-*,
portability-*,
security-*,
misc-*,
google-*,
CheckOptions:
# Naming conventions
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.MethodCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: m_camelBack
- key: readability-identifier-naming.StaticMemberCase
value: s_camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: g_lower_case
- key: readability-identifier-naming.NamespaceCase
value: lower_case

# Function complexity
- key: readability-function-cognitive-complexity.Threshold
value: 35

# Bug detection
- key: bugprone-argument-comment
value: 1
- key: bugprone-branch-clone
value: 1
- key: bugprone-use-after-move
value: 1

# Modern practices
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-auto
value: 1
- key: modernize-avoid-bind
value: 1

# Core guidelines
- key: cppcoreguidelines-no-malloc
value: 1
- key: cppcoreguidelines-pro-type-cstyle-cast
value: 1
- key: cppcoreguidelines-special-member-functions
value: 1

# Security
- key: security-undefined-bool-conversion
value: 1
- key: security-implicit-int-float-conversion
value: 1

# Performance
- key: performance-unnecessary-copy-initialization
value: 1
- key: performance-for-range-copy
value: 1
- key: performance-move-const-arg
value: 1

0 comments on commit 4856615

Please sign in to comment.