mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 09:08:09 +01:00
* Qual: Add pre-commit hooks for Perl code formatting and linting - Added perltidy hook to format Perl code - Added perlcritic hook to lint Perl code * Qual: Update file opening syntax in build scripts (perltidy) The changes update the syntax for opening files in several build scripts to use the three-argument form of the `open` function, which is more secure and recommended in modern Perl practices. * Qual: Improve file handling and add strict/warnings pragmas (perlcritic) The changes include: - Adding 'use strict' and 'use warnings' pragmas to enforce better coding practices - Improving file handling by using lexical filehandles (my $IN, my $SPECFROM, etc.) - Fixing file opening and closing operations to use proper error handling - Updating various file operations to use the new lexical filehandles - Fixing indentation and formatting issues in the code * Qual: Add strict and warnings pragmas to Perl scripts (perlcritic) The changes add 'use strict;' and 'use warnings;' pragmas - dev/build/doxygen/dolibarr-doxygen-build.pl - dev/build/doxygen/dolibarr-doxygen-filter.pl - dev/build/doxygen/dolibarr-doxygen-getversion.pl - dev/build/gource/getavatars.pl - dev/tools/dolibarr-mysql2pgsql.pl * Qual: Add Perl no critic pragmas (perlcritic) - Ignore some perlcritic notices * Qual: Improve code formatting and readability Perltidy: - Indentation and spacing - Improved variable naming and alignment - Better code organization and structure - Enhanced readability of conditional statements and loops These changes do not alter the functionality of the script but make it more maintainable and easier to understand. * qual: Exclude virtualmin from perltidy and perlcritic hooks Exclude the virtualmin directory from both perltidy and perlcritic hooks due to specific reasons mentioned in the comment. This change ensures that these hooks do not process files in the virtualmin directory. * Qual: Add installation of perltidy and perlcritic for pre-commit workflow This commit adds the installation of perltidy and perlcritic as part of the pre-commit hooks workflow. * Fix: Update version detection in dolibarr-doxygen-build.pl - Add support for detecting version from DOL_MAJOR_VERSION and DOL_MINOR_VERSION constants - Fix undefined variable issue in version detection * Fix: Update getavatars.pl to use HTTPS and reverse git log - Changed the URL from HTTP to HTTPS for Gravatar - Added `--reverse` flag to git log command to process commits in chronological order (faster) - Updated error message to indicate .git repository instead of .git directory (+ correct test) * fix: Correct spelling in error messages and prompts - Fixed typo in error message for missing environment variables - Corrected spelling in prompt for module name input - Improved clarity in comment for target checking
295 lines
10 KiB
YAML
295 lines
10 KiB
YAML
---
|
|
exclude: (?x)^( htdocs/includes/ckeditor/.*|(\.(?!github/workflows)[^/]*/.*))$
|
|
repos:
|
|
# Several miscellaneous checks and fix (on yaml files, end of files fix)
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v6.0.0
|
|
hooks:
|
|
# This hook tests the name of the branch and return an error if the name is
|
|
# 'develop' or an official version 'x.y'
|
|
# So you can't commit if your branch name is not a custom branch name.
|
|
# Using a custom branch name is good practice that makes it easier to manage PRs.
|
|
# You can skip this:
|
|
# - Permanently:
|
|
# export SKIP=no-commit-to-branch # In your .bashrc or session.
|
|
# - Only this for one commit:
|
|
# SKIP=no-commit-to-branch git commit -a -m "My message"
|
|
# - Skipping all checks for a commit:
|
|
# git commit -a -m "My message" --no-verify
|
|
# (Recommendation: run git commit -a .. once, then with `--no-verify`)
|
|
- id: no-commit-to-branch
|
|
args: [--branch, develop, --pattern, \d+.0$]
|
|
# This checks that xml files are correct
|
|
- id: check-xml
|
|
exclude: |
|
|
(?x)^(htdocs/includes/.*)$
|
|
# This checks that yaml files are correct
|
|
- id: check-yaml
|
|
args: [--unsafe]
|
|
# This checks that json files are correct
|
|
- id: check-json
|
|
# Fixes Fix files that have DOS end of line endings
|
|
- id: mixed-line-ending
|
|
# alternative for dev/tools/fixdosfiles.sh
|
|
exclude: |
|
|
(?x)^(htdocs/includes/tecnickcom/tcpdf/fonts/.*
|
|
|.*/CRLF.*.php # Files in swiftmailer
|
|
)$
|
|
args: [--fix=lf]
|
|
# Remove trailing whitespace
|
|
- id: trailing-whitespace
|
|
exclude_types: [markdown]
|
|
# Fix the end of file
|
|
- id: end-of-file-fixer
|
|
# Check that there are no completely merged file conflicts
|
|
- id: check-merge-conflict
|
|
stages: [pre-rebase, pre-commit, pre-merge-commit]
|
|
# Check that files with shebangs have the executable bit set (in git)
|
|
- id: check-executables-have-shebangs
|
|
# Check that shell files are executables
|
|
- id: check-shebang-scripts-are-executable
|
|
exclude:
|
|
(?x)^( dev/tools/dolibarr-postgres2mysql.php |test/other/test_serialize.php
|
|
|test/phpunit/textutf8.txt |test/phpunit/textiso.txt |htdocs/includes/.*
|
|
|htdocs/modulebuilder/template/.* |dev/build/debian/dolibarr.postrm |dev/build/debian/dolibarr.postinst
|
|
|dev/build/debian/dolibarr.config )$
|
|
# Fix the first UTF8 byte
|
|
- id: fix-byte-order-marker
|
|
# Check that there are no files that have are the same when uppercased (conflict on windows)
|
|
- id: check-case-conflict
|
|
|
|
# Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos
|
|
- repo: https://github.com/gitleaks/gitleaks.git
|
|
rev: v8.29.0
|
|
hooks:
|
|
- id: gitleaks
|
|
|
|
# Check github actions
|
|
- repo: https://github.com/rhysd/actionlint
|
|
rev: v1.7.8
|
|
hooks:
|
|
- id: actionlint
|
|
|
|
# Beautify shell scripts
|
|
- repo: https://github.com/lovesegfault/beautysh.git
|
|
rev: v6.2.1
|
|
hooks:
|
|
- id: beautysh
|
|
exclude: |
|
|
(?x)^(dev/setup/git/hooks/pre-commit
|
|
)$
|
|
args: [--tab]
|
|
|
|
# Run local script
|
|
#
|
|
# For example, to update the license in edited files, you could add to local.sh:
|
|
#
|
|
# ```shell
|
|
# #!/bin/bash
|
|
# MYDIR=$(dirname "$0")
|
|
# git diff HEAD --name-only | grep -v includes | \
|
|
# xargs "$MYDIR/dev/tools/updatelicense.php"
|
|
# ```
|
|
- repo: local
|
|
hooks:
|
|
- name: Find missing/unused/duplicate language keys
|
|
id: check-translations
|
|
files: (?x)^(htdocs/langs/en_US/.*\.lang)
|
|
language: script
|
|
entry: ./dev/translation/sanity_check_trans_missing_unused.sh
|
|
pass_filenames: false
|
|
args: [list]
|
|
- id: local-precommit-script
|
|
name: Run local script before commit if it exists
|
|
language: system
|
|
entry: bash -c '[ ! -x local.sh ] || ./local.sh'
|
|
pass_filenames: false
|
|
- id: duplicate-lang-lines
|
|
stages: [manual]
|
|
name: Find duplicate language lines
|
|
files: (?x)^(htdocs/langs/en_US/.*\.lang)
|
|
language: script
|
|
entry: ./dev/tools/fixduplicatelanglines.sh
|
|
pass_filenames: false
|
|
args: [list]
|
|
- id: duplicate-lang-keys
|
|
stages: [manual]
|
|
name: Find duplicate language keys
|
|
files: (?x)^(htdocs/langs/en_US/.*\.lang)
|
|
language: script
|
|
entry: ./dev/tools/fixduplicatelangkey.sh
|
|
pass_filenames: false
|
|
args: [list]
|
|
- id: fix-alt-languages
|
|
stages: [manual]
|
|
name: Fix alt languages
|
|
# Selection: see fixaltlanguages.sh script
|
|
files: (?x)^(htdocs/langs/(e[lnstu]|k[akmno]|s[lqrv]|b[nrs]|c[asy]|n[bel]|[ip]t|a[mr]|d[ae]|f[ar]|h[ei]|m[sy]|t[ag]|u[kr]|gl|ja|lo|ru|vi|zh)_[^/]*/.*\.lang)
|
|
language: script
|
|
entry: ./dev/tools/fixaltlanguages_pre-commit.sh
|
|
pass_filenames: true
|
|
|
|
# Check PHP syntax
|
|
- repo: https://github.com/mdeweerd/pre-commit-php
|
|
rev: v1.6.8
|
|
hooks:
|
|
- id: php-cbf
|
|
files: \.(php)$
|
|
args: [--standard=dev/setup/codesniffer/ruleset.xml]
|
|
- id: php-cs
|
|
exclude: |
|
|
(?x)^(htdocs/includes/.*)$
|
|
files: \.(php)$
|
|
args:
|
|
[
|
|
--standard=dev/setup/codesniffer/ruleset.xml,
|
|
--report=emacs,
|
|
--severity=5,
|
|
--no-colors,
|
|
]
|
|
- alias: php-cs-with-cache
|
|
id: php-cs
|
|
# Configuration for ci - run on all files with cache
|
|
stages: [manual]
|
|
args:
|
|
[
|
|
--standard=dev/setup/codesniffer/ruleset.xml,
|
|
--report=emacs,
|
|
--severity=5,
|
|
--no-colors,
|
|
--cache=.cache/pre-commit/dolibarr-php-cs.cache,
|
|
.,
|
|
]
|
|
pass_filenames: false # Run on all files
|
|
- id: php-lint
|
|
exclude:
|
|
(?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$
|
|
- id: php-stan
|
|
stages: [manual]
|
|
files: \.(php)$
|
|
|
|
# Prettier (format code, only for non common files)
|
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
rev: v3.1.0
|
|
hooks:
|
|
- id: prettier
|
|
stages: [manual]
|
|
exclude:
|
|
(?x)^( .*\.(phar |min\.css |lock) |htdocs/(includes|theme/common)/.*
|
|
)$
|
|
exclude_types:
|
|
- php
|
|
- executable
|
|
- binary
|
|
- shell
|
|
- javascript
|
|
- markdown
|
|
- html
|
|
- less
|
|
- plain-text
|
|
- scss
|
|
- css
|
|
- yaml
|
|
|
|
# Check format of yaml files
|
|
- repo: https://github.com/adrienverge/yamllint.git
|
|
rev: v1.37.1
|
|
hooks:
|
|
- id: yamllint
|
|
args:
|
|
- --no-warnings
|
|
- -d
|
|
- "{extends: relaxed, rules: {line-length: {max: 120}}}"
|
|
|
|
# Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/)
|
|
- repo: https://github.com/codespell-project/codespell
|
|
rev: v2.4.1
|
|
hooks:
|
|
- id: codespell
|
|
# Due to a current limitation of configuration files,
|
|
# we can specify two dicts only on the CLI.
|
|
# You can update the contents of the exclude-file codespell-lines-ignore with the script
|
|
# dev/tools/codespell/addCodespellIgnores.sh
|
|
args:
|
|
- -D
|
|
- "-"
|
|
- -D
|
|
- dev/tools/codespell/codespell-dict.txt
|
|
- -I
|
|
- dev/tools/codespell/codespell-ignore.txt
|
|
- -x
|
|
- dev/tools/codespell/codespell-lines-ignore.txt
|
|
exclude_types: [image]
|
|
exclude: (?x)^(.phan/stubs/.*|phpstan\.neon.*)$
|
|
additional_dependencies: [tomli]
|
|
- alias: codespell-lang-en_US
|
|
# Only for translations with specialised exceptions
|
|
# -D contains predefined conversion dictionaries
|
|
# -L is to ignore some words
|
|
id: codespell
|
|
files: ^htdocs/langs/en_US/.*$
|
|
args:
|
|
- -D
|
|
- "-"
|
|
- -D
|
|
- dev/tools/codespell/codespell-dict.txt
|
|
- -L
|
|
- informations,medias,uptodate,reenable,crypted,developpers
|
|
- -L
|
|
- creat,unitl,alltime,datas,referers
|
|
- -I
|
|
- dev/tools/codespell/codespell-ignore.txt
|
|
- -x
|
|
- dev/tools/codespell/codespell-lines-ignore.txt
|
|
- --uri-ignore-words-list
|
|
- ned
|
|
|
|
# Check some shell scripts
|
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
rev: v0.11.0.1
|
|
hooks:
|
|
- id: shellcheck
|
|
args: [-W, "100"]
|
|
|
|
# Check sql file syntax
|
|
- repo: https://github.com/sqlfluff/sqlfluff
|
|
rev: 3.3.1
|
|
hooks:
|
|
- id: sqlfluff-lint
|
|
stages: [pre-commit, manual] # manual needed for ci
|
|
exclude: (?x)^
|
|
(dev/initdemo/mysqldump_.*\.sql
|
|
|htdocs/core/menus/init_menu_auguria\.sql
|
|
|htdocs/includes/.*
|
|
|htdocs/install/doctemplates/websites/.*_template
|
|
|htdocs/install/doctemplates/websites/website_template.*\.sql
|
|
|htdocs/install/mysql/data/llx_20_c_departements\.sql
|
|
|htdocs/install/mysql/data/llx_accounting_account_.*\.sql
|
|
|htdocs/install/mysql/migration/3\..*\.sql
|
|
|htdocs/install/mysql/migration/(1[0-5]|[456789])\.0\.0-.*\.sql
|
|
|htdocs/install/mysql/migration/repair\.sql
|
|
|htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal\.sql
|
|
|htdocs/install/mysql/tables/llx_categorie.*\.key\.sql
|
|
|htdocs/install/mysql/tables/llx_rights_def\.key\.sql
|
|
|htdocs/install/pgsql/functions/functions.*\.sql
|
|
|htdocs/modulebuilder/template/sql/.*\.sql
|
|
)$
|
|
|
|
- repo: https://github.com/perltidy/perltidy
|
|
rev: '20250105.03'
|
|
hooks:
|
|
- id: perltidy
|
|
# virtualmin excuded - reason https://github.com/Dolibarr/dolibarr/pull/36370#issuecomment-3565101823
|
|
exclude: (?x)^
|
|
(dev/build/perl/virtualmin/dolibarr.pl
|
|
)$
|
|
args: [ --tabs, --nola ]
|
|
- repo: https://github.com/henryykt/pre-commit-perl
|
|
rev: v0.0.5
|
|
hooks:
|
|
- id: perlcritic
|
|
# virtualmin excuded - reason https://github.com/Dolibarr/dolibarr/pull/36370#issuecomment-3565101823
|
|
exclude: (?x)^
|
|
(dev/build/perl/virtualmin/dolibarr.pl
|
|
)$
|