Configurable flake8 plugin for maximum function length
Project description
flake8-max-function-length
A configurable flake8 plugin to enforce a maximum function/method length.
Installation
Install with pip
pip install flake8-max-function-length
Configuration Options
The package has only one rule MFL000
to check that function length is equal or lower to a maximum value.
By default, the function length should be lower than 50 lines and is calculated based on its content ignoring
its docstring, comments and empty lines. Still, you have the ability to customize that based on the following
options:
--max-function-length=n
: Maximum allowed function length. (Default: 50)--mfl-include-function-definition
: Include the function definition line(s) when calculating the function length. (Default: disabled)--mfl-include-docstring
: Include the length of the docstring when calculating the function length. (Default: disabled)--mfl-include-empty-lines
: Include empty lines inside the function when calculating the function length. (Default: disabled)--mfl-include-comment-lines
: Include comment lines when calculating the function length. (Default: disabled)
Usage with pre-commit
repos:
- repo: https://github.com/pycqa/flake8
rev: '6.0.0'
hooks:
- id: flake8
#args: [ --max-function-length, '100', --mfl-include-docstring, --mfl-include-comment-lines ]
additional_dependencies: [ "flake8-max-function-length==0.7.3" ]
Similar tools
- flake8-functions has a similar rule for maximum function length, however, it doesn't exclude for empty lines and comments.
- Pylint has the too-many-statements rule, which is also similar to this one. Still, I find it easier to reason about number of lines as opposed to number of statements.
License
This project is MIT licensed.
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
File details
Details for the file flake8-max-function-length-0.7.3.tar.gz
.
File metadata
- Download URL: flake8-max-function-length-0.7.3.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5d3ed68cfd3810aed5a9ab5016428e5bcc68737fc3669d60b74cfb3e6bcfa82 |
|
MD5 | e0126bee9db08b8ab981d461b4c41a45 |
|
BLAKE2b-256 | 1c12ec619f23ab2902a3dfdd38c655ab7df0fd232c33f294e0ce200e40478949 |
File details
Details for the file flake8_max_function_length-0.7.3-py3-none-any.whl
.
File metadata
- Download URL: flake8_max_function_length-0.7.3-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60d99fcdf5cf9a306848ea1bcfeaa7461afd683169129f694a5a4ad505cacc93 |
|
MD5 | b5541408f14d43a10ea0ae33af8aba0d |
|
BLAKE2b-256 | 214405949d57b50ead988ddecbd924d7a21f3c5e566112f1fde3b74f059d5a85 |