1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

style: improve Makefile, stricter style rules

This commit is contained in:
matejcik 2019-05-06 18:03:41 +02:00
parent 43d080a30d
commit cf5df6b39b
3 changed files with 15 additions and 20 deletions

View File

@ -5,20 +5,26 @@ help: ## show this help
## style commands: ## style commands:
PY_FILES = $(shell find -type f -name '*.py' | grep -f ./tools/style.py.include | grep -v -f ./tools/style.py.exclude )
C_FILES = $(shell find -type f -name '*.[ch]' | grep -f ./tools/style.c.include | grep -v -f ./tools/style.c.exclude )
style_check: ## run code style check on application sources and tests style_check: ## run code style check on application sources and tests
flake8 --version flake8 --version
isort --version | awk '/VERSION/{print $$2}' isort --version | awk '/VERSION/{print $$2}'
black --version black --version
flake8 $(shell find -type f -name '*.py' | grep -f ./tools/style.py.include | grep -v -f ./tools/style.py.exclude ) flake8 $(PY_FILES)
isort --check-only $(shell find -type f -name '*.py' | grep -f ./tools/style.py.include | grep -v -f ./tools/style.py.exclude ) isort --check-only $(PY_FILES)
black --check $(shell find -type f -name '*.py' | grep -f ./tools/style.py.include | grep -v -f ./tools/style.py.exclude ) black --check $(PY_FILES)
make -C python style_check
style: ## apply code style on application sources and tests style: ## apply code style on application sources and tests
isort $(shell find -type f -name '*.py' | grep -f ./tools/style.py.include | grep -v -f ./tools/style.py.exclude ) isort $(PY_FILES)
black $(shell find -type f -name '*.py' | grep -f ./tools/style.py.include | grep -v -f ./tools/style.py.exclude ) black $(PY_FILES)
make -C python style
cstyle_check: ## run code style check on low-level C code cstyle_check: ## run code style check on low-level C code
./tools/clang-format-check $(shell find -type f -name '*.c' -o -name '*.h' | grep -f ./tools/style.c.include | grep -v -f ./tools/style.c.exclude ) ./tools/clang-format-check $(C_FILES)
cstyle: ## apply code style on low-level C code cstyle: ## apply code style on low-level C code
clang-format -i $(shell find -type f -name '*.c' -o -name '*.h' | grep -f ./tools/style.c.include | grep -v -f ./tools/style.c.exclude ) clang-format -i $(C_FILES)

View File

@ -12,10 +12,6 @@ ignore =
E501, E501,
# E741 ambiguous variable name # E741 ambiguous variable name
E741, E741,
# F403: star import used, unable to detect undefined names
F403,
# F405: name may be undefined, or defined from star imports
F405,
# W503: line break before binary operator # W503: line break before binary operator
W503 W503

View File

@ -12,10 +12,6 @@ ignore =
E501, E501,
# E741 ambiguous variable name # E741 ambiguous variable name
E741, E741,
# F403: star import used, unable to detect undefined names
F403,
# F405: name may be undefined, or defined from star imports
F405,
# W503: line break before binary operator # W503: line break before binary operator
W503 W503
@ -30,8 +26,5 @@ forced_separate = apps
known_standard_library = micropython,ubinascii,ustruct,uctypes,utime,utimeq,trezorio,trezorui,trezorutils,trezorconfig known_standard_library = micropython,ubinascii,ustruct,uctypes,utime,utimeq,trezorio,trezorui,trezorutils,trezorconfig
known_third_party = curve25519,ecdsa,hypothesis known_third_party = curve25519,ecdsa,hypothesis
# TODO: ask matejcik if we can omit this completely [tool:pytest]
# [tool:pytest] xfail_strict = true
# addopts = --pyargs trezorlib.tests.device_tests
# xfail_strict = true
# run_xfail =