Document flake8-unused-arguments (#4147)
This commit is contained in:
@@ -16,6 +16,24 @@ use crate::checkers::ast::Checker;
|
||||
use super::helpers;
|
||||
use super::types::Argumentable;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for the presence of unused arguments in function definitions.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// An argument that is defined but not used is likely a mistake, and should
|
||||
/// be removed to avoid confusion.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// def foo(bar, baz):
|
||||
/// return bar * 2
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// def foo(bar):
|
||||
/// return bar * 2
|
||||
/// ```
|
||||
#[violation]
|
||||
pub struct UnusedFunctionArgument {
|
||||
pub name: String,
|
||||
@@ -29,6 +47,25 @@ impl Violation for UnusedFunctionArgument {
|
||||
}
|
||||
}
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for the presence of unused arguments in instance method definitions.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// An argument that is defined but not used is likely a mistake, and should
|
||||
/// be removed to avoid confusion.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// class MyClass:
|
||||
/// def my_method(self, arg1, arg2):
|
||||
/// print(arg1)
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// class MyClass:
|
||||
/// def my_method(self, arg1):
|
||||
/// ```
|
||||
#[violation]
|
||||
pub struct UnusedMethodArgument {
|
||||
pub name: String,
|
||||
@@ -42,6 +79,34 @@ impl Violation for UnusedMethodArgument {
|
||||
}
|
||||
}
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for the presence of unused arguments in class method definitions.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// An argument that is defined but not used is likely a mistake, and should
|
||||
/// be removed to avoid confusion.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// class MyClass:
|
||||
/// @classmethod
|
||||
/// def my_method(self, arg1, arg2):
|
||||
/// print(arg1)
|
||||
///
|
||||
/// def other_method(self):
|
||||
/// self.my_method("foo", "bar")
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// class MyClass:
|
||||
/// @classmethod
|
||||
/// def my_method(self, arg1):
|
||||
/// print(arg1)
|
||||
///
|
||||
/// def other_method(self):
|
||||
/// self.my_method("foo", "bar")
|
||||
/// ```
|
||||
#[violation]
|
||||
pub struct UnusedClassMethodArgument {
|
||||
pub name: String,
|
||||
@@ -55,6 +120,34 @@ impl Violation for UnusedClassMethodArgument {
|
||||
}
|
||||
}
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for the presence of unused arguments in static method definitions.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// An argument that is defined but not used is likely a mistake, and should
|
||||
/// be removed to avoid confusion.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// class MyClass:
|
||||
/// @staticmethod
|
||||
/// def my_static_method(self, arg1, arg2):
|
||||
/// print(arg1)
|
||||
///
|
||||
/// def other_method(self):
|
||||
/// self.my_static_method("foo", "bar")
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// class MyClass:
|
||||
/// @static
|
||||
/// def my_static_method(self, arg1):
|
||||
/// print(arg1)
|
||||
///
|
||||
/// def other_method(self):
|
||||
/// self.my_static_method("foo", "bar")
|
||||
/// ```
|
||||
#[violation]
|
||||
pub struct UnusedStaticMethodArgument {
|
||||
pub name: String,
|
||||
@@ -68,6 +161,25 @@ impl Violation for UnusedStaticMethodArgument {
|
||||
}
|
||||
}
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for the presence of unused arguments in lambda expression
|
||||
/// definitions.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// An argument that is defined but not used is likely a mistake, and should
|
||||
/// be removed to avoid confusion.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
/// my_list = [1, 2, 3, 4, 5]
|
||||
/// squares = map(lambda x, y: x**2, my_list)
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// my_list = [1, 2, 3, 4, 5]
|
||||
/// squares = map(lambda x: x**2, my_list)
|
||||
/// ```
|
||||
#[violation]
|
||||
pub struct UnusedLambdaArgument {
|
||||
pub name: String,
|
||||
|
||||
Reference in New Issue
Block a user