Skip to content

chrysa/pre-commit-tools

Repository files navigation

pre-commit-tools

Some out-of-the-box hooks for pre-commit.

Using pre-commit-tools with pre-commit

Add this to your .pre-commit-config.yaml

-   repo: https://github.com/chrysa/pre-commit-tools
    rev: ''  # Use the ref you want to point at
    hooks:
          - id: console-debug-detection
          - id: console-log-detection
          - id: console-table-detection
          - id: format-dockerfiles
          - id: print-detection
          - id: pprint-detection
          - id: yaml-sorter
          - id: debugger-detection
          - id: json-sorter
          - id: requirements-sort
          - id: env-file-check
          - id: logger-detection

Hooks available

format-dockerfiles

Description

  • add shebang # syntax=docker/dockerfile:1.4 if missing
  • group consecutive same command without space
  • group consecutive RUN or ENV on one command line with new line

Todo

  • separate block for literal ARGS and ARGS composed with variable
  • order alphabetically ARGS
  • order alphabetically ENV
  • add config file support

python-print-detection

detect print on python code if is not commented or escaped with # print-detection: disable

python-pprint-detection

detect pprint on python code if is not commented or escaped with # pprint-detection: disable

[WIP] pylint-html-report

generate pylint html reports use --output-json to define json output and --output-html to specify html output use --output-json= to define json output and --output-html= to specify html output

yaml-sorter

Sort YAML file keys alphabetically (recursive). Modifies files in-place and returns 1 if any file was changed. Use # yaml-sorter: disable is not supported — simply exclude the file in your .pre-commit-config.yaml. use --output-json to define json output and --output-html to specify html output

debugger-detection

Detect debugger statements (breakpoint(), pdb.set_trace(), ipdb.set_trace(), pudb.set_trace()) in Python files. Use # debugger-detection: disable to ignore a specific line.

json-sorter

Sort JSON file keys alphabetically (recursive). Modifies files in-place and returns 1 if any file was changed.

requirements-sort

Sort requirements*.txt files alphabetically (comments and blank lines first, then packages sorted case-insensitively). Modifies files in-place and returns 1 if any file was changed.

env-file-check

Detect potential secrets committed in .env files (passwords, tokens, API keys, etc.). Placeholder values (<value>, ${VAR}, changeme, etc.) are ignored.

logger-detection

Detect direct use of the root logging module (e.g. logging.info(...)) instead of a named logger. Use # logger-detection: disable to ignore a specific line.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages