Metadata-Version: 2.1
Name: refurb-plugin-example
Version: 1.0.0
Summary: An example plugin for Refurb
Home-page: https://github.com/dosisod/refurb-plugin-example
License: GPL-3.0-only
Author: dosisod
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Dist: refurb (==0.2.4)
Project-URL: Repository, https://github.com/dosisod/refurb-plugin-example
Description-Content-Type: text/markdown

# Refurb Plugin Example

This repo is meant to be a good starting point for those who are looking to
make plugins for Refurb.

For illustrative purposes, this plugin will emit an error when the following
`print` statement is found:

```python
print("Hello world!")
```

## Setup

First things first, fork this repo. Make sure to change the name, but keep
the `refurb-` prefix (for naming convention sake).

Next, clone:

```
$ git clone https://github.com/USERNAME/refurb-your-plugin
$ cd refurb-your-plugin
```

Of course, replacing `refurb-your-plugin` with the name you picked.

Then, update the `pyproject.toml` file with the your information.
You can run the `setup.sh` script to do this for you, which will ask you a series
of questions. If the script does not work, you will have to update it manually
(you should only need to update the first two sections).

## Check Discovery

In order for Refurb to find and use your check, 2 conditions must be met:

1. You must export a class that starts with `Error`, which will contain the error metadata. Note:
  * It must derive from `Error`
  * It cannot be named `ErrorCode`
2. You must have a function called `check`, which is the entry point for a given check.

The definition for a `check` function looks something like this:

```
def check(node: CallExpr, errors: list[Error]) -> None:
    ...
```

Where `CallExpr` is the node you want to accept, and `errors` is where you append an
error if one occurs. You can accept multiple node types using a type union, like so:

```
def check(node: UnaryExpr | OpExpr, errors: list[Error]) -> None:
    ...
```

This check will accept both unary and binary expressions.

Any nested folders must contain an `__init__.py` file. This might not be 100% necessary,
but from what I can tell, it is best to add it in anyways.

