A configurable flake8 plugin to enforce a maximum function/method 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.10.0" ]
Similar tools
- flake8-functions has a similar rule for maximum function length, however, it doesn't allow excluding 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
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_max_function_length-0.10.0.tar.gz.
File metadata
- Download URL: flake8_max_function_length-0.10.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd0984f36334be8428e92da98f72ff365494b97df74abbf49e296531043d8d14
|
|
| MD5 |
ed563567cff506709111fbc8f3e67f60
|
|
| BLAKE2b-256 |
5ad7f28938f5b1e5cf4b341f2fd69c6405370f1239f19dccc670bfd2b26f605d
|
File details
Details for the file flake8_max_function_length-0.10.0-py3-none-any.whl.
File metadata
- Download URL: flake8_max_function_length-0.10.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f93bb3e82fd63fe4a56205e6edc8c5270328ec60a1c9de331a94509cd2b1a2cc
|
|
| MD5 |
b6e29730feccf6cfee732237d56d0487
|
|
| BLAKE2b-256 |
adad90c0c377dbb66daaf158fe9d4678f9966f005103e0e58875026394a6e271
|