# mpyhooks This tool provides various hooks to check file content in a repository, with many originating from the [OpenFOAM Foundation's code style guide](https://openfoam.org/dev/coding-style-guide/). The hooks can be easily integrated with pre-commit for automated checking. ## Usage ```bash mpyhooks [options] [files ...] ``` ## Available Hooks ### encoding - Preview File Encoding Check encoding for preview files in [Rodare](https://rodare.hzdr.de) (Rossendorf Data Repository). **Usage:** ```bash mpyhooks encoding file1 file2 ... ``` ### line-length - Line Length Check Check for line length less than 80 characters. Enforces maximum line length following OpenFOAM Foundation software style guide. **Usage:** ```bash mpyhooks line-length file1.C file2.H ... ``` ### ifndef - Header Guard Check Check for `#ifndef` directive and `#define` statements in header files. Ensures proper include guards in header files. The hook tries to detect regular header files and will skip header files that contain pure source code only. The detection is based on a test for `#pragma once`, `#ifndef` or `#define`. **Usage:** ```bash mpyhooks ifndef MyClass.H ... ``` **Expected format:** ```cpp #ifndef MyClass_H #define MyClass_H // ... content ... #endif ``` ### tabs - Tab Detection Check for tabs in files (should use 4 spaces instead). **Usage:** ```bash mpyhooks tabs file1.C file2.py ... ``` ### non-standard-code - Code Style Check Checks for non-standard C++ patterns per OpenFOAM Foundation software guidelines. **Usage:** ```bash mpyhooks non-standard-code file1.C file2.H ... ``` ### copyright - Copyright Validation Check and fix copyright header in source code files. The header is generated based on JINJA templates. A template for HZDR and OpenFOAM Foundation software for C++, shell and dictionaries is shipped with the package. Metadata for the header has to be provided via `codemeta.json` and/or by `reuse.toml`. The hook tries to load both automatically. The copyright holder for the source code file is generated from the existing header, the `copyrightHolder` key in codemeta.json and from reuse annotations. In case duplicates exists, they are merged. **Usage:** ```bash mpyhooks copyright --template