A flake8 plugin to enforce object calisthenics rule "keep entities small"
Project description
Flake8 Small Entities Plugin
flake8-small-entities
is a Flake8 plugin that encourages developers to write smaller, more manageable entities by enforcing the Object Calisthenics rule "Keep Entities Small." The plugin analyzes Python code to ensure functions, classes, and modules do not exceed predefined line limits.
Installation
To install flake8-small-entities
, use pip:
pip install flake8-small-entities
Usage
Once installed, the plugin will be automatically activated alongside Flake8. To analyze your project, simply run:
flake8 your_project_directory
Violations of the line limits for functions, classes, and modules will be flagged accordingly.
Configuration
The plugin allows customization of the maximum number of lines allowed for each entity type. You can specify these settings in your Flake8 configuration file or directly via command-line options.
Command-Line Options
--max-fn-lines
: Maximum number of lines in a function (default is 15)--max-class-lines
: Maximum number of lines in a class (default is 50)--max-module-lines
: Maximum number of lines in a module (default is 200)
Config File Example
You can also set these options in a .flake8
configuration file in your project root:
[flake8]
max-fn-lines = 20
max-class-lines = 60
max-module-lines = 300
Rules Enforced
- FSE100: Function has too many lines
- FSE101: Class has too many lines
- FSE102: Module has too many lines
Each rule will indicate where the entity exceeds the specified line count, helping developers to refactor code into smaller, more focused components.
Motivation
Adhering to the "Keep Entities Small" rule improves code readability, maintainability, and facilitates easier debugging and testing. Large entities often perform too many functions, making them difficult to understand and change.
Contributing
Contributions are welcome! If you have suggestions for improvements or encounter any issues, please open an issue or submit a pull request on our GitHub repository.
License
This plugin is distributed under the MIT License. The full license text is available in the LICENSE
file included with the source code.
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 Distribution
Built Distribution
Hashes for flake8_small_entities-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed63af9380a9098ad1baf4bf788542724f63dbd039120aa9f447fb0ccf4396df |
|
MD5 | e7152e2d0c5310afac5de8af49d16771 |
|
BLAKE2b-256 | 4fa2b37ddeb12fc0314281339ea76cd48fd96084067cbea1cfcdbf6c87ef835c |
Hashes for flake8_small_entities-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 326a6c028acbb038a6d29b5b49726ecef0788b95b9a1a40dac5ca9bdb704f61f |
|
MD5 | ad49e40151fadc4f1c5fc60bb121f0e6 |
|
BLAKE2b-256 | 4f777837036a0662e5d38b557dee26e83a0887e8c05cc5171edc98f4fd4249db |