Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## Next Release

### Features

#### CPP Rules

- make it possible to check header guards also for `.tpp` and `.impl.hpp` files

<!-- insertion marker -->
## [0.1.0](https://github.com/repo/owner/releases/tag/0.1.0) - 2026-01-18

Expand Down
17 changes: 14 additions & 3 deletions src/devops/cpp/style_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,21 @@ def check_header_guards(file_rule_input: FileRuleInput) -> ResultType:
expected_macro = str(path).upper()
expected_macro = expected_macro.removeprefix("INCLUDE/")
expected_macro = expected_macro.removeprefix("TEST/")
expected_macro = expected_macro.removeprefix("SRC/")
expected_macro = expected_macro.replace("/", "__")
expected_macro = expected_macro.removesuffix(".HPP")
expected_macro = expected_macro.removesuffix(".H")
expected_macro = "__" + expected_macro + "_HPP__"

if expected_macro.endswith(".IMPL.HPP"):
expected_macro = expected_macro.removesuffix(".IMPL.HPP")
expected_macro = "__" + expected_macro + "_IMPL_HPP__"
elif expected_macro.endswith(".HPP"):
expected_macro = expected_macro.removesuffix(".HPP")
expected_macro = "__" + expected_macro + "_HPP__"
elif expected_macro.endswith(".TPP"):
expected_macro = expected_macro.removesuffix(".TPP")
expected_macro = "__" + expected_macro + "_TPP__"
elif expected_macro.endswith(".H"):
expected_macro = expected_macro.removesuffix(".H")
expected_macro = "__" + expected_macro + "_H__"

if guard_macro != expected_macro:
msg = (
Expand Down
2 changes: 1 addition & 1 deletion src/devops/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def determine_file_type(filename: str | Path) -> FileType:
"""
filename = str(filename)

if filename.endswith((".h", ".hpp")):
if filename.endswith((".h", ".hpp", ".tpp", ".impl.hpp")):
return FileType.CPPHeader
if filename.endswith((".cpp", ".cxx", ".cc", ".c")):
return FileType.CPPSource
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp/test_style_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ class MockClass {};

def test_check_header_guards_with_h_extension(self) -> None:
"""Test header guards with .h extension."""
file_content = """#ifndef __MYHEADER_HPP__
#define __MYHEADER_HPP__
file_content = """#ifndef __MYHEADER_H__
#define __MYHEADER_H__

void myFunction();

Expand Down