Skip to content

Commit

Permalink
Update Pre-Commit hooks (#16983)
Browse files Browse the repository at this point in the history
Summary of the issue:
Continuing work on our pre-commit hooks, there are still several we don't use but could.

Description of user facing changes
None.

Description of development approach
Tested pre-commit hooks available at pre-commit/pre-commit-hooks. Added those that work as expected and do not require major changes to our code base. Added:

Automatic checking of yaml, toml and XML syntax
Checks that no Python debug statements are included in commits
Remove BOM on Python, C/C++ and Batch files, if present
Ensure that unit test files are named according to unittest rules.
Ensure that any include VCS links are permalinks.
  • Loading branch information
SaschaCowley authored Aug 12, 2024
1 parent 2e09be1 commit c8a847b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,60 @@ repos:
# Prevents commits to certain branches
- id: no-commit-to-branch
args: ["--branch", "master", "--branch", "beta", "--branch", "rc"]
# Checks that large files have not been added. Default cut-off for "large" files is 500kb.
- id: check-added-large-files
# POFiles and TTF fonts can't be made smaller
exclude_types: ["pofile", "ttf"]
# Same applies for NVDA dictionary (.dic) files and Spline Font Database (.SFD) files, but these aren't recognised by the Identify library.
exclude: "\\.(dic|sfd)$"
# Checks python syntax
- id: check-ast
# File uses encoding not supported in Linux
exclude: source/comInterfaces/_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py
# Checks for filenames that will conflict on case insensitive filesystems (the majority of Windows filesystems, most of the time)
- id: check-case-conflict
# Checks for artifacts from resolving merge conflicts.
- id: check-merge-conflict
# Checks Python files for debug statements, such as python's breakpoint function, or those inserted by some IDEs.
- id: debug-statements
# File uses encoding not supported in Linux
exclude: source/comInterfaces/_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py
# Removes trailing whitespace.
- id: trailing-whitespace
types_or: [python, c, c++, batch, markdown]
# Ensures all files end in 1 (and only 1) newline.
- id: end-of-file-fixer
types_or: [python, c, c++, batch, markdown]
# Removes the UTF-8 BOM from files that have it.
# See https://github.com/nvaccess/nvda/blob/master/projectDocs/dev/codingStandards.md#encoding
- id: fix-byte-order-marker
types_or: [python, c, c++, batch, markdown]
# Validates TOML files.
- id: check-toml
# Validates YAML files.
- id: check-yaml
# Validates XML files.
- id: check-xml
# Ensures that links to lines in files under version control point to a particular commit.
- id: check-vcs-permalinks
# Checks that tests are named test_*.py.
- id: name-tests-test
args: ["--unittest"]
# Exclude Python files under `tests/` that aren't unittest files.
# This is a Python verbose regular expression.
# See https://docs.python.org/3/library/re.html#re.VERBOSE
exclude: |
(?x)^tests/(
checkPot.py | # Doesn't use unittest
system | # Uses robot
unit/ (
# Test helpers
textProvider.py |
extensionPointTestHelpers.py |
objectProvider.py |
test_speechManager/speechManagerTestHarness.py
)
)
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
Expand Down

0 comments on commit c8a847b

Please sign in to comment.