-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds categories to each of the checks, though there is no way to enable or disable checks based off of their category (yet).
- Loading branch information
Showing
38 changed files
with
175 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Categories | ||
|
||
Here is a list of the built-in categories in Refurb, and their meanings. | ||
|
||
## `builtin` | ||
|
||
Checks that have the `builtin` category cover a few different topics: | ||
|
||
* Built-in functions such as `print()`, `open()`, `str()`, and so on | ||
* Statements such as `del` | ||
* File system related operations such as `open()` and `readlines()` | ||
|
||
## `control-flow` | ||
|
||
These checks deal with the control flow of a program, such as optimizing usage | ||
of `return` and `continue`, removing `if` statements under certain conditions, | ||
and so on. | ||
|
||
## `contextlib` | ||
|
||
These checks are for the [contextlib](https://docs.python.org/3/library/contextlib.html) | ||
standard library module. | ||
|
||
## `dict` | ||
|
||
These checks cover: | ||
|
||
* Usage of `dict` objects | ||
* In some cases, objects supporting the [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping) protocol | ||
|
||
## `fstring` | ||
|
||
These checks relate to Python's [f-strings](https://fstring.help/). | ||
|
||
## `functools` | ||
|
||
These checks relate to the [functools](https://docs.python.org/3/library/functools.html) | ||
standard library module. | ||
|
||
## `iterable` | ||
|
||
These checks cover: | ||
|
||
* Iterable types such as `list` and `tuple` | ||
* Standard library objects which are commonly iterated over such as `dict` keys | ||
|
||
## `itertools` | ||
|
||
These checks relate to the [itertools](https://docs.python.org/3/library/itertools.html) | ||
standard library module. | ||
|
||
## `operator` | ||
|
||
These checks relate to the [operator](https://docs.python.org/3/library/operator.html) | ||
standard library module. | ||
|
||
## `logical` | ||
|
||
These checks relate to logical cleanups and optimizations, primarily in `if` statements, | ||
but also in boolean expressions. | ||
|
||
## `list` | ||
|
||
These checks cover usage of the built-in `list` object. | ||
|
||
## `pathlib` | ||
|
||
These checks relate to the [pathlib](https://docs.python.org/3/library/pathlib.html) | ||
standard library module. | ||
|
||
## `pythonic` | ||
|
||
This is a general catch-all for things which are "unpythonic". It differs from the | ||
`readability` category because "unreadable" code can still be pythonic. | ||
|
||
## `readability` | ||
|
||
These checks aim to make existing code more readable. This can be subjective, but in general, | ||
they reduce the horizontal or vertical length of your code, or make the underlying meaning | ||
of the code more apparent. | ||
|
||
## `scoping` | ||
|
||
These checks have to do with Python's scoping rules. For more info on how Python's scoping | ||
rules work, read [this article](https://realpython.com/python-scope-legb-rule/). | ||
|
||
## `string` | ||
|
||
These checks deal with usage of [`str`](https://docs.python.org/3/library/stdtypes.html#string-methods) | ||
objects in Python. | ||
|
||
## `set` | ||
|
||
These checks deal with usage of [`set`](https://docs.python.org/3/tutorial/datastructures.html#sets) | ||
objects in Python. | ||
|
||
## `truthy` | ||
|
||
These checks cover truthy and falsy operations in Python, primarily in the context of `assert` and `if` | ||
statements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 135 | ||
categories = ["dict"] | ||
|
||
|
||
def check( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 115 | ||
categories = ["iterable", "truthy"] | ||
|
||
|
||
CONTAINER_TYPES = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 123 | ||
categories = ["readability"] | ||
|
||
|
||
FUNC_NAMES = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 112 | ||
categories = ["pythonic", "readability"] | ||
|
||
|
||
FUNC_NAMES = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 118 | ||
categories = ["operator"] | ||
|
||
|
||
BINARY_OPERATORS = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 116 | ||
categories = ["builtin", "fstring"] | ||
|
||
|
||
FUNC_CONVERSIONS = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ class ErrorInfo(Error): | |
""" | ||
|
||
code = 119 | ||
categories = ["builtin", "fstring"] | ||
|
||
|
||
CONVERSIONS = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.