From: SONOLET Aymeric Date: Tue, 16 Apr 2024 10:15:17 +0000 (+0200) Subject: feat: add clang-format and pre-commit config files X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=652941f57cf4410f55730b33f3842302fd6274bb;p=tools%2Fmedcoupling.git feat: add clang-format and pre-commit config files --- diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..b54894b56 --- /dev/null +++ b/.clang-format @@ -0,0 +1,21 @@ +# A clang-format style that approximates Python's PEP 7 +# Useful for IDE integration +# +BasedOnStyle: Google +AlignAfterOpenBracket: Align +AllowShortEnumsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AlwaysBreakAfterReturnType: TopLevel +BreakBeforeBraces: Stroustrup +ColumnLimit: 79 +ContinuationIndentWidth: 8 +DerivePointerAlignment: false +IndentWidth: 4 +IncludeBlocks: Regroup +Language: Cpp +PointerAlignment: Right +ReflowComments: true +SpaceBeforeParens: ControlStatements +SpacesInParentheses: false +TabWidth: 4 +UseTab: Never diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..2a4efa8c9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,102 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 # Use the ref you want to point at + hooks: + - id: trailing-whitespace + exclude: | + (?x)^( + .*\.py| + .*\.cpp| + .*\.h| + .*\.hpp| + .*\.hxx| + .*\.cxx + )$ + - id: check-added-large-files + - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + exclude: | + (?x)^( + .*\.py| + .*\.cpp| + .*\.h| + .*\.hpp| + .*\.hxx| + .*\.cxx + )$ + - id: check-case-conflict + exclude: | + (?x)^( + .*\.py| + .*\.cpp| + .*\.h| + .*\.hpp| + .*\.hxx| + .*\.cxx + )$ + - id: check-json + - id: pretty-format-json + - id: check-merge-conflict + - id: check-toml + - id: check-xml + - id: requirements-txt-fixer + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.3.7 + hooks: + # Run the linter. + - id: ruff + types_or: [python, pyi, jupyter] + args: [--fix] + exclude: | + (?x)^( + .*[Tt]est.*| + .*__init__.py + )$ + # Run the formatter. + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v18.1.3 # Use the sha / tag you want to point at + hooks: + - id: clang-format + files: | + (?x)^( + .*\.txx| + .*\.hxx| + .*\.cxx + )$ + types_or: [text] + - repo: https://github.com/scop/pre-commit-shfmt + rev: v3.8.0-1 + hooks: + # Choose one of: + - id: shfmt # prebuilt upstream executable + args: [--indent=4, -w, -s] + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + args: [--severity=warning] + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 # or higher tag + hooks: + - id: yamllint + args: [--strict, '--config-data={extends: relaxed, rules: {line-length: {max: 120}}}'] + - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.3 # or other specific tag + hooks: + - id: yamlfmt + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 # Use the ref you want to point at + hooks: + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format