Skip to main content

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


Download files

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

Source Distribution

flake8_small_entities-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_small_entities-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file flake8_small_entities-0.1.0.tar.gz.

File metadata

  • Download URL: flake8_small_entities-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for flake8_small_entities-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed63af9380a9098ad1baf4bf788542724f63dbd039120aa9f447fb0ccf4396df
MD5 e7152e2d0c5310afac5de8af49d16771
BLAKE2b-256 4fa2b37ddeb12fc0314281339ea76cd48fd96084067cbea1cfcdbf6c87ef835c

See more details on using hashes here.

File details

Details for the file flake8_small_entities-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_small_entities-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 326a6c028acbb038a6d29b5b49726ecef0788b95b9a1a40dac5ca9bdb704f61f
MD5 ad49e40151fadc4f1c5fc60bb121f0e6
BLAKE2b-256 4f777837036a0662e5d38b557dee26e83a0887e8c05cc5171edc98f4fd4249db

See more details on using hashes here.

Supported by

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