Skip to main content

A flake8 plugin to enforce object calisthenics rule "one dot per line"

Project description

Flake8 One Dot Per Line Plugin

flake8-one-dot is a Flake8 plugin that enforces the Object Calisthenics principle of "One Dot Per Line" to promote better encapsulation and minimize the violation of the law of Demeter in Python code. It achieves this by flagging lines that contain multiple attribute accesses, which can indicate a code smell related to excessive knowledge of internal structures.

Installation

Install flake8-one-dot via pip:

pip install flake8-one-dot

Usage

After installation, the plugin will automatically be activated when you run Flake8:

flake8 your_project_directory

Any line with more than one dot will be reported as a violation, prompting a refactoring suggestion to improve encapsulation.

Configuration

flake8-one-dot does not require any specific configurations and works out-of-the-box with the default Flake8 settings.

Rules Enforced

  • FOD100: Too many dots per line (more than one dot found)

This rule helps developers recognize lines of code that may be overly reliant on object internals or chain multiple method calls in ways that could complicate future refactoring and maintenance.

Motivation

The "One Dot Per Line" rule helps maintain clean separation between objects and their internal data, encouraging methods to be short and ensuring that objects interact with each other through well-defined interfaces. This reduces coupling and enhances modularity, making the codebase easier to understand and maintain.

Contributing

We appreciate contributions from the community to make flake8-one-dot more effective or to fix potential bugs. If you have suggestions or want to contribute code, please feel free to fork the repository, make your changes, and submit a pull request.

License

This plugin is distributed under the MIT License. The full license text can be found 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_one_dot-0.1.3.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

flake8_one_dot-0.1.3-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file flake8_one_dot-0.1.3.tar.gz.

File metadata

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

File hashes

Hashes for flake8_one_dot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ed27c12d0b95b2c4beab80004083c7883eaaa87f6f32d31896112038fd3c6de6
MD5 779b983d021f334c09e2e902af55aff3
BLAKE2b-256 59615490a987bc4d9d4dad8d8a9cfb3349dc716dfeb2e9ff27af2a7e38a86c15

See more details on using hashes here.

File details

Details for the file flake8_one_dot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: flake8_one_dot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for flake8_one_dot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5c57b415c1c0833325ca5d401ce95962223978a8e508563d41cb3b8cd13ea273
MD5 96c70b3e2f2d831fecead49208197923
BLAKE2b-256 3dbabcae4e408542bc839d4c8fc3ec06870d7c73d156a0e2db1bfacec8f0d59e

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