Add pre-commit configuration
'pre-commit' tool [1] provides an extensible way to configure hooks which can be run automatically before each commit. That way we can make sure that code send to review is passing base static analysis checks like e.g. bandit, flake8 or hacking. For now this is optional to use and not integrated in e.g. tox.ini file but we can integrate it there too as next step. [1] https://pre-commit.com/ Change-Id: I49efd39a93103d2e1888c9b641962280622ae60b
This commit is contained in:
parent
a0fb735b7e
commit
10ea6601c1
51
.pre-commit-config.yaml
Normal file
51
.pre-commit-config.yaml
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
default_language_version:
|
||||
# force all unspecified python hooks to run python3
|
||||
python: python3
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: mixed-line-ending
|
||||
args: ['--fix', 'lf']
|
||||
exclude: '.*\.(svg)$'
|
||||
- id: check-byte-order-marker
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-merge-conflict
|
||||
- id: debug-statements
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.7.5
|
||||
hooks:
|
||||
- id: bandit
|
||||
# B104: Possible binding to all interfaces
|
||||
# B303: Blacklist use of insecure MD2, MD4, MD5, or SHA1 hash functions
|
||||
# B311: Standard pseudo-random generators are not suitable for security/cryptographic purpose
|
||||
args: ['-n5', '-sB104,B303,B311']
|
||||
files: 'neutron_lib/'
|
||||
exclude: 'neutron_lib/tests'
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
rev: v1.5.4
|
||||
hooks:
|
||||
- id: remove-tabs
|
||||
exclude: '.*\.(svg)$'
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: flake8
|
||||
name: flake8
|
||||
additional_dependencies:
|
||||
- hacking>=6.1.0,<6.2.0
|
||||
- neutron
|
||||
language: python
|
||||
entry: flake8
|
||||
files: '^.*\.py$'
|
||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||
# TODO(slaweq): enable pylint check once all issues in the current code will
|
||||
# be solved
|
||||
# - id: pylint
|
||||
# name: pylint
|
||||
# entry: .tox/pep8/bin/pylint
|
||||
# files: ^neutron_lib/
|
||||
# language: system
|
||||
# types: [python]
|
||||
# args: ['--rcfile=.pylintrc', '--output-format=colorized']
|
@ -45,6 +45,7 @@ disable=
|
||||
unused-variable,
|
||||
useless-super-delegation,
|
||||
using-constant-test,
|
||||
redundant-u-string-prefix,
|
||||
# "C" Coding convention violations
|
||||
consider-iterating-dictionary,
|
||||
consider-using-enumerate,
|
||||
@ -75,6 +76,8 @@ disable=
|
||||
too-many-public-methods,
|
||||
too-many-return-statements,
|
||||
too-many-statements,
|
||||
use-dict-literal,
|
||||
super-with-arguments,
|
||||
# new for python3 version of pylint
|
||||
consider-using-set-comprehension,
|
||||
unnecessary-pass,
|
||||
|
@ -39,6 +39,12 @@ run_pylint () {
|
||||
|
||||
echo "Running pylint..."
|
||||
echo "You can speed this up by running it on 'HEAD~[0-9]' (e.g. HEAD~1, this change only)..."
|
||||
echo ""
|
||||
echo "Consider using the 'pre-commit' tool instead."
|
||||
echo ""
|
||||
echo " pip install --user pre-commit"
|
||||
echo " pre-commit install --allow-missing-config"
|
||||
echo ""
|
||||
if [ -n "${files}" ]; then
|
||||
pylint --rcfile=.pylintrc --output-format=colorized ${files}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user