Skip to main content

A flake8 plugin to enforce object calisthenics rule "ONE level of indentation"

Project description

flake8-no-nesting

flake8-no-nesting is a plugin for Flake8 designed to enhance code readability and maintainability by enforcing the Object Calisthenics rule: "One Level of Indentation per Method." The plugin aims to detect and flag the use of nested control structures such as try, if, with, while, and for in Python code.

Installation

Install flake8-no-nesting via pip:

pip install flake8-no-nesting

Usage

After installation, flake8-no-nesting integrates seamlessly with Flake8. To run the plugin, execute Flake8 on your project directory:

flake8 your_project_directory

The plugin will analyze your code for any violations related to nested control structures.

Rules Enforced

  • FNN100 nested if found
  • FNN101 nested for loop found
  • FNN102 nested while loop found
  • FNN103 nested with found
  • FNN104 nested try found

Each violation will report the specific type of nesting and its location, helping you to refactor your code accordingly.

Configuration

No specific configuration is required to get started with flake8-no-nesting. However, you can customize the behavior of Flake8 via the .flake8 configuration file to ignore certain files or directories, or to adjust other Flake8 settings.

Example .flake8 configuration:

[flake8]
exclude = tests/*
max-line-length = 120

Motivation

This plugin supports the "One Level of Indentation per Method" rule from Object Calisthenics, which advocates for minimal indentation to improve code readability and reduce complexity. Following this rule helps in writing code that is easier to understand, test, and maintain.

Contributing

We welcome contributions to improve flake8-no-nesting. If you have suggestions or encounter bugs, please feel free to open an issue or submit a pull request.

License

flake8-no-nesting is distributed under the MIT License. See the LICENSE file for more details.

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_no_nesting-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

flake8_no_nesting-0.1.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file flake8_no_nesting-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for flake8_no_nesting-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a882053479f27f6d6488711b3f41fe98542965dca0953e3cd1322262b3ecbbe6
MD5 2cbba230232f81e92685675dd543d97a
BLAKE2b-256 9991da08a2022207314dc37fb34330c8f75f9e57582ec81e046d6a64801c2c56

See more details on using hashes here.

File details

Details for the file flake8_no_nesting-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_no_nesting-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8edd3564e0c8b803801a8e8c4d9f3345f41c0f16cd8579202ebbaf96974ca151
MD5 a27987989e89e5b887e073f375732567
BLAKE2b-256 d2b8bcdeef4bfd44a577c0165cf7dbd3761dc3971b1de6d260d60d87da3a38b6

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