Plugin to lint various issues in code.
Project description
flake8-jungle
A flake8 plugin to detect bad practices in projects. This plugin is based on flake8-django.
Installation
Install from pip with:
$ pip install flake8-jungle
pre-commit example
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: ['flake8-jungle==VERSION']
args: ['--max-condition-complexity=8']
List of Rules
| Rule | Description | Configuration |
|---|---|---|
JG02 |
Do not use exclude attribute in ModelForm, list all items explicitly in fields attribute instead. |
|
JG04 |
Exceptions should never pass silently, add logging or comment at least. | |
JG05 |
Condition is too complex which makes it hard to understand. | --max-condition-complexity |
JG06 |
Function is too long. | --max-function-length |
JG07 |
Model is too long, split it into services, selectors, or utilities. | --max-model-length |
JG08 |
Function or method contains local imports, which should be mostly avoided. If you are trying to fix curcular dependency issues, the design probably has some flaws, you should consider refactoring instead. | |
JG10 |
Too much patching in tests. Consider changing your design to utilize Dependency Injection and fakes. | --max-patches-in-test |
JG11 |
Please use structlog and follow the correct logging style: logger.info("snake_case_message.with_dots", key="value"). |
The following rules are disabled by default:
| Rule | Description | Configuration |
|---|---|---|
JG01 |
The order of the model's inner classes, methods, and fields does not follow the Django Style Guide. | |
JG03 |
Avoid using null=True on string-based fields such as CharField and TextField. |
|
JG09 |
Incorrect logging format, please use the following syntax: logger.info("MESSAGE %(arg1)s", {"arg1": "value1"}). |
To enable optional rules you can use the --select parameter. It's default values are: E,F,W,C90.
For example, if you wanted to enable JG10, you could call flake8 in the following way:
flake8 --select=E,F,W,C90,JG,JG10
Testing
flake8-jungle uses pytest for tests. To run them use:
$ poetry install
$ poetry run pytest tests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8-jungle-1.0.7.tar.gz.
File metadata
- Download URL: flake8-jungle-1.0.7.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.2 Linux/5.15.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88f02fb6ad5b004efbd8ebf3ebf60e91bcfb2aeebd1e569f902f9ddf302c51f8
|
|
| MD5 |
0dba57f5a026886ceb18d91ffd4e5e0b
|
|
| BLAKE2b-256 |
503ab8a405d6e1def42f34539eb515a1dbe7b2dd1a6f7fc1e2f03a54a10f4714
|
File details
Details for the file flake8_jungle-1.0.7-py3-none-any.whl.
File metadata
- Download URL: flake8_jungle-1.0.7-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.2 Linux/5.15.0-1020-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51157ba0ea17428ef879b0f2151335852d876243b4a6d794f08077aa2177a924
|
|
| MD5 |
655ccb4701226c3104dcffcae1251ca1
|
|
| BLAKE2b-256 |
3ebe5056c0e0fdc98d18ee681ffa1f30d1a25648384ed203e1354418a5373879
|