From 6eb9d9bff5606428b96ea42daa0c64cd53f3b2be Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Fri, 20 Feb 2026 14:32:38 +0100 Subject: [PATCH 1/4] feat: include src dir for header guard checks and make it possible to use .tpp and .impl.hpp files --- src/devops/cpp/style_rules.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/devops/cpp/style_rules.py b/src/devops/cpp/style_rules.py index 75fd7f6..ffc944e 100644 --- a/src/devops/cpp/style_rules.py +++ b/src/devops/cpp/style_rules.py @@ -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 = ( From 245b14565c57154c2ec0ec1fe6afec895ee8a057 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Fri, 20 Feb 2026 14:36:28 +0100 Subject: [PATCH 2/4] feat: extend file type detection to include .tpp and .impl.hpp extensions --- src/devops/files/files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devops/files/files.py b/src/devops/files/files.py index cb53400..6d54aad 100644 --- a/src/devops/files/files.py +++ b/src/devops/files/files.py @@ -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 From 52d48212babf25b82e112283bdb32978080c0d64 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Fri, 20 Feb 2026 14:49:20 +0100 Subject: [PATCH 3/4] feat: update changelog to include new feature for checking header guards in .tpp and .impl.hpp files --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7f36ac..0b1656b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 + ## [0.1.0](https://github.com/repo/owner/releases/tag/0.1.0) - 2026-01-18 From e1f92bee25f7817f97b057e4334e626785306bdb Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Fri, 20 Feb 2026 14:51:42 +0100 Subject: [PATCH 4/4] fix: update header guard test to use .h extension instead of .hpp --- tests/cpp/test_style_rules.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cpp/test_style_rules.py b/tests/cpp/test_style_rules.py index 8e4f8cd..8990eef 100644 --- a/tests/cpp/test_style_rules.py +++ b/tests/cpp/test_style_rules.py @@ -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();