Skip to main content

Another custom linter layer

Project description

Custolint logo

Your current code-validation pipeline rules may be changed more easily using custolint.

Documentation Python Code Coverage License

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.

You cannot just take and (Boromir meme)

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:

  1. had added a function custolint/generics.py:filer_output.

  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

custolint-0.2.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file custolint-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: custolint-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for custolint-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa5f35c6621cbdcd1c061f8b6e44aa5f4f06c051002533adfcb454657a5b5e17
MD5 42b28a86f8fb371b245b3d7746508635
BLAKE2b-256 ba5494e24457fbbed4e69941e5ad8558e823fea08c1ee64752fdd25e8b3b02ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page