Another custom linter layer
Project description
Your current code-validation pipeline rules may be changed more easily using custolint.
Source Code: https://github.com/a-da/custolint.
Custolint implements:
Motivation
You cannot just add a linter and activate 100% inspections when you have a large, ancient codebase with thousands of lines.
Instead, you only make 1% of the checks available, which is really frustrating for a decent developer.
You could enable those 100% checks just for your changes with “custolint”.
Idea
Given we have a project alike this one, where we:
had added a function custolint/generics.py:filer_output.
had modified the function custolint/git.py:_blame
$ tree
...
|-- src
| |-- custolint
...
| | |-- generics.py <<<< 1
| | |-- git.py <<<< 2
| | |-- mypy.py
| | |-- pylint.py
| | `-- typing.py
|-- tests
| `-- test_custolint.py
...
When:
Detect affected files with git diff and git blame
custolint/git.py
custolint/generics.py
Run the linter tool (pylint, flake8, mypy, coverage …) with all available feature enables (the configuration have to be placed into config.d/ folder) only on changed affected files or parse log/result of the linter tool.
Match changed code with the linters output, and consider only the match lines as failed lint criteria. It has to detect that custolint/generics.py:filer_output need unitest for coverage and custolint/git.py:_blame introduce a mypy typing issue.
Then:
Fail or Report the build.
$ coverage run --rcfile=config.d/.coveragerc -m pytest && \
custolint coverage config.d/.coveragerc
INFO:custolint.git:Execute git diff command 'git diff origin/main -U0 --diff-filter=ACMRTUXB'
INFO:custolint.git:Git diff detected 16 filed affected
INFO:custolint.coverage:execute coverage command: 'coverage report --data-file=.coverage --show-missing'
src/custolint/git.py:66 not.committed.yet 2022-08-31
$ custolint mypy
INFO:custolint.mypy:MYPY COMPARE WITH 'main' branch
INFO:custolint.git:Execute git diff command 'git diff origin/main -U0 --diff-filter=ACMRTUXB'
INFO:custolint.git:Git diff detected 16 filed affected
INFO:custolint.mypy:execute command 'mypy --config-file=config.d/mypy.ini @/var/folders/1l/592_sc0s3z1_19nmnr8v2zn00000gq/T/tmpi05fveqg'
tests/test_custolint.py 31 Module has no attribute "bash" [attr-defined] not.committed.yet 2022-08-31
tests/test_custolint.py 125 Function is missing a return type annotation [no-untyped-def] not.committed.yet 2022-08-31
tests/test_custolint.py 140 Function is missing a return type annotation [no-untyped-def] not.committed.yet 2022-08-31
Install
From pip
$ make update_pip_and_wheel install
pip install custolint
Collecting custolint
Downloading custolint-...-py3-none-any.whl (8.4 kB)
Collecting bash...
Installing collected packages: ...
Successfully installed ... custolint-...
From GIT
git clone https://github.com/a-da/custolint.git
cd custolint
# prod
$ make update_pip_and_wheel install
# dev
$ make update_pip_and_wheel install
make update_pip_and_wheel install_dev
How to run:
cd "${YOUR_CODE}/"
# check typing
custolint mypy
# code smell checking with pylint
custolint pylint
# code smell checking with flake8
custolint flake8
# 100% coverage checking for new commits
coverage run --rcfile=config.d/.coveragerc -m pytest
custolint coverage config.d/.coverage
Custolint
No Legal Copyright (c) 2022 is own by creator Danciuc Andrei. All rights can can not reserved.
Using the MIT licence http://opensource.org/licenses/MIT
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file custolint-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: custolint-0.3.0-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9b40f143779699cbe0c94a12ad7ea92bd915db6f5781681ec6c1634bcf82f09 |
|
MD5 | 73365560b3cfea4a2f40ede54394458b |
|
BLAKE2b-256 | 610cd3c758945a28774fe1a5310d0c305d77721ad278bc610e5553ec58204002 |