From 310f134e3b888f7304f5e28ec2147be5ea624b83 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Sat, 20 Dec 2025 19:54:09 +0100 Subject: [PATCH 1/4] fix: update license header handling in CppConfig to ensure default path is set --- src/devops/config/config_cpp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/devops/config/config_cpp.py b/src/devops/config/config_cpp.py index 48a85be..d978ebb 100644 --- a/src/devops/config/config_cpp.py +++ b/src/devops/config/config_cpp.py @@ -39,8 +39,12 @@ def to_toml_lines(self) -> list[str]: f"#license_header_check = {str(self.license_header_check).lower()}\n" ) - if self.license_header is not None: - lines.append(f'#license_header = "{self.license_header}"\n') + if self.license_header is None: + license_header = "" + else: + license_header = f'"{self.license_header}"' + + lines.append(f"#license_header = {license_header}\n") lines.append( f"#check_only_staged_files = {str(self.check_only_staged_files).lower()}\n" From edc440cdd211c23bae5186c0f49c6227b00682d4 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Sat, 20 Dec 2025 19:55:49 +0100 Subject: [PATCH 2/4] docs: add license header entry to changelog for default config --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7761ad0..1e35108 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 +### Bug Fixes + +#### Config + +- generated default .toml file contains now key `license_header` + ## [0.0.1](https://github.com/repo/owner/releases/tag/0.0.1) - 2025-12-20 From 91dcb56b9e1ec2c4afcf3cfc569d10437cc93e68 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Sat, 20 Dec 2025 20:17:24 +0100 Subject: [PATCH 3/4] feat: add directories input argument for C++ checks --- devops.toml.template | 23 ----------------------- src/devops/cpp/checks.py | 11 +++++++++-- src/devops/scripts/cpp_checks.py | 16 ++++++++++++++-- 3 files changed, 23 insertions(+), 27 deletions(-) delete mode 100644 devops.toml.template diff --git a/devops.toml.template b/devops.toml.template deleted file mode 100644 index 32882f5..0000000 --- a/devops.toml.template +++ /dev/null @@ -1,23 +0,0 @@ -# DevOps Configuration File - -[exclude] -#buggy_cpp_macros = [] - -[logging] -#global_level = "INFO" -#utils_level = "INFO" -#config_level = "INFO" -#cpp_level = "INFO" - -[git] -#tag_prefix = "" -#empty_tag_list_allowed = true - -[cpp] -#style_checks = true -#license_header_check = true -#check_only_staged_files = false - -[file] -#encoding = "utf-8" - diff --git a/src/devops/cpp/checks.py b/src/devops/cpp/checks.py index 871d6cb..1822a92 100644 --- a/src/devops/cpp/checks.py +++ b/src/devops/cpp/checks.py @@ -107,7 +107,9 @@ def run_file_rules(rules: list[Rule], file: Path) -> list[ResultType]: def run_cpp_checks( - rules: list[Rule], config: CppConfig = __GLOBAL_CONFIG__.cpp + rules: list[Rule], + config: CppConfig = __GLOBAL_CONFIG__.cpp, + dirs: list[Path] | None = None, ) -> None: """Run C++ checks based on the provided rules. @@ -126,7 +128,12 @@ def run_cpp_checks( If invalid (non-file or non-line) rules are provided. """ - if config.check_only_staged_files: + if dirs is not None: + cpp_check_logger.info( + f"Running checks in directories: {[str(d) for d in dirs]}" + ) + files = get_files_in_dirs(dirs) + elif config.check_only_staged_files: cpp_check_logger.info("Running checks on staged files...") files = get_staged_files() else: diff --git a/src/devops/scripts/cpp_checks.py b/src/devops/scripts/cpp_checks.py index 69ab3d6..405eb2a 100644 --- a/src/devops/scripts/cpp_checks.py +++ b/src/devops/scripts/cpp_checks.py @@ -1,23 +1,30 @@ """Module defining C++ check rules.""" from dataclasses import replace +from pathlib import Path import typer from devops import __GLOBAL_CONFIG__ from devops.cpp import build_cpp_rules, run_cpp_checks +from devops.files import filter_cpp_files, get_dirs_in_dir, get_files_in_dirs app = typer.Typer(help="C++ code quality checks.") @app.command() -def cpp_checks(license_header: str | None = None) -> None: +def cpp_checks( + license_header: str | None = None, dirs: list[str] | None = None +) -> None: """Run C++ code quality checks. Parameters ---------- license_header: str | None The path to the license header file. If None, uses the global configuration. + dirs: list[str] | None + List of directories to check. + If None, uses all directories in the current directory. """ if license_header is None: @@ -28,5 +35,10 @@ def cpp_checks(license_header: str | None = None) -> None: license_header=license_header, ) + dirs = get_dirs_in_dir() if dirs is None else [Path(d) for d in dirs] + + files = get_files_in_dirs(dirs) + files = filter_cpp_files(files) + rules = build_cpp_rules(config) - run_cpp_checks(rules, config) + run_cpp_checks(rules, config, dirs=dirs) From 9e84f4d833ce213e5163d1b5e348ef2d8705d155 Mon Sep 17 00:00:00 2001 From: Jakob Gamper <97gamjak@gmail.com> Date: Sat, 20 Dec 2025 20:19:31 +0100 Subject: [PATCH 4/4] docs: update changelog to include dirs argument for cpp_checks cli --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e35108..db8194a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## Next Release +### API + +- Add `dirs` argument to `cpp_checks` cli + ### Bug Fixes #### Config