An open API service indexing awesome lists of open source software.

https://github.com/snackattas/flake8-scout-rule

A Flake8 formatter that applies '# noqa: <errors>' annotations to the flake8 violations found, helping to incrementally improve code quality.
https://github.com/snackattas/flake8-scout-rule

flake8 flake8-extensions flake8-plugin linting python python3 qa quality scout-rule

Last synced: about 1 month ago
JSON representation

A Flake8 formatter that applies '# noqa: <errors>' annotations to the flake8 violations found, helping to incrementally improve code quality.

Awesome Lists containing this project

README

          

# Flake8 Scout Rule

[![PyPI version](https://badge.fury.io/py/flake8-scout-rule.svg)](https://badge.fury.io/py/flake8-scout-rule)
[![Unit Tests](https://github.com/snackattas/flake8-scout-rule/actions/workflows/test.yml/badge.svg)](https://github.com/snackattas/flake8-scout-rule/actions/workflows/test.yml)
[![codecov](https://codecov.io/github/snackattas/flake8-scout-rule/graph/badge.svg?token=0B7MI160C2)](https://codecov.io/github/snackattas/flake8-scout-rule)
![PyPI - Downloads](https://img.shields.io/pypi/dm/flake8-scout-rule)
![GitHub commit activity](https://img.shields.io/github/commit-activity/y/snackattas/flake8-scout-rule)

![sample usage](https://github.com/user-attachments/assets/93e0c654-0138-4bc2-81cb-9cefe10ceec9)

> The Scout Rule: Leave Your Code Better Than You Found It

We all strive to be good digital citizens, right? The Scout Rule is a simple idea: **always leave your code cleaner than you found it.**

But let's face it, dealing with legacy code can be a real pain. It might not follow best practices or have linting rules in place.

**Introducing the Flake8 Scout Rule!**

This handy tool is like a digital cleanup crew. It works in two steps:

1. **Finds the Mess**: It runs `flake8` to identify all the coding mistakes.
2. **Adds a Note**: It politely adds a `# noqa: ` comment next to each issue, basically saying, "Hey, future developer, this code needs some love."

**Why Use It?**

* **Gentle Introduction to New Linting Rules**: It doesn't force you to fix everything at once.
* **Teamwork Makes the Dream Work**: Your team can gradually clean up the code together.
* **Easy to Use**: No need to manually annotate files, this formatter is easy and does it for you.

**How It Works**:

1. **Configure Flake8**: Set up Flake8 with the rules you want to enforce.
2. **Run the Flake8 Scout Rule Formatter**: Let the Flake8 Scout Rule do its magic.
2. **Collaborate**: Agree with your team that whenever someone touches a file with those # noqa comments, they'll take a moment to fix the underlying issues, if it makes sense to do so.

By following this approach, you can gradually improve your codebase, one commit at a time.

# How to run

First install `flake8` and `flake8-scout-rule`
```commandline
pip install flake8 flake8-scout-rule
```

Then run `flake8-scout-rule` like this, as a flake8 formatter
```commandline
flake8 --format=scout .
```
*Note: The formatter is compatible with all valid Flake8 options. It is particularly beneficial to use this formatter with the `--select` and `--ignore` Flake8 options.*

### No prompt option
This option automatically update files with violations without prompting the user to review the violations.
```commandline
flake8 --format=scout --no-prompt .
```

# License
Free software: MIT License

# Credits
This package was created by Zach Attas aka [snackattas](https://github.com/snackattas), but couldn't have been possible without [flake8](https://github.com/PyCQA/flake8)!