mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
Use a derive macro for Violations (#14557)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
6fd10e2fe7
commit
14ba469fc0
629 changed files with 2555 additions and 2562 deletions
|
@ -139,7 +139,7 @@ At a high level, the steps involved in adding a new lint rule are as follows:
|
||||||
1. Create a file for your rule (e.g., `crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs`).
|
1. Create a file for your rule (e.g., `crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs`).
|
||||||
|
|
||||||
1. In that file, define a violation struct (e.g., `pub struct AssertFalse`). You can grep for
|
1. In that file, define a violation struct (e.g., `pub struct AssertFalse`). You can grep for
|
||||||
`#[violation]` to see examples.
|
`#[derive(ViolationMetadata)]` to see examples.
|
||||||
|
|
||||||
1. In that file, define a function that adds the violation to the diagnostic list as appropriate
|
1. In that file, define a function that adds the violation to the diagnostic list as appropriate
|
||||||
(e.g., `pub(crate) fn assert_false`) based on whatever inputs are required for the rule (e.g.,
|
(e.g., `pub(crate) fn assert_false`) based on whatever inputs are required for the rule (e.g.,
|
||||||
|
|
36
clippy.toml
36
clippy.toml
|
@ -1,21 +1,25 @@
|
||||||
doc-valid-idents = [
|
doc-valid-idents = [
|
||||||
"..",
|
"..",
|
||||||
"CodeQL",
|
"CodeQL",
|
||||||
"FastAPI",
|
"FastAPI",
|
||||||
"IPython",
|
"IPython",
|
||||||
"LangChain",
|
"LangChain",
|
||||||
"LibCST",
|
"LibCST",
|
||||||
"McCabe",
|
"McCabe",
|
||||||
"NumPy",
|
"NumPy",
|
||||||
"SCREAMING_SNAKE_CASE",
|
"SCREAMING_SNAKE_CASE",
|
||||||
"SQLAlchemy",
|
"SQLAlchemy",
|
||||||
"StackOverflow",
|
"StackOverflow",
|
||||||
"PyCharm",
|
"PyCharm",
|
||||||
|
"SNMPv1",
|
||||||
|
"SNMPv2",
|
||||||
|
"SNMPv3",
|
||||||
|
"PyFlakes"
|
||||||
]
|
]
|
||||||
|
|
||||||
ignore-interior-mutability = [
|
ignore-interior-mutability = [
|
||||||
# Interned is read-only. The wrapped `Rc` never gets updated.
|
# Interned is read-only. The wrapped `Rc` never gets updated.
|
||||||
"ruff_formatter::format_element::Interned",
|
"ruff_formatter::format_element::Interned",
|
||||||
# The expression is read-only.
|
# The expression is read-only.
|
||||||
"ruff_python_ast::hashable::HashableExpr",
|
"ruff_python_ast::hashable::HashableExpr",
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,7 +2,7 @@ pub use diagnostic::{Diagnostic, DiagnosticKind};
|
||||||
pub use edit::Edit;
|
pub use edit::Edit;
|
||||||
pub use fix::{Applicability, Fix, IsolationLevel};
|
pub use fix::{Applicability, Fix, IsolationLevel};
|
||||||
pub use source_map::{SourceMap, SourceMarker};
|
pub use source_map::{SourceMap, SourceMarker};
|
||||||
pub use violation::{AlwaysFixableViolation, FixAvailability, Violation};
|
pub use violation::{AlwaysFixableViolation, FixAvailability, Violation, ViolationMetadata};
|
||||||
|
|
||||||
mod diagnostic;
|
mod diagnostic;
|
||||||
mod edit;
|
mod edit;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::DiagnosticKind;
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
@ -17,7 +18,16 @@ impl Display for FixAvailability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Violation: Debug + PartialEq + Eq {
|
pub trait ViolationMetadata {
|
||||||
|
/// Returns the rule name of this violation
|
||||||
|
fn rule_name() -> &'static str;
|
||||||
|
|
||||||
|
/// Returns an explanation of what this violation catches,
|
||||||
|
/// why it's bad, and what users should do instead.
|
||||||
|
fn explain() -> Option<&'static str>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Violation: ViolationMetadata {
|
||||||
/// `None` in the case a fix is never available or otherwise Some
|
/// `None` in the case a fix is never available or otherwise Some
|
||||||
/// [`FixAvailability`] describing the available fix.
|
/// [`FixAvailability`] describing the available fix.
|
||||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::None;
|
const FIX_AVAILABILITY: FixAvailability = FixAvailability::None;
|
||||||
|
@ -41,7 +51,7 @@ pub trait Violation: Debug + PartialEq + Eq {
|
||||||
|
|
||||||
/// This trait exists just to make implementing the [`Violation`] trait more
|
/// This trait exists just to make implementing the [`Violation`] trait more
|
||||||
/// convenient for violations that can always be fixed.
|
/// convenient for violations that can always be fixed.
|
||||||
pub trait AlwaysFixableViolation: Debug + PartialEq + Eq {
|
pub trait AlwaysFixableViolation: ViolationMetadata {
|
||||||
/// The message used to describe the violation.
|
/// The message used to describe the violation.
|
||||||
fn message(&self) -> String;
|
fn message(&self) -> String;
|
||||||
|
|
||||||
|
@ -69,3 +79,16 @@ impl<V: AlwaysFixableViolation> Violation for V {
|
||||||
<Self as AlwaysFixableViolation>::message_formats()
|
<Self as AlwaysFixableViolation>::message_formats()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> From<T> for DiagnosticKind
|
||||||
|
where
|
||||||
|
T: Violation,
|
||||||
|
{
|
||||||
|
fn from(value: T) -> Self {
|
||||||
|
Self {
|
||||||
|
body: Violation::message(&value),
|
||||||
|
suggestion: Violation::fix_title(&value),
|
||||||
|
name: T::rule_name().to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
|
@ -39,8 +39,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// dag = DAG(dag_id="my_dag", schedule=timedelta(days=1))
|
/// dag = DAG(dag_id="my_dag", schedule=timedelta(days=1))
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AirflowDagNoScheduleArgument;
|
pub(crate) struct AirflowDagNoScheduleArgument;
|
||||||
|
|
||||||
impl Violation for AirflowDagNoScheduleArgument {
|
impl Violation for AirflowDagNoScheduleArgument {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
|
@ -31,8 +31,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// my_task = PythonOperator(task_id="my_task")
|
/// my_task = PythonOperator(task_id="my_task")
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AirflowVariableNameTaskIdMismatch {
|
pub(crate) struct AirflowVariableNameTaskIdMismatch {
|
||||||
task_id: String,
|
task_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_trivia::CommentRanges;
|
use ruff_python_trivia::CommentRanges;
|
||||||
use ruff_source_file::{LineRanges, UniversalNewlineIterator};
|
use ruff_source_file::{LineRanges, UniversalNewlineIterator};
|
||||||
use ruff_text_size::TextRange;
|
use ruff_text_size::TextRange;
|
||||||
|
@ -29,8 +29,8 @@ use super::super::detection::comment_contains_code;
|
||||||
/// - `lint.task-tags`
|
/// - `lint.task-tags`
|
||||||
///
|
///
|
||||||
/// [#4845]: https://github.com/astral-sh/ruff/issues/4845
|
/// [#4845]: https://github.com/astral-sh/ruff/issues/4845
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct CommentedOutCode;
|
pub(crate) struct CommentedOutCode;
|
||||||
|
|
||||||
impl Violation for CommentedOutCode {
|
impl Violation for CommentedOutCode {
|
||||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::None;
|
const FIX_AVAILABILITY: FixAvailability = FixAvailability::None;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
|
@ -63,8 +63,8 @@ use crate::settings::types::PythonVersion;
|
||||||
/// [fastAPI documentation]: https://fastapi.tiangolo.com/tutorial/query-params-str-validations/?h=annotated#advantages-of-annotated
|
/// [fastAPI documentation]: https://fastapi.tiangolo.com/tutorial/query-params-str-validations/?h=annotated#advantages-of-annotated
|
||||||
/// [typing.Annotated]: https://docs.python.org/3/library/typing.html#typing.Annotated
|
/// [typing.Annotated]: https://docs.python.org/3/library/typing.html#typing.Annotated
|
||||||
/// [typing_extensions]: https://typing-extensions.readthedocs.io/en/stable/
|
/// [typing_extensions]: https://typing-extensions.readthedocs.io/en/stable/
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FastApiNonAnnotatedDependency {
|
pub(crate) struct FastApiNonAnnotatedDependency {
|
||||||
py_version: PythonVersion,
|
py_version: PythonVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{Decorator, Expr, ExprCall, Keyword, StmtFunctionDef};
|
use ruff_python_ast::{Decorator, Expr, ExprCall, Keyword, StmtFunctionDef};
|
||||||
use ruff_python_semantic::{Modules, SemanticModel};
|
use ruff_python_semantic::{Modules, SemanticModel};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -59,8 +59,8 @@ use crate::rules::fastapi::rules::is_fastapi_route_decorator;
|
||||||
/// return item
|
/// return item
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FastApiRedundantResponseModel;
|
pub(crate) struct FastApiRedundantResponseModel;
|
||||||
|
|
||||||
impl AlwaysFixableViolation for FastApiRedundantResponseModel {
|
impl AlwaysFixableViolation for FastApiRedundantResponseModel {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::str::CharIndices;
|
||||||
|
|
||||||
use ruff_diagnostics::Fix;
|
use ruff_diagnostics::Fix;
|
||||||
use ruff_diagnostics::{Diagnostic, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::{Expr, Parameter, ParameterWithDefault};
|
use ruff_python_ast::{Expr, Parameter, ParameterWithDefault};
|
||||||
use ruff_python_semantic::{Modules, SemanticModel};
|
use ruff_python_semantic::{Modules, SemanticModel};
|
||||||
|
@ -62,8 +62,8 @@ use crate::rules::fastapi::rules::is_fastapi_route_decorator;
|
||||||
/// ## Fix safety
|
/// ## Fix safety
|
||||||
/// This rule's fix is marked as unsafe, as modifying a function signature can
|
/// This rule's fix is marked as unsafe, as modifying a function signature can
|
||||||
/// change the behavior of the code.
|
/// change the behavior of the code.
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FastApiUnusedPathParameter {
|
pub(crate) struct FastApiUnusedPathParameter {
|
||||||
arg_name: String,
|
arg_name: String,
|
||||||
function_name: String,
|
function_name: String,
|
||||||
is_positional: bool,
|
is_positional: bool,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, CmpOp, Expr};
|
use ruff_python_ast::{self as ast, CmpOp, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ use super::super::helpers::is_sys;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionCmpStr3;
|
pub(crate) struct SysVersionCmpStr3;
|
||||||
|
|
||||||
impl Violation for SysVersionCmpStr3 {
|
impl Violation for SysVersionCmpStr3 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -87,8 +87,8 @@ impl Violation for SysVersionCmpStr3 {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionInfo0Eq3;
|
pub(crate) struct SysVersionInfo0Eq3;
|
||||||
|
|
||||||
impl Violation for SysVersionInfo0Eq3 {
|
impl Violation for SysVersionInfo0Eq3 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -127,8 +127,8 @@ impl Violation for SysVersionInfo0Eq3 {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionInfo1CmpInt;
|
pub(crate) struct SysVersionInfo1CmpInt;
|
||||||
|
|
||||||
impl Violation for SysVersionInfo1CmpInt {
|
impl Violation for SysVersionInfo1CmpInt {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -169,8 +169,8 @@ impl Violation for SysVersionInfo1CmpInt {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionInfoMinorCmpInt;
|
pub(crate) struct SysVersionInfoMinorCmpInt;
|
||||||
|
|
||||||
impl Violation for SysVersionInfoMinorCmpInt {
|
impl Violation for SysVersionInfoMinorCmpInt {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -212,8 +212,8 @@ impl Violation for SysVersionInfoMinorCmpInt {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionCmpStr10;
|
pub(crate) struct SysVersionCmpStr10;
|
||||||
|
|
||||||
impl Violation for SysVersionCmpStr10 {
|
impl Violation for SysVersionCmpStr10 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -35,8 +35,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [PyPI: `six`](https://pypi.org/project/six/)
|
/// - [PyPI: `six`](https://pypi.org/project/six/)
|
||||||
/// - [Six documentation: `six.PY2`](https://six.readthedocs.io/#six.PY2)
|
/// - [Six documentation: `six.PY2`](https://six.readthedocs.io/#six.PY2)
|
||||||
/// - [Six documentation: `six.PY3`](https://six.readthedocs.io/#six.PY3)
|
/// - [Six documentation: `six.PY3`](https://six.readthedocs.io/#six.PY3)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SixPY3;
|
pub(crate) struct SixPY3;
|
||||||
|
|
||||||
impl Violation for SixPY3 {
|
impl Violation for SixPY3 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ use crate::rules::flake8_2020::helpers::is_sys;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionSlice3;
|
pub(crate) struct SysVersionSlice3;
|
||||||
|
|
||||||
impl Violation for SysVersionSlice3 {
|
impl Violation for SysVersionSlice3 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -77,8 +77,8 @@ impl Violation for SysVersionSlice3 {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersion2;
|
pub(crate) struct SysVersion2;
|
||||||
|
|
||||||
impl Violation for SysVersion2 {
|
impl Violation for SysVersion2 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -117,8 +117,8 @@ impl Violation for SysVersion2 {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersion0;
|
pub(crate) struct SysVersion0;
|
||||||
|
|
||||||
impl Violation for SysVersion0 {
|
impl Violation for SysVersion0 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -157,8 +157,8 @@ impl Violation for SysVersion0 {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
/// - [Python documentation: `sys.version`](https://docs.python.org/3/library/sys.html#sys.version)
|
||||||
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
/// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SysVersionSlice1;
|
pub(crate) struct SysVersionSlice1;
|
||||||
|
|
||||||
impl Violation for SysVersionSlice1 {
|
impl Violation for SysVersionSlice1 {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::ReturnStatementVisitor;
|
use ruff_python_ast::helpers::ReturnStatementVisitor;
|
||||||
use ruff_python_ast::identifier::Identifier;
|
use ruff_python_ast::identifier::Identifier;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
|
@ -33,8 +33,8 @@ use crate::rules::ruff::typing::type_hint_resolves_to_any;
|
||||||
/// ```python
|
/// ```python
|
||||||
/// def foo(x: int): ...
|
/// def foo(x: int): ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingTypeFunctionArgument {
|
pub(crate) struct MissingTypeFunctionArgument {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ impl Violation for MissingTypeFunctionArgument {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// def foo(*args: int): ...
|
/// def foo(*args: int): ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingTypeArgs {
|
pub(crate) struct MissingTypeArgs {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ impl Violation for MissingTypeArgs {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// def foo(**kwargs: int): ...
|
/// def foo(**kwargs: int): ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingTypeKwargs {
|
pub(crate) struct MissingTypeKwargs {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +137,9 @@ impl Violation for MissingTypeKwargs {
|
||||||
/// class Foo:
|
/// class Foo:
|
||||||
/// def bar(self: "Foo"): ...
|
/// def bar(self: "Foo"): ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
#[deprecated(note = "ANN101 has been removed")]
|
#[deprecated(note = "ANN101 has been removed")]
|
||||||
pub struct MissingTypeSelf;
|
pub(crate) struct MissingTypeSelf;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
impl Violation for MissingTypeSelf {
|
impl Violation for MissingTypeSelf {
|
||||||
|
@ -181,9 +181,9 @@ impl Violation for MissingTypeSelf {
|
||||||
/// @classmethod
|
/// @classmethod
|
||||||
/// def bar(cls: Type["Foo"]): ...
|
/// def bar(cls: Type["Foo"]): ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
#[deprecated(note = "ANN102 has been removed")]
|
#[deprecated(note = "ANN102 has been removed")]
|
||||||
pub struct MissingTypeCls;
|
pub(crate) struct MissingTypeCls;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
impl Violation for MissingTypeCls {
|
impl Violation for MissingTypeCls {
|
||||||
|
@ -215,8 +215,8 @@ impl Violation for MissingTypeCls {
|
||||||
/// def add(a: int, b: int) -> int:
|
/// def add(a: int, b: int) -> int:
|
||||||
/// return a + b
|
/// return a + b
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingReturnTypeUndocumentedPublicFunction {
|
pub(crate) struct MissingReturnTypeUndocumentedPublicFunction {
|
||||||
name: String,
|
name: String,
|
||||||
annotation: Option<String>,
|
annotation: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -258,8 +258,8 @@ impl Violation for MissingReturnTypeUndocumentedPublicFunction {
|
||||||
/// def _add(a: int, b: int) -> int:
|
/// def _add(a: int, b: int) -> int:
|
||||||
/// return a + b
|
/// return a + b
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingReturnTypePrivateFunction {
|
pub(crate) struct MissingReturnTypePrivateFunction {
|
||||||
name: String,
|
name: String,
|
||||||
annotation: Option<String>,
|
annotation: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -314,8 +314,8 @@ impl Violation for MissingReturnTypePrivateFunction {
|
||||||
/// def __init__(self, x: int) -> None:
|
/// def __init__(self, x: int) -> None:
|
||||||
/// self.x = x
|
/// self.x = x
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingReturnTypeSpecialMethod {
|
pub(crate) struct MissingReturnTypeSpecialMethod {
|
||||||
name: String,
|
name: String,
|
||||||
annotation: Option<String>,
|
annotation: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -361,8 +361,8 @@ impl Violation for MissingReturnTypeSpecialMethod {
|
||||||
/// def bar() -> int:
|
/// def bar() -> int:
|
||||||
/// return 1
|
/// return 1
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingReturnTypeStaticMethod {
|
pub(crate) struct MissingReturnTypeStaticMethod {
|
||||||
name: String,
|
name: String,
|
||||||
annotation: Option<String>,
|
annotation: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -408,8 +408,8 @@ impl Violation for MissingReturnTypeStaticMethod {
|
||||||
/// def bar(cls) -> int:
|
/// def bar(cls) -> int:
|
||||||
/// return 1
|
/// return 1
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MissingReturnTypeClassMethod {
|
pub(crate) struct MissingReturnTypeClassMethod {
|
||||||
name: String,
|
name: String,
|
||||||
annotation: Option<String>,
|
annotation: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -474,8 +474,8 @@ impl Violation for MissingReturnTypeClassMethod {
|
||||||
/// - [Typing spec: `Any`](https://typing.readthedocs.io/en/latest/spec/special-types.html#any)
|
/// - [Typing spec: `Any`](https://typing.readthedocs.io/en/latest/spec/special-types.html#any)
|
||||||
/// - [Python documentation: `typing.Any`](https://docs.python.org/3/library/typing.html#typing.Any)
|
/// - [Python documentation: `typing.Any`](https://docs.python.org/3/library/typing.html#typing.Any)
|
||||||
/// - [Mypy documentation: The Any type](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#the-any-type)
|
/// - [Mypy documentation: The Any type](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#the-any-type)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AnyType {
|
pub(crate) struct AnyType {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, Stmt};
|
use ruff_python_ast::{self as ast, Expr, Stmt};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ use crate::rules::flake8_async::helpers::AsyncModule;
|
||||||
/// - [`asyncio` events](https://docs.python.org/3/library/asyncio-sync.html#asyncio.Event)
|
/// - [`asyncio` events](https://docs.python.org/3/library/asyncio-sync.html#asyncio.Event)
|
||||||
/// - [`anyio` events](https://trio.readthedocs.io/en/latest/reference-core.html#trio.Event)
|
/// - [`anyio` events](https://trio.readthedocs.io/en/latest/reference-core.html#trio.Event)
|
||||||
/// - [`trio` events](https://anyio.readthedocs.io/en/latest/api.html#anyio.Event)
|
/// - [`trio` events](https://anyio.readthedocs.io/en/latest/api.html#anyio.Event)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AsyncBusyWait {
|
pub(crate) struct AsyncBusyWait {
|
||||||
module: AsyncModule,
|
module: AsyncModule,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -8,6 +8,7 @@ use crate::checkers::ast::Checker;
|
||||||
use crate::rules::flake8_async::helpers::AsyncModule;
|
use crate::rules::flake8_async::helpers::AsyncModule;
|
||||||
use crate::settings::types::PythonVersion;
|
use crate::settings::types::PythonVersion;
|
||||||
|
|
||||||
|
#[allow(clippy::doc_link_with_quotes)]
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for `async` function definitions with `timeout` parameters.
|
/// Checks for `async` function definitions with `timeout` parameters.
|
||||||
///
|
///
|
||||||
|
@ -63,8 +64,8 @@ use crate::settings::types::PythonVersion;
|
||||||
/// - [`trio` timeouts](https://trio.readthedocs.io/en/stable/reference-core.html#cancellation-and-timeouts)
|
/// - [`trio` timeouts](https://trio.readthedocs.io/en/stable/reference-core.html#cancellation-and-timeouts)
|
||||||
///
|
///
|
||||||
/// ["structured concurrency"]: https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#timeouts-and-cancellation
|
/// ["structured concurrency"]: https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#timeouts-and-cancellation
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AsyncFunctionWithTimeout {
|
pub(crate) struct AsyncFunctionWithTimeout {
|
||||||
module: AsyncModule,
|
module: AsyncModule,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, ExprCall, Int, Number};
|
use ruff_python_ast::{self as ast, Expr, ExprCall, Int, Number};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -32,8 +32,8 @@ use crate::rules::flake8_async::helpers::AsyncModule;
|
||||||
/// async def func():
|
/// async def func():
|
||||||
/// await trio.lowlevel.checkpoint()
|
/// await trio.lowlevel.checkpoint()
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AsyncZeroSleep {
|
pub(crate) struct AsyncZeroSleep {
|
||||||
module: AsyncModule,
|
module: AsyncModule,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::ExprCall;
|
use ruff_python_ast::ExprCall;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::QualifiedName;
|
use ruff_python_ast::name::QualifiedName;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// async with session.get("https://example.com/foo/bar") as resp:
|
/// async with session.get("https://example.com/foo/bar") as resp:
|
||||||
/// ...
|
/// ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BlockingHttpCallInAsyncFunction;
|
pub(crate) struct BlockingHttpCallInAsyncFunction;
|
||||||
|
|
||||||
impl Violation for BlockingHttpCallInAsyncFunction {
|
impl Violation for BlockingHttpCallInAsyncFunction {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_python_semantic::{analyze, SemanticModel};
|
use ruff_python_semantic::{analyze, SemanticModel};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -33,8 +33,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// async with await anyio.open_file("bar.txt") as f:
|
/// async with await anyio.open_file("bar.txt") as f:
|
||||||
/// contents = await f.read()
|
/// contents = await f.read()
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BlockingOpenCallInAsyncFunction;
|
pub(crate) struct BlockingOpenCallInAsyncFunction;
|
||||||
|
|
||||||
impl Violation for BlockingOpenCallInAsyncFunction {
|
impl Violation for BlockingOpenCallInAsyncFunction {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
|
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_python_semantic::analyze::typing::find_assigned_value;
|
use ruff_python_semantic::analyze::typing::find_assigned_value;
|
||||||
use ruff_python_semantic::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
@ -30,8 +30,8 @@ use crate::registry::AsRule;
|
||||||
/// async def foo():
|
/// async def foo():
|
||||||
/// asyncio.create_subprocess_shell(cmd)
|
/// asyncio.create_subprocess_shell(cmd)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct CreateSubprocessInAsyncFunction;
|
pub(crate) struct CreateSubprocessInAsyncFunction;
|
||||||
|
|
||||||
impl Violation for CreateSubprocessInAsyncFunction {
|
impl Violation for CreateSubprocessInAsyncFunction {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -62,8 +62,8 @@ impl Violation for CreateSubprocessInAsyncFunction {
|
||||||
/// async def foo():
|
/// async def foo():
|
||||||
/// asyncio.create_subprocess_shell(cmd)
|
/// asyncio.create_subprocess_shell(cmd)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct RunProcessInAsyncFunction;
|
pub(crate) struct RunProcessInAsyncFunction;
|
||||||
|
|
||||||
impl Violation for RunProcessInAsyncFunction {
|
impl Violation for RunProcessInAsyncFunction {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -98,8 +98,8 @@ impl Violation for RunProcessInAsyncFunction {
|
||||||
/// async def foo():
|
/// async def foo():
|
||||||
/// await asyncio.loop.run_in_executor(None, wait_for_process)
|
/// await asyncio.loop.run_in_executor(None, wait_for_process)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct WaitForProcessInAsyncFunction;
|
pub(crate) struct WaitForProcessInAsyncFunction;
|
||||||
|
|
||||||
impl Violation for WaitForProcessInAsyncFunction {
|
impl Violation for WaitForProcessInAsyncFunction {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::ExprCall;
|
use ruff_python_ast::ExprCall;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::QualifiedName;
|
use ruff_python_ast::name::QualifiedName;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// async def fetch():
|
/// async def fetch():
|
||||||
/// await asyncio.sleep(1)
|
/// await asyncio.sleep(1)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BlockingSleepInAsyncFunction;
|
pub(crate) struct BlockingSleepInAsyncFunction;
|
||||||
|
|
||||||
impl Violation for BlockingSleepInAsyncFunction {
|
impl Violation for BlockingSleepInAsyncFunction {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::{any_over_body, AwaitVisitor};
|
use ruff_python_ast::helpers::{any_over_body, AwaitVisitor};
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_python_ast::{Expr, StmtWith, WithItem};
|
use ruff_python_ast::{Expr, StmtWith, WithItem};
|
||||||
|
@ -38,8 +38,8 @@ use crate::rules::flake8_async::helpers::MethodName;
|
||||||
/// - [`asyncio` timeouts](https://docs.python.org/3/library/asyncio-task.html#timeouts)
|
/// - [`asyncio` timeouts](https://docs.python.org/3/library/asyncio-task.html#timeouts)
|
||||||
/// - [`anyio` timeouts](https://anyio.readthedocs.io/en/stable/cancellation.html)
|
/// - [`anyio` timeouts](https://anyio.readthedocs.io/en/stable/cancellation.html)
|
||||||
/// - [`trio` timeouts](https://trio.readthedocs.io/en/stable/reference-core.html#cancellation-and-timeouts)
|
/// - [`trio` timeouts](https://trio.readthedocs.io/en/stable/reference-core.html#cancellation-and-timeouts)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct CancelScopeNoCheckpoint {
|
pub(crate) struct CancelScopeNoCheckpoint {
|
||||||
method_name: MethodName,
|
method_name: MethodName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{Expr, ExprCall, ExprNumberLiteral, Number};
|
use ruff_python_ast::{Expr, ExprCall, ExprNumberLiteral, Number};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -34,8 +34,8 @@ use crate::rules::flake8_async::helpers::AsyncModule;
|
||||||
/// async def func():
|
/// async def func():
|
||||||
/// await trio.sleep_forever()
|
/// await trio.sleep_forever()
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct LongSleepNotForever {
|
pub(crate) struct LongSleepNotForever {
|
||||||
module: AsyncModule,
|
module: AsyncModule,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{Expr, ExprCall};
|
use ruff_python_ast::{Expr, ExprCall};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
@ -31,8 +31,8 @@ use crate::rules::flake8_async::helpers::MethodName;
|
||||||
/// ## Fix safety
|
/// ## Fix safety
|
||||||
/// This rule's fix is marked as unsafe, as adding an `await` to a function
|
/// This rule's fix is marked as unsafe, as adding an `await` to a function
|
||||||
/// call changes its semantics and runtime behavior.
|
/// call changes its semantics and runtime behavior.
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct TrioSyncCall {
|
pub(crate) struct TrioSyncCall {
|
||||||
method_name: MethodName,
|
method_name: MethodName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::Stmt;
|
||||||
use ruff_text_size::{TextLen, TextRange};
|
use ruff_text_size::{TextLen, TextRange};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
|
@ -30,8 +30,8 @@ use ruff_text_size::Ranged;
|
||||||
/// if x <= 0:
|
/// if x <= 0:
|
||||||
/// raise ValueError("Expected positive value.")
|
/// raise ValueError("Expected positive value.")
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct Assert;
|
pub(crate) struct Assert;
|
||||||
|
|
||||||
impl Violation for Assert {
|
impl Violation for Assert {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::QualifiedName;
|
use ruff_python_ast::name::QualifiedName;
|
||||||
use ruff_python_ast::{self as ast, Expr, Operator};
|
use ruff_python_ast::{self as ast, Expr, Operator};
|
||||||
use ruff_python_semantic::{Modules, SemanticModel};
|
use ruff_python_semantic::{Modules, SemanticModel};
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [Python documentation: `os.chmod`](https://docs.python.org/3/library/os.html#os.chmod)
|
/// - [Python documentation: `os.chmod`](https://docs.python.org/3/library/os.html#os.chmod)
|
||||||
/// - [Python documentation: `stat`](https://docs.python.org/3/library/stat.html)
|
/// - [Python documentation: `stat`](https://docs.python.org/3/library/stat.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-732](https://cwe.mitre.org/data/definitions/732.html)
|
/// - [Common Weakness Enumeration: CWE-732](https://cwe.mitre.org/data/definitions/732.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BadFilePermissions {
|
pub(crate) struct BadFilePermissions {
|
||||||
reason: Reason,
|
reason: Reason,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, ExprAttribute};
|
use ruff_python_ast::{self as ast, Expr, ExprAttribute};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Django documentation: SQL injection protection](https://docs.djangoproject.com/en/dev/topics/security/#sql-injection-protection)
|
/// - [Django documentation: SQL injection protection](https://docs.djangoproject.com/en/dev/topics/security/#sql-injection-protection)
|
||||||
/// - [Common Weakness Enumeration: CWE-89](https://cwe.mitre.org/data/definitions/89.html)
|
/// - [Common Weakness Enumeration: CWE-89](https://cwe.mitre.org/data/definitions/89.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct DjangoExtra;
|
pub(crate) struct DjangoExtra;
|
||||||
|
|
||||||
impl Violation for DjangoExtra {
|
impl Violation for DjangoExtra {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -24,8 +24,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Django documentation: SQL injection protection](https://docs.djangoproject.com/en/dev/topics/security/#sql-injection-protection)
|
/// - [Django documentation: SQL injection protection](https://docs.djangoproject.com/en/dev/topics/security/#sql-injection-protection)
|
||||||
/// - [Common Weakness Enumeration: CWE-89](https://cwe.mitre.org/data/definitions/89.html)
|
/// - [Common Weakness Enumeration: CWE-89](https://cwe.mitre.org/data/definitions/89.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct DjangoRawSql;
|
pub(crate) struct DjangoRawSql;
|
||||||
|
|
||||||
impl Violation for DjangoRawSql {
|
impl Violation for DjangoRawSql {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -21,8 +21,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `exec`](https://docs.python.org/3/library/functions.html#exec)
|
/// - [Python documentation: `exec`](https://docs.python.org/3/library/functions.html#exec)
|
||||||
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ExecBuiltin;
|
pub(crate) struct ExecBuiltin;
|
||||||
|
|
||||||
impl Violation for ExecBuiltin {
|
impl Violation for ExecBuiltin {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::is_const_true;
|
use ruff_python_ast::helpers::is_const_true;
|
||||||
use ruff_python_ast::{Expr, ExprAttribute, ExprCall};
|
use ruff_python_ast::{Expr, ExprAttribute, ExprCall};
|
||||||
use ruff_python_semantic::analyze::typing;
|
use ruff_python_semantic::analyze::typing;
|
||||||
|
@ -36,8 +36,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Flask documentation: Debug Mode](https://flask.palletsprojects.com/en/latest/quickstart/#debug-mode)
|
/// - [Flask documentation: Debug Mode](https://flask.palletsprojects.com/en/latest/quickstart/#debug-mode)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FlaskDebugTrue;
|
pub(crate) struct FlaskDebugTrue;
|
||||||
|
|
||||||
impl Violation for FlaskDebugTrue {
|
impl Violation for FlaskDebugTrue {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, StringLike};
|
use ruff_python_ast::{self as ast, StringLike};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-200](https://cwe.mitre.org/data/definitions/200.html)
|
/// - [Common Weakness Enumeration: CWE-200](https://cwe.mitre.org/data/definitions/200.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HardcodedBindAllInterfaces;
|
pub(crate) struct HardcodedBindAllInterfaces;
|
||||||
|
|
||||||
impl Violation for HardcodedBindAllInterfaces {
|
impl Violation for HardcodedBindAllInterfaces {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{Expr, Parameter, ParameterWithDefault, Parameters};
|
use ruff_python_ast::{Expr, Parameter, ParameterWithDefault, Parameters};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -38,8 +38,8 @@ use super::super::helpers::{matches_password_name, string_literal};
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-259](https://cwe.mitre.org/data/definitions/259.html)
|
/// - [Common Weakness Enumeration: CWE-259](https://cwe.mitre.org/data/definitions/259.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HardcodedPasswordDefault {
|
pub(crate) struct HardcodedPasswordDefault {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::Keyword;
|
use ruff_python_ast::Keyword;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -34,8 +34,8 @@ use super::super::helpers::{matches_password_name, string_literal};
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-259](https://cwe.mitre.org/data/definitions/259.html)
|
/// - [Common Weakness Enumeration: CWE-259](https://cwe.mitre.org/data/definitions/259.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HardcodedPasswordFuncArg {
|
pub(crate) struct HardcodedPasswordFuncArg {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ use super::super::helpers::{matches_password_name, string_literal};
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-259](https://cwe.mitre.org/data/definitions/259.html)
|
/// - [Common Weakness Enumeration: CWE-259](https://cwe.mitre.org/data/definitions/259.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HardcodedPasswordString {
|
pub(crate) struct HardcodedPasswordString {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::LazyLock;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::str::raw_contents;
|
use ruff_python_ast::str::raw_contents;
|
||||||
use ruff_python_ast::{self as ast, Expr, Operator};
|
use ruff_python_ast::{self as ast, Expr, Operator};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -35,8 +35,8 @@ static SQL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [B608: Test for SQL injection](https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html)
|
/// - [B608: Test for SQL injection](https://bandit.readthedocs.io/en/latest/plugins/b608_hardcoded_sql_expressions.html)
|
||||||
/// - [psycopg3: Server-side binding](https://www.psycopg.org/psycopg3/docs/basic/from_pg2.html#server-side-binding)
|
/// - [psycopg3: Server-side binding](https://www.psycopg.org/psycopg3/docs/basic/from_pg2.html#server-side-binding)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HardcodedSQLExpression;
|
pub(crate) struct HardcodedSQLExpression;
|
||||||
|
|
||||||
impl Violation for HardcodedSQLExpression {
|
impl Violation for HardcodedSQLExpression {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::{self as ast, Expr, StringLike};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [Common Weakness Enumeration: CWE-377](https://cwe.mitre.org/data/definitions/377.html)
|
/// - [Common Weakness Enumeration: CWE-377](https://cwe.mitre.org/data/definitions/377.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-379](https://cwe.mitre.org/data/definitions/379.html)
|
/// - [Common Weakness Enumeration: CWE-379](https://cwe.mitre.org/data/definitions/379.html)
|
||||||
/// - [Python documentation: `tempfile`](https://docs.python.org/3/library/tempfile.html)
|
/// - [Python documentation: `tempfile`](https://docs.python.org/3/library/tempfile.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HardcodedTempFile {
|
pub(crate) struct HardcodedTempFile {
|
||||||
string: String,
|
string: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::is_const_false;
|
use ruff_python_ast::helpers::is_const_false;
|
||||||
use ruff_python_ast::{self as ast, Arguments};
|
use ruff_python_ast::{self as ast, Arguments};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -48,8 +48,8 @@ use super::super::helpers::string_literal;
|
||||||
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-328](https://cwe.mitre.org/data/definitions/328.html)
|
/// - [Common Weakness Enumeration: CWE-328](https://cwe.mitre.org/data/definitions/328.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-916](https://cwe.mitre.org/data/definitions/916.html)
|
/// - [Common Weakness Enumeration: CWE-916](https://cwe.mitre.org/data/definitions/916.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct HashlibInsecureHashFunction {
|
pub(crate) struct HashlibInsecureHashFunction {
|
||||||
library: String,
|
library: String,
|
||||||
string: String,
|
string: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Jinja documentation: API](https://jinja.palletsprojects.com/en/latest/api/#autoescaping)
|
/// - [Jinja documentation: API](https://jinja.palletsprojects.com/en/latest/api/#autoescaping)
|
||||||
/// - [Common Weakness Enumeration: CWE-94](https://cwe.mitre.org/data/definitions/94.html)
|
/// - [Common Weakness Enumeration: CWE-94](https://cwe.mitre.org/data/definitions/94.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct Jinja2AutoescapeFalse {
|
pub(crate) struct Jinja2AutoescapeFalse {
|
||||||
value: bool,
|
value: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -24,8 +24,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `logging.config.listen()`](https://docs.python.org/3/library/logging.config.html#logging.config.listen)
|
/// - [Python documentation: `logging.config.listen()`](https://docs.python.org/3/library/logging.config.html#logging.config.listen)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct LoggingConfigInsecureListen;
|
pub(crate) struct LoggingConfigInsecureListen;
|
||||||
|
|
||||||
impl Violation for LoggingConfigInsecureListen {
|
impl Violation for LoggingConfigInsecureListen {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ use ruff_text_size::Ranged;
|
||||||
/// - [Mako documentation](https://www.makotemplates.org/)
|
/// - [Mako documentation](https://www.makotemplates.org/)
|
||||||
/// - [OpenStack security: Cross site scripting XSS](https://security.openstack.org/guidelines/dg_cross-site-scripting-xss.html)
|
/// - [OpenStack security: Cross site scripting XSS](https://security.openstack.org/guidelines/dg_cross-site-scripting-xss.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-80](https://cwe.mitre.org/data/definitions/80.html)
|
/// - [Common Weakness Enumeration: CWE-80](https://cwe.mitre.org/data/definitions/80.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MakoTemplates;
|
pub(crate) struct MakoTemplates;
|
||||||
|
|
||||||
impl Violation for MakoTemplates {
|
impl Violation for MakoTemplates {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -25,8 +25,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
||||||
/// - [Paramiko documentation: `SSHClient.exec_command()`](https://docs.paramiko.org/en/stable/api/client.html#paramiko.client.SSHClient.exec_command)
|
/// - [Paramiko documentation: `SSHClient.exec_command()`](https://docs.paramiko.org/en/stable/api/client.html#paramiko.client.SSHClient.exec_command)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ParamikoCall;
|
pub(crate) struct ParamikoCall;
|
||||||
|
|
||||||
impl Violation for ParamikoCall {
|
impl Violation for ParamikoCall {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::helpers::is_const_false;
|
use ruff_python_ast::helpers::is_const_false;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -30,8 +30,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-295](https://cwe.mitre.org/data/definitions/295.html)
|
/// - [Common Weakness Enumeration: CWE-295](https://cwe.mitre.org/data/definitions/295.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct RequestWithNoCertValidation {
|
pub(crate) struct RequestWithNoCertValidation {
|
||||||
string: String,
|
string: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
|
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -32,8 +32,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Requests documentation: Timeouts](https://requests.readthedocs.io/en/latest/user/advanced/#timeouts)
|
/// - [Requests documentation: Timeouts](https://requests.readthedocs.io/en/latest/user/advanced/#timeouts)
|
||||||
/// - [httpx documentation: Timeouts](https://www.python-httpx.org/advanced/timeouts/)
|
/// - [httpx documentation: Timeouts](https://www.python-httpx.org/advanced/timeouts/)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct RequestWithoutTimeout {
|
pub(crate) struct RequestWithoutTimeout {
|
||||||
implicit: bool,
|
implicit: bool,
|
||||||
module: String,
|
module: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Checks relating to shell injection.
|
//! Checks relating to shell injection.
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::Truthiness;
|
use ruff_python_ast::helpers::Truthiness;
|
||||||
use ruff_python_ast::{self as ast, Arguments, Expr};
|
use ruff_python_ast::{self as ast, Arguments, Expr};
|
||||||
use ruff_python_semantic::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
@ -36,8 +36,8 @@ use crate::{
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `subprocess` — Subprocess management](https://docs.python.org/3/library/subprocess.html)
|
/// - [Python documentation: `subprocess` — Subprocess management](https://docs.python.org/3/library/subprocess.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SubprocessPopenWithShellEqualsTrue {
|
pub(crate) struct SubprocessPopenWithShellEqualsTrue {
|
||||||
safety: Safety,
|
safety: Safety,
|
||||||
is_exact: bool,
|
is_exact: bool,
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ impl Violation for SubprocessPopenWithShellEqualsTrue {
|
||||||
/// - [Python documentation: `subprocess` — Subprocess management](https://docs.python.org/3/library/subprocess.html)
|
/// - [Python documentation: `subprocess` — Subprocess management](https://docs.python.org/3/library/subprocess.html)
|
||||||
///
|
///
|
||||||
/// [#4045]: https://github.com/astral-sh/ruff/issues/4045
|
/// [#4045]: https://github.com/astral-sh/ruff/issues/4045
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SubprocessWithoutShellEqualsTrue;
|
pub(crate) struct SubprocessWithoutShellEqualsTrue;
|
||||||
|
|
||||||
impl Violation for SubprocessWithoutShellEqualsTrue {
|
impl Violation for SubprocessWithoutShellEqualsTrue {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -116,8 +116,8 @@ impl Violation for SubprocessWithoutShellEqualsTrue {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Security Considerations](https://docs.python.org/3/library/subprocess.html#security-considerations)
|
/// - [Python documentation: Security Considerations](https://docs.python.org/3/library/subprocess.html#security-considerations)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct CallWithShellEqualsTrue {
|
pub(crate) struct CallWithShellEqualsTrue {
|
||||||
is_exact: bool,
|
is_exact: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ impl Violation for CallWithShellEqualsTrue {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `subprocess`](https://docs.python.org/3/library/subprocess.html)
|
/// - [Python documentation: `subprocess`](https://docs.python.org/3/library/subprocess.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct StartProcessWithAShell {
|
pub(crate) struct StartProcessWithAShell {
|
||||||
safety: Safety,
|
safety: Safety,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +209,8 @@ impl Violation for StartProcessWithAShell {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [start-process-with-a-shell]: https://docs.astral.sh/ruff/rules/start-process-with-a-shell/#start-process-with-a-shell-s605
|
/// [start-process-with-a-shell]: https://docs.astral.sh/ruff/rules/start-process-with-a-shell/#start-process-with-a-shell-s605
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct StartProcessWithNoShell;
|
pub(crate) struct StartProcessWithNoShell;
|
||||||
|
|
||||||
impl Violation for StartProcessWithNoShell {
|
impl Violation for StartProcessWithNoShell {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -244,8 +244,8 @@ impl Violation for StartProcessWithNoShell {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `subprocess.Popen()`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)
|
/// - [Python documentation: `subprocess.Popen()`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)
|
||||||
/// - [Common Weakness Enumeration: CWE-426](https://cwe.mitre.org/data/definitions/426.html)
|
/// - [Common Weakness Enumeration: CWE-426](https://cwe.mitre.org/data/definitions/426.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct StartProcessWithPartialPath;
|
pub(crate) struct StartProcessWithPartialPath;
|
||||||
|
|
||||||
impl Violation for StartProcessWithPartialPath {
|
impl Violation for StartProcessWithPartialPath {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -277,8 +277,8 @@ impl Violation for StartProcessWithPartialPath {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
/// - [Common Weakness Enumeration: CWE-78](https://cwe.mitre.org/data/definitions/78.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UnixCommandWildcardInjection;
|
pub(crate) struct UnixCommandWildcardInjection;
|
||||||
|
|
||||||
impl Violation for UnixCommandWildcardInjection {
|
impl Violation for UnixCommandWildcardInjection {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, Int};
|
use ruff_python_ast::{self as ast, Expr, Int};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Cybersecurity and Infrastructure Security Agency (CISA): Alert TA17-156A](https://www.cisa.gov/news-events/alerts/2017/06/05/reducing-risk-snmp-abuse)
|
/// - [Cybersecurity and Infrastructure Security Agency (CISA): Alert TA17-156A](https://www.cisa.gov/news-events/alerts/2017/06/05/reducing-risk-snmp-abuse)
|
||||||
/// - [Common Weakness Enumeration: CWE-319](https://cwe.mitre.org/data/definitions/319.html)
|
/// - [Common Weakness Enumeration: CWE-319](https://cwe.mitre.org/data/definitions/319.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SnmpInsecureVersion;
|
pub(crate) struct SnmpInsecureVersion;
|
||||||
|
|
||||||
impl Violation for SnmpInsecureVersion {
|
impl Violation for SnmpInsecureVersion {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-319](https://cwe.mitre.org/data/definitions/319.html)
|
/// - [Common Weakness Enumeration: CWE-319](https://cwe.mitre.org/data/definitions/319.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SnmpWeakCryptography;
|
pub(crate) struct SnmpWeakCryptography;
|
||||||
|
|
||||||
impl Violation for SnmpWeakCryptography {
|
impl Violation for SnmpWeakCryptography {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use ruff_python_ast::{Expr, ExprAttribute, ExprCall};
|
use ruff_python_ast::{Expr, ExprAttribute, ExprCall};
|
||||||
use ruff_python_semantic::analyze::typing;
|
use ruff_python_semantic::analyze::typing;
|
||||||
|
@ -33,8 +33,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Paramiko documentation: set_missing_host_key_policy](https://docs.paramiko.org/en/latest/api/client.html#paramiko.client.SSHClient.set_missing_host_key_policy)
|
/// - [Paramiko documentation: set_missing_host_key_policy](https://docs.paramiko.org/en/latest/api/client.html#paramiko.client.SSHClient.set_missing_host_key_policy)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SSHNoHostKeyVerification;
|
pub(crate) struct SSHNoHostKeyVerification;
|
||||||
|
|
||||||
impl Violation for SSHNoHostKeyVerification {
|
impl Violation for SSHNoHostKeyVerification {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, ExprCall};
|
use ruff_python_ast::{self as ast, Expr, ExprCall};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2)
|
/// ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SslInsecureVersion {
|
pub(crate) struct SslInsecureVersion {
|
||||||
protocol: String,
|
protocol: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, StmtFunctionDef};
|
use ruff_python_ast::{self as ast, Expr, StmtFunctionDef};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// def func(version=ssl.PROTOCOL_TLSv1_2): ...
|
/// def func(version=ssl.PROTOCOL_TLSv1_2): ...
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SslWithBadDefaults {
|
pub(crate) struct SslWithBadDefaults {
|
||||||
protocol: String,
|
protocol: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::ExprCall;
|
use ruff_python_ast::ExprCall;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2)
|
/// ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SslWithNoVersion;
|
pub(crate) struct SslWithNoVersion;
|
||||||
|
|
||||||
impl Violation for SslWithNoVersion {
|
impl Violation for SslWithNoVersion {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! See: <https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html>
|
//! See: <https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html>
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
|
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Decorator, Expr, ExprCall, Operator};
|
use ruff_python_ast::{self as ast, Decorator, Expr, ExprCall, Operator};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ use crate::registry::AsRule;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `pickle` — Python object serialization](https://docs.python.org/3/library/pickle.html)
|
/// - [Python documentation: `pickle` — Python object serialization](https://docs.python.org/3/library/pickle.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-502](https://cwe.mitre.org/data/definitions/502.html)
|
/// - [Common Weakness Enumeration: CWE-502](https://cwe.mitre.org/data/definitions/502.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousPickleUsage;
|
pub(crate) struct SuspiciousPickleUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousPickleUsage {
|
impl Violation for SuspiciousPickleUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -91,8 +91,8 @@ impl Violation for SuspiciousPickleUsage {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `marshal` — Internal Python object serialization](https://docs.python.org/3/library/marshal.html)
|
/// - [Python documentation: `marshal` — Internal Python object serialization](https://docs.python.org/3/library/marshal.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-502](https://cwe.mitre.org/data/definitions/502.html)
|
/// - [Common Weakness Enumeration: CWE-502](https://cwe.mitre.org/data/definitions/502.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousMarshalUsage;
|
pub(crate) struct SuspiciousMarshalUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousMarshalUsage {
|
impl Violation for SuspiciousMarshalUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -137,8 +137,8 @@ impl Violation for SuspiciousMarshalUsage {
|
||||||
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-328](https://cwe.mitre.org/data/definitions/328.html)
|
/// - [Common Weakness Enumeration: CWE-328](https://cwe.mitre.org/data/definitions/328.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-916](https://cwe.mitre.org/data/definitions/916.html)
|
/// - [Common Weakness Enumeration: CWE-916](https://cwe.mitre.org/data/definitions/916.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousInsecureHashUsage;
|
pub(crate) struct SuspiciousInsecureHashUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousInsecureHashUsage {
|
impl Violation for SuspiciousInsecureHashUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -175,8 +175,8 @@ impl Violation for SuspiciousInsecureHashUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousInsecureCipherUsage;
|
pub(crate) struct SuspiciousInsecureCipherUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousInsecureCipherUsage {
|
impl Violation for SuspiciousInsecureCipherUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -215,8 +215,8 @@ impl Violation for SuspiciousInsecureCipherUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
/// - [Common Weakness Enumeration: CWE-327](https://cwe.mitre.org/data/definitions/327.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousInsecureCipherModeUsage;
|
pub(crate) struct SuspiciousInsecureCipherModeUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousInsecureCipherModeUsage {
|
impl Violation for SuspiciousInsecureCipherModeUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -260,8 +260,8 @@ impl Violation for SuspiciousInsecureCipherModeUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation:`mktemp`](https://docs.python.org/3/library/tempfile.html#tempfile.mktemp)
|
/// - [Python documentation:`mktemp`](https://docs.python.org/3/library/tempfile.html#tempfile.mktemp)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousMktempUsage;
|
pub(crate) struct SuspiciousMktempUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousMktempUsage {
|
impl Violation for SuspiciousMktempUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -296,8 +296,8 @@ impl Violation for SuspiciousMktempUsage {
|
||||||
/// - [Python documentation: `eval`](https://docs.python.org/3/library/functions.html#eval)
|
/// - [Python documentation: `eval`](https://docs.python.org/3/library/functions.html#eval)
|
||||||
/// - [Python documentation: `literal_eval`](https://docs.python.org/3/library/ast.html#ast.literal_eval)
|
/// - [Python documentation: `literal_eval`](https://docs.python.org/3/library/ast.html#ast.literal_eval)
|
||||||
/// - [_Eval really is dangerous_ by Ned Batchelder](https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html)
|
/// - [_Eval really is dangerous_ by Ned Batchelder](https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousEvalUsage;
|
pub(crate) struct SuspiciousEvalUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousEvalUsage {
|
impl Violation for SuspiciousEvalUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -335,8 +335,8 @@ impl Violation for SuspiciousEvalUsage {
|
||||||
/// - [Django documentation: `mark_safe`](https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.safestring.mark_safe)
|
/// - [Django documentation: `mark_safe`](https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.safestring.mark_safe)
|
||||||
/// - [Django documentation: Cross Site Scripting (XSS) protection](https://docs.djangoproject.com/en/dev/topics/security/#cross-site-scripting-xss-protection)
|
/// - [Django documentation: Cross Site Scripting (XSS) protection](https://docs.djangoproject.com/en/dev/topics/security/#cross-site-scripting-xss-protection)
|
||||||
/// - [Common Weakness Enumeration: CWE-80](https://cwe.mitre.org/data/definitions/80.html)
|
/// - [Common Weakness Enumeration: CWE-80](https://cwe.mitre.org/data/definitions/80.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousMarkSafeUsage;
|
pub(crate) struct SuspiciousMarkSafeUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousMarkSafeUsage {
|
impl Violation for SuspiciousMarkSafeUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -383,8 +383,8 @@ impl Violation for SuspiciousMarkSafeUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `urlopen`](https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen)
|
/// - [Python documentation: `urlopen`](https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousURLOpenUsage;
|
pub(crate) struct SuspiciousURLOpenUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousURLOpenUsage {
|
impl Violation for SuspiciousURLOpenUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -421,8 +421,8 @@ impl Violation for SuspiciousURLOpenUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `random` — Generate pseudo-random numbers](https://docs.python.org/3/library/random.html)
|
/// - [Python documentation: `random` — Generate pseudo-random numbers](https://docs.python.org/3/library/random.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousNonCryptographicRandomUsage;
|
pub(crate) struct SuspiciousNonCryptographicRandomUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousNonCryptographicRandomUsage {
|
impl Violation for SuspiciousNonCryptographicRandomUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -461,8 +461,8 @@ impl Violation for SuspiciousNonCryptographicRandomUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLCElementTreeUsage;
|
pub(crate) struct SuspiciousXMLCElementTreeUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLCElementTreeUsage {
|
impl Violation for SuspiciousXMLCElementTreeUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -501,8 +501,8 @@ impl Violation for SuspiciousXMLCElementTreeUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLElementTreeUsage;
|
pub(crate) struct SuspiciousXMLElementTreeUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLElementTreeUsage {
|
impl Violation for SuspiciousXMLElementTreeUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -541,8 +541,8 @@ impl Violation for SuspiciousXMLElementTreeUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLExpatReaderUsage;
|
pub(crate) struct SuspiciousXMLExpatReaderUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLExpatReaderUsage {
|
impl Violation for SuspiciousXMLExpatReaderUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -581,8 +581,8 @@ impl Violation for SuspiciousXMLExpatReaderUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLExpatBuilderUsage;
|
pub(crate) struct SuspiciousXMLExpatBuilderUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLExpatBuilderUsage {
|
impl Violation for SuspiciousXMLExpatBuilderUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -621,8 +621,8 @@ impl Violation for SuspiciousXMLExpatBuilderUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLSaxUsage;
|
pub(crate) struct SuspiciousXMLSaxUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLSaxUsage {
|
impl Violation for SuspiciousXMLSaxUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -661,8 +661,8 @@ impl Violation for SuspiciousXMLSaxUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLMiniDOMUsage;
|
pub(crate) struct SuspiciousXMLMiniDOMUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLMiniDOMUsage {
|
impl Violation for SuspiciousXMLMiniDOMUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -701,8 +701,8 @@ impl Violation for SuspiciousXMLMiniDOMUsage {
|
||||||
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
/// - [PyPI: `defusedxml`](https://pypi.org/project/defusedxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLPullDOMUsage;
|
pub(crate) struct SuspiciousXMLPullDOMUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLPullDOMUsage {
|
impl Violation for SuspiciousXMLPullDOMUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -730,8 +730,8 @@ impl Violation for SuspiciousXMLPullDOMUsage {
|
||||||
/// - [PyPI: `lxml`](https://pypi.org/project/lxml/)
|
/// - [PyPI: `lxml`](https://pypi.org/project/lxml/)
|
||||||
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
/// - [Common Weakness Enumeration: CWE-400](https://cwe.mitre.org/data/definitions/400.html)
|
||||||
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
/// - [Common Weakness Enumeration: CWE-776](https://cwe.mitre.org/data/definitions/776.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXMLETreeUsage;
|
pub(crate) struct SuspiciousXMLETreeUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousXMLETreeUsage {
|
impl Violation for SuspiciousXMLETreeUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -773,8 +773,8 @@ impl Violation for SuspiciousXMLETreeUsage {
|
||||||
/// - [Python documentation: `ssl` — TLS/SSL wrapper for socket objects](https://docs.python.org/3/library/ssl.html)
|
/// - [Python documentation: `ssl` — TLS/SSL wrapper for socket objects](https://docs.python.org/3/library/ssl.html)
|
||||||
///
|
///
|
||||||
/// [PEP 476]: https://peps.python.org/pep-0476/
|
/// [PEP 476]: https://peps.python.org/pep-0476/
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousUnverifiedContextUsage;
|
pub(crate) struct SuspiciousUnverifiedContextUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousUnverifiedContextUsage {
|
impl Violation for SuspiciousUnverifiedContextUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -794,8 +794,8 @@ impl Violation for SuspiciousUnverifiedContextUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `telnetlib` — Telnet client](https://docs.python.org/3/library/telnetlib.html)
|
/// - [Python documentation: `telnetlib` — Telnet client](https://docs.python.org/3/library/telnetlib.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousTelnetUsage;
|
pub(crate) struct SuspiciousTelnetUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousTelnetUsage {
|
impl Violation for SuspiciousTelnetUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -815,8 +815,8 @@ impl Violation for SuspiciousTelnetUsage {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `ftplib` — FTP protocol client](https://docs.python.org/3/library/ftplib.html)
|
/// - [Python documentation: `ftplib` — FTP protocol client](https://docs.python.org/3/library/ftplib.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousFTPLibUsage;
|
pub(crate) struct SuspiciousFTPLibUsage;
|
||||||
|
|
||||||
impl Violation for SuspiciousFTPLibUsage {
|
impl Violation for SuspiciousFTPLibUsage {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! See: <https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html>
|
//! See: <https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html>
|
||||||
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
|
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Stmt};
|
use ruff_python_ast::{self as ast, Stmt};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ use crate::registry::AsRule;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `telnetlib` - Telnet client](https://docs.python.org/3.12/library/telnetlib.html#module-telnetlib)
|
/// - [Python documentation: `telnetlib` - Telnet client](https://docs.python.org/3.12/library/telnetlib.html#module-telnetlib)
|
||||||
/// - [PEP 594: `telnetlib`](https://peps.python.org/pep-0594/#telnetlib)
|
/// - [PEP 594: `telnetlib`](https://peps.python.org/pep-0594/#telnetlib)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousTelnetlibImport;
|
pub(crate) struct SuspiciousTelnetlibImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousTelnetlibImport {
|
impl Violation for SuspiciousTelnetlibImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -49,8 +49,8 @@ impl Violation for SuspiciousTelnetlibImport {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `ftplib` - FTP protocol client](https://docs.python.org/3/library/ftplib.html)
|
/// - [Python documentation: `ftplib` - FTP protocol client](https://docs.python.org/3/library/ftplib.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousFtplibImport;
|
pub(crate) struct SuspiciousFtplibImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousFtplibImport {
|
impl Violation for SuspiciousFtplibImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -74,8 +74,8 @@ impl Violation for SuspiciousFtplibImport {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `pickle` — Python object serialization](https://docs.python.org/3/library/pickle.html)
|
/// - [Python documentation: `pickle` — Python object serialization](https://docs.python.org/3/library/pickle.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousPickleImport;
|
pub(crate) struct SuspiciousPickleImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousPickleImport {
|
impl Violation for SuspiciousPickleImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -95,8 +95,8 @@ impl Violation for SuspiciousPickleImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import subprocess
|
/// import subprocess
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousSubprocessImport;
|
pub(crate) struct SuspiciousSubprocessImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousSubprocessImport {
|
impl Violation for SuspiciousSubprocessImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -118,8 +118,8 @@ impl Violation for SuspiciousSubprocessImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import xml.etree.cElementTree
|
/// import xml.etree.cElementTree
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXmlEtreeImport;
|
pub(crate) struct SuspiciousXmlEtreeImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousXmlEtreeImport {
|
impl Violation for SuspiciousXmlEtreeImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -141,8 +141,8 @@ impl Violation for SuspiciousXmlEtreeImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import xml.sax
|
/// import xml.sax
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXmlSaxImport;
|
pub(crate) struct SuspiciousXmlSaxImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousXmlSaxImport {
|
impl Violation for SuspiciousXmlSaxImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -164,8 +164,8 @@ impl Violation for SuspiciousXmlSaxImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import xml.dom.expatbuilder
|
/// import xml.dom.expatbuilder
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXmlExpatImport;
|
pub(crate) struct SuspiciousXmlExpatImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousXmlExpatImport {
|
impl Violation for SuspiciousXmlExpatImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -187,8 +187,8 @@ impl Violation for SuspiciousXmlExpatImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import xml.dom.minidom
|
/// import xml.dom.minidom
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXmlMinidomImport;
|
pub(crate) struct SuspiciousXmlMinidomImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousXmlMinidomImport {
|
impl Violation for SuspiciousXmlMinidomImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -210,8 +210,8 @@ impl Violation for SuspiciousXmlMinidomImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import xml.dom.pulldom
|
/// import xml.dom.pulldom
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXmlPulldomImport;
|
pub(crate) struct SuspiciousXmlPulldomImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousXmlPulldomImport {
|
impl Violation for SuspiciousXmlPulldomImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -240,8 +240,8 @@ impl Violation for SuspiciousXmlPulldomImport {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [deprecated]: https://github.com/tiran/defusedxml/blob/c7445887f5e1bcea470a16f61369d29870cfcfe1/README.md#defusedxmllxml
|
/// [deprecated]: https://github.com/tiran/defusedxml/blob/c7445887f5e1bcea470a16f61369d29870cfcfe1/README.md#defusedxmllxml
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousLxmlImport;
|
pub(crate) struct SuspiciousLxmlImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousLxmlImport {
|
impl Violation for SuspiciousLxmlImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -263,8 +263,8 @@ impl Violation for SuspiciousLxmlImport {
|
||||||
/// ```python
|
/// ```python
|
||||||
/// import xmlrpc
|
/// import xmlrpc
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousXmlrpcImport;
|
pub(crate) struct SuspiciousXmlrpcImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousXmlrpcImport {
|
impl Violation for SuspiciousXmlrpcImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -289,8 +289,8 @@ impl Violation for SuspiciousXmlrpcImport {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [httpoxy website](https://httpoxy.org/)
|
/// - [httpoxy website](https://httpoxy.org/)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousHttpoxyImport;
|
pub(crate) struct SuspiciousHttpoxyImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousHttpoxyImport {
|
impl Violation for SuspiciousHttpoxyImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -314,8 +314,8 @@ impl Violation for SuspiciousHttpoxyImport {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Buffer Overflow Issue](https://github.com/pycrypto/pycrypto/issues/176)
|
/// - [Buffer Overflow Issue](https://github.com/pycrypto/pycrypto/issues/176)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousPycryptoImport;
|
pub(crate) struct SuspiciousPycryptoImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousPycryptoImport {
|
impl Violation for SuspiciousPycryptoImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
@ -339,8 +339,8 @@ impl Violation for SuspiciousPycryptoImport {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Buffer Overflow Issue](https://github.com/pycrypto/pycrypto/issues/176)
|
/// - [Buffer Overflow Issue](https://github.com/pycrypto/pycrypto/issues/176)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SuspiciousPyghmiImport;
|
pub(crate) struct SuspiciousPyghmiImport;
|
||||||
|
|
||||||
impl Violation for SuspiciousPyghmiImport {
|
impl Violation for SuspiciousPyghmiImport {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use ruff_diagnostics::Diagnostic;
|
use ruff_diagnostics::Diagnostic;
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -37,8 +37,8 @@ use ruff_text_size::Ranged;
|
||||||
/// - [Python documentation: Extraction filters](https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter)
|
/// - [Python documentation: Extraction filters](https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter)
|
||||||
///
|
///
|
||||||
/// [PEP 706]: https://peps.python.org/pep-0706/#backporting-forward-compatibility
|
/// [PEP 706]: https://peps.python.org/pep-0706/#backporting-forward-compatibility
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct TarfileUnsafeMembers;
|
pub(crate) struct TarfileUnsafeMembers;
|
||||||
|
|
||||||
impl Violation for TarfileUnsafeMembers {
|
impl Violation for TarfileUnsafeMembers {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{ExceptHandler, Expr, Stmt};
|
use ruff_python_ast::{ExceptHandler, Expr, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -41,8 +41,8 @@ use crate::rules::flake8_bandit::helpers::is_untyped_exception;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-703](https://cwe.mitre.org/data/definitions/703.html)
|
/// - [Common Weakness Enumeration: CWE-703](https://cwe.mitre.org/data/definitions/703.html)
|
||||||
/// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html)
|
/// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct TryExceptContinue;
|
pub(crate) struct TryExceptContinue;
|
||||||
|
|
||||||
impl Violation for TryExceptContinue {
|
impl Violation for TryExceptContinue {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{ExceptHandler, Expr, Stmt};
|
use ruff_python_ast::{ExceptHandler, Expr, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -37,8 +37,8 @@ use crate::rules::flake8_bandit::helpers::is_untyped_exception;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Common Weakness Enumeration: CWE-703](https://cwe.mitre.org/data/definitions/703.html)
|
/// - [Common Weakness Enumeration: CWE-703](https://cwe.mitre.org/data/definitions/703.html)
|
||||||
/// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html)
|
/// - [Python documentation: `logging`](https://docs.python.org/3/library/logging.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct TryExceptPass;
|
pub(crate) struct TryExceptPass;
|
||||||
|
|
||||||
impl Violation for TryExceptPass {
|
impl Violation for TryExceptPass {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PyYAML documentation: Loading YAML](https://pyyaml.org/wiki/PyYAMLDocumentation)
|
/// - [PyYAML documentation: Loading YAML](https://pyyaml.org/wiki/PyYAMLDocumentation)
|
||||||
/// - [Common Weakness Enumeration: CWE-20](https://cwe.mitre.org/data/definitions/20.html)
|
/// - [Common Weakness Enumeration: CWE-20](https://cwe.mitre.org/data/definitions/20.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UnsafeYAMLLoad {
|
pub(crate) struct UnsafeYAMLLoad {
|
||||||
pub loader: Option<String>,
|
pub loader: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, ExprAttribute, ExprCall};
|
use ruff_python_ast::{self as ast, Expr, ExprAttribute, ExprCall};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [CSRC: Transitioning the Use of Cryptographic Algorithms and Key Lengths](https://csrc.nist.gov/pubs/sp/800/131/a/r2/final)
|
/// - [CSRC: Transitioning the Use of Cryptographic Algorithms and Key Lengths](https://csrc.nist.gov/pubs/sp/800/131/a/r2/final)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct WeakCryptographicKey {
|
pub(crate) struct WeakCryptographicKey {
|
||||||
cryptographic_key: CryptographicKey,
|
cryptographic_key: CryptographicKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::is_const_true;
|
use ruff_python_ast::helpers::is_const_true;
|
||||||
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
|
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
|
||||||
use ruff_python_ast::{self as ast, Expr, Stmt};
|
use ruff_python_ast::{self as ast, Expr, Stmt};
|
||||||
|
@ -61,8 +61,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
|
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
|
||||||
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
|
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
|
||||||
/// - [PEP 8: Programming Recommendations on bare `except`](https://peps.python.org/pep-0008/#programming-recommendations)
|
/// - [PEP 8: Programming Recommendations on bare `except`](https://peps.python.org/pep-0008/#programming-recommendations)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BlindExcept {
|
pub(crate) struct BlindExcept {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::UnqualifiedName;
|
use ruff_python_ast::name::UnqualifiedName;
|
||||||
use ruff_python_ast::{Decorator, ParameterWithDefault, Parameters};
|
use ruff_python_ast::{Decorator, ParameterWithDefault, Parameters};
|
||||||
use ruff_python_semantic::analyze::visibility;
|
use ruff_python_semantic::analyze::visibility;
|
||||||
|
@ -89,8 +89,8 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
|
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
|
||||||
/// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/)
|
/// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BooleanDefaultValuePositionalArgument;
|
pub(crate) struct BooleanDefaultValuePositionalArgument;
|
||||||
|
|
||||||
impl Violation for BooleanDefaultValuePositionalArgument {
|
impl Violation for BooleanDefaultValuePositionalArgument {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ use crate::rules::flake8_boolean_trap::helpers::allow_boolean_trap;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
|
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
|
||||||
/// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/)
|
/// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BooleanPositionalValueInCall;
|
pub(crate) struct BooleanPositionalValueInCall;
|
||||||
|
|
||||||
impl Violation for BooleanPositionalValueInCall {
|
impl Violation for BooleanPositionalValueInCall {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use ruff_diagnostics::Diagnostic;
|
use ruff_diagnostics::Diagnostic;
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::UnqualifiedName;
|
use ruff_python_ast::name::UnqualifiedName;
|
||||||
use ruff_python_ast::{self as ast, Decorator, Expr, ParameterWithDefault, Parameters};
|
use ruff_python_ast::{self as ast, Decorator, Expr, ParameterWithDefault, Parameters};
|
||||||
use ruff_python_semantic::analyze::visibility;
|
use ruff_python_semantic::analyze::visibility;
|
||||||
|
@ -98,8 +98,8 @@ use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def;
|
||||||
/// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/)
|
/// - [_How to Avoid “The Boolean Trap”_ by Adam Johnson](https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/)
|
||||||
///
|
///
|
||||||
/// [preview]: https://docs.astral.sh/ruff/preview/
|
/// [preview]: https://docs.astral.sh/ruff/preview/
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BooleanTypeHintPositionalArgument;
|
pub(crate) struct BooleanTypeHintPositionalArgument;
|
||||||
|
|
||||||
impl Violation for BooleanTypeHintPositionalArgument {
|
impl Violation for BooleanTypeHintPositionalArgument {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Arguments, Expr, Keyword, Stmt};
|
use ruff_python_ast::{self as ast, Arguments, Expr, Keyword, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::identifier::Identifier;
|
use ruff_python_ast::identifier::Identifier;
|
||||||
use ruff_python_semantic::analyze::visibility::{is_abstract, is_overload};
|
use ruff_python_semantic::analyze::visibility::{is_abstract, is_overload};
|
||||||
use ruff_python_semantic::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
@ -53,8 +53,8 @@ use crate::registry::Rule;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `abc`](https://docs.python.org/3/library/abc.html)
|
/// - [Python documentation: `abc`](https://docs.python.org/3/library/abc.html)
|
||||||
/// - [Python documentation: `typing.ClassVar`](https://docs.python.org/3/library/typing.html#typing.ClassVar)
|
/// - [Python documentation: `typing.ClassVar`](https://docs.python.org/3/library/typing.html#typing.ClassVar)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AbstractBaseClassWithoutAbstractMethod {
|
pub(crate) struct AbstractBaseClassWithoutAbstractMethod {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ impl Violation for AbstractBaseClassWithoutAbstractMethod {
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `abc`](https://docs.python.org/3/library/abc.html)
|
/// - [Python documentation: `abc`](https://docs.python.org/3/library/abc.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct EmptyMethodWithoutAbstractDecorator {
|
pub(crate) struct EmptyMethodWithoutAbstractDecorator {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Stmt};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::is_const_false;
|
use ruff_python_ast::helpers::is_const_false;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `assert`](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
|
/// - [Python documentation: `assert`](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AssertFalse;
|
pub(crate) struct AssertFalse;
|
||||||
|
|
||||||
impl AlwaysFixableViolation for AssertFalse {
|
impl AlwaysFixableViolation for AssertFalse {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr, WithItem};
|
use ruff_python_ast::{self as ast, Expr, WithItem};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```python
|
/// ```python
|
||||||
/// self.assertRaises(SomeSpecificException, foo)
|
/// self.assertRaises(SomeSpecificException, foo)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AssertRaisesException {
|
pub(crate) struct AssertRaisesException {
|
||||||
assertion: AssertionKind,
|
assertion: AssertionKind,
|
||||||
exception: ExceptionKind,
|
exception: ExceptionKind,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -39,8 +39,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `os.environ`](https://docs.python.org/3/library/os.html#os.environ)
|
/// - [Python documentation: `os.environ`](https://docs.python.org/3/library/os.html#os.environ)
|
||||||
/// - [Python documentation: `subprocess.Popen`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)
|
/// - [Python documentation: `subprocess.Popen`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct AssignmentToOsEnviron;
|
pub(crate) struct AssignmentToOsEnviron;
|
||||||
|
|
||||||
impl Violation for AssignmentToOsEnviron {
|
impl Violation for AssignmentToOsEnviron {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::map_callable;
|
use ruff_python_ast::helpers::map_callable;
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_python_semantic::analyze::{class, function_type};
|
use ruff_python_semantic::analyze::{class, function_type};
|
||||||
|
@ -62,8 +62,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [Python documentation: `functools.lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache)
|
/// - [Python documentation: `functools.lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache)
|
||||||
/// - [Python documentation: `functools.cache`](https://docs.python.org/3/library/functools.html#functools.cache)
|
/// - [Python documentation: `functools.cache`](https://docs.python.org/3/library/functools.html#functools.cache)
|
||||||
/// - [don't lru_cache methods!](https://www.youtube.com/watch?v=sVjtp6tGo0g)
|
/// - [don't lru_cache methods!](https://www.youtube.com/watch?v=sVjtp6tGo0g)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct CachedInstanceMethod;
|
pub(crate) struct CachedInstanceMethod;
|
||||||
|
|
||||||
impl Violation for CachedInstanceMethod {
|
impl Violation for CachedInstanceMethod {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Violation};
|
use ruff_diagnostics::{AlwaysFixableViolation, Violation};
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::UnqualifiedName;
|
use ruff_python_ast::name::UnqualifiedName;
|
||||||
use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext};
|
use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
@ -39,8 +39,8 @@ use crate::registry::Rule;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct DuplicateTryBlockException {
|
pub(crate) struct DuplicateTryBlockException {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ impl Violation for DuplicateTryBlockException {
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
||||||
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
|
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct DuplicateHandlerException {
|
pub(crate) struct DuplicateHandlerException {
|
||||||
pub names: Vec<String>,
|
pub names: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use anyhow::{Context, Result};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::comparable::HashableExpr;
|
use ruff_python_ast::comparable::HashableExpr;
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
|
@ -28,8 +28,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```python
|
/// ```python
|
||||||
/// {1, 2, 3}
|
/// {1, 2, 3}
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct DuplicateValue {
|
pub(crate) struct DuplicateValue {
|
||||||
value: String,
|
value: String,
|
||||||
existing: String,
|
existing: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::{self as ast};
|
||||||
use ruff_python_ast::{ExceptHandler, Expr};
|
use ruff_python_ast::{ExceptHandler, Expr};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -33,8 +33,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ExceptWithEmptyTuple;
|
pub(crate) struct ExceptWithEmptyTuple;
|
||||||
|
|
||||||
impl Violation for ExceptWithEmptyTuple {
|
impl Violation for ExceptWithEmptyTuple {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::VecDeque;
|
||||||
use ruff_python_ast::{self as ast, ExceptHandler, Expr, Operator};
|
use ruff_python_ast::{self as ast, ExceptHandler, Expr, Operator};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
||||||
/// - [Python documentation: Built-in Exceptions](https://docs.python.org/3/library/exceptions.html#built-in-exceptions)
|
/// - [Python documentation: Built-in Exceptions](https://docs.python.org/3/library/exceptions.html#built-in-exceptions)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ExceptWithNonExceptionClasses;
|
pub(crate) struct ExceptWithNonExceptionClasses;
|
||||||
|
|
||||||
impl Violation for ExceptWithNonExceptionClasses {
|
impl Violation for ExceptWithNonExceptionClasses {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Stmt};
|
use ruff_python_ast::{self as ast, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::identifier::Identifier;
|
use ruff_python_ast::identifier::Identifier;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -30,8 +30,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
|
||||||
/// - [Python documentation: Formatted string literals](https://docs.python.org/3/reference/lexical_analysis.html#f-strings)
|
/// - [Python documentation: Formatted string literals](https://docs.python.org/3/reference/lexical_analysis.html#f-strings)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FStringDocstring;
|
pub(crate) struct FStringDocstring;
|
||||||
|
|
||||||
impl Violation for FStringDocstring {
|
impl Violation for FStringDocstring {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -3,7 +3,7 @@ use ruff_text_size::{Ranged, TextRange};
|
||||||
|
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_diagnostics::{Diagnostic, DiagnosticKind};
|
use ruff_diagnostics::{Diagnostic, DiagnosticKind};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::name::{QualifiedName, UnqualifiedName};
|
use ruff_python_ast::name::{QualifiedName, UnqualifiedName};
|
||||||
use ruff_python_ast::visitor;
|
use ruff_python_ast::visitor;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
|
@ -64,8 +64,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## Options
|
/// ## Options
|
||||||
/// - `lint.flake8-bugbear.extend-immutable-calls`
|
/// - `lint.flake8-bugbear.extend-immutable-calls`
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FunctionCallInDefaultArgument {
|
pub(crate) struct FunctionCallInDefaultArgument {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::types::Node;
|
use ruff_python_ast::types::Node;
|
||||||
use ruff_python_ast::visitor;
|
use ruff_python_ast::visitor;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
|
@ -41,8 +41,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [The Hitchhiker's Guide to Python: Late Binding Closures](https://docs.python-guide.org/writing/gotchas/#late-binding-closures)
|
/// - [The Hitchhiker's Guide to Python: Late Binding Closures](https://docs.python-guide.org/writing/gotchas/#late-binding-closures)
|
||||||
/// - [Python documentation: `functools.partial`](https://docs.python.org/3/library/functools.html#functools.partial)
|
/// - [Python documentation: `functools.partial`](https://docs.python.org/3/library/functools.html#functools.partial)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct FunctionUsesLoopVariable {
|
pub(crate) struct FunctionUsesLoopVariable {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
|
use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
|
||||||
use ruff_source_file::LineRanges;
|
use ruff_source_file::LineRanges;
|
||||||
|
@ -31,8 +31,8 @@ use crate::fix::edits::pad;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `getattr`](https://docs.python.org/3/library/functions.html#getattr)
|
/// - [Python documentation: `getattr`](https://docs.python.org/3/library/functions.html#getattr)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct GetAttrWithConstant;
|
pub(crate) struct GetAttrWithConstant;
|
||||||
|
|
||||||
impl AlwaysFixableViolation for GetAttrWithConstant {
|
impl AlwaysFixableViolation for GetAttrWithConstant {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Stmt};
|
use ruff_python_ast::{self as ast, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -40,8 +40,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
|
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct JumpStatementInFinally {
|
pub(crate) struct JumpStatementInFinally {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::fmt::Debug;
|
||||||
|
|
||||||
use ruff_diagnostics::Diagnostic;
|
use ruff_diagnostics::Diagnostic;
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::comparable::ComparableExpr;
|
use ruff_python_ast::comparable::ComparableExpr;
|
||||||
use ruff_python_ast::name::UnqualifiedName;
|
use ruff_python_ast::name::UnqualifiedName;
|
||||||
use ruff_python_ast::{
|
use ruff_python_ast::{
|
||||||
|
@ -36,8 +36,8 @@ use crate::fix::snippet::SourceCodeSnippet;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Mutable Sequence Types](https://docs.python.org/3/library/stdtypes.html#typesseq-mutable)
|
/// - [Python documentation: Mutable Sequence Types](https://docs.python.org/3/library/stdtypes.html#typesseq-mutable)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct LoopIteratorMutation {
|
pub(crate) struct LoopIteratorMutation {
|
||||||
name: Option<SourceCodeSnippet>,
|
name: Option<SourceCodeSnippet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::{self as ast, Expr, ParameterWithDefault};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::visitor;
|
use ruff_python_ast::visitor;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -36,8 +36,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: The `for` statement](https://docs.python.org/3/reference/compound_stmts.html#the-for-statement)
|
/// - [Python documentation: The `for` statement](https://docs.python.org/3/reference/compound_stmts.html#the-for-statement)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct LoopVariableOverridesIterator {
|
pub(crate) struct LoopVariableOverridesIterator {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::is_docstring_stmt;
|
use ruff_python_ast::helpers::is_docstring_stmt;
|
||||||
use ruff_python_ast::name::QualifiedName;
|
use ruff_python_ast::name::QualifiedName;
|
||||||
use ruff_python_ast::{self as ast, Expr, Parameter, ParameterWithDefault};
|
use ruff_python_ast::{self as ast, Expr, Parameter, ParameterWithDefault};
|
||||||
|
@ -68,8 +68,8 @@ use crate::Locator;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Default Argument Values](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values)
|
/// - [Python documentation: Default Argument Values](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MutableArgumentDefault;
|
pub(crate) struct MutableArgumentDefault;
|
||||||
|
|
||||||
impl Violation for MutableArgumentDefault {
|
impl Violation for MutableArgumentDefault {
|
||||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::map_subscript;
|
use ruff_python_ast::helpers::map_subscript;
|
||||||
use ruff_python_ast::name::QualifiedName;
|
use ruff_python_ast::name::QualifiedName;
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
|
@ -53,8 +53,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `contextvars` — Context Variables](https://docs.python.org/3/library/contextvars.html)
|
/// - [Python documentation: `contextvars` — Context Variables](https://docs.python.org/3/library/contextvars.html)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct MutableContextvarDefault;
|
pub(crate) struct MutableContextvarDefault;
|
||||||
|
|
||||||
impl Violation for MutableContextvarDefault {
|
impl Violation for MutableContextvarDefault {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `warnings.warn`](https://docs.python.org/3/library/warnings.html#warnings.warn)
|
/// - [Python documentation: `warnings.warn`](https://docs.python.org/3/library/warnings.html#warnings.warn)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct NoExplicitStacklevel;
|
pub(crate) struct NoExplicitStacklevel;
|
||||||
|
|
||||||
impl Violation for NoExplicitStacklevel {
|
impl Violation for NoExplicitStacklevel {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -26,8 +26,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `raise` statement](https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement)
|
/// - [Python documentation: `raise` statement](https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct RaiseLiteral;
|
pub(crate) struct RaiseLiteral;
|
||||||
|
|
||||||
impl Violation for RaiseLiteral {
|
impl Violation for RaiseLiteral {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::Stmt;
|
use ruff_python_ast::Stmt;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::RaiseStatementVisitor;
|
use ruff_python_ast::helpers::RaiseStatementVisitor;
|
||||||
use ruff_python_ast::statement_visitor::StatementVisitor;
|
use ruff_python_ast::statement_visitor::StatementVisitor;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `raise` statement](https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement)
|
/// - [Python documentation: `raise` statement](https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct RaiseWithoutFromInsideExcept;
|
pub(crate) struct RaiseWithoutFromInsideExcept;
|
||||||
|
|
||||||
impl Violation for RaiseWithoutFromInsideExcept {
|
impl Violation for RaiseWithoutFromInsideExcept {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::fmt;
|
||||||
use ruff_python_ast::{self as ast};
|
use ruff_python_ast::{self as ast};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_semantic::Modules;
|
use ruff_python_semantic::Modules;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [Python documentation: `re.sub`](https://docs.python.org/3/library/re.html#re.sub)
|
/// - [Python documentation: `re.sub`](https://docs.python.org/3/library/re.html#re.sub)
|
||||||
/// - [Python documentation: `re.subn`](https://docs.python.org/3/library/re.html#re.subn)
|
/// - [Python documentation: `re.subn`](https://docs.python.org/3/library/re.html#re.subn)
|
||||||
/// - [Python documentation: `re.split`](https://docs.python.org/3/library/re.html#re.split)
|
/// - [Python documentation: `re.split`](https://docs.python.org/3/library/re.html#re.split)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ReSubPositionalArgs {
|
pub(crate) struct ReSubPositionalArgs {
|
||||||
method: Method,
|
method: Method,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, ExceptHandler, Expr};
|
use ruff_python_ast::{self as ast, ExceptHandler, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ use crate::fix::edits::pad;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
/// - [Python documentation: `except` clause](https://docs.python.org/3/reference/compound_stmts.html#except-clause)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct RedundantTupleInExceptionHandler {
|
pub(crate) struct RedundantTupleInExceptionHandler {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use ruff_diagnostics::Diagnostic;
|
use ruff_diagnostics::Diagnostic;
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::statement_visitor;
|
use ruff_python_ast::statement_visitor;
|
||||||
use ruff_python_ast::statement_visitor::StatementVisitor;
|
use ruff_python_ast::statement_visitor::StatementVisitor;
|
||||||
use ruff_python_ast::{self as ast, Expr, Stmt, StmtFunctionDef};
|
use ruff_python_ast::{self as ast, Expr, Stmt, StmtFunctionDef};
|
||||||
|
@ -79,8 +79,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// for file_type in file_types:
|
/// for file_type in file_types:
|
||||||
/// yield from dir_path.glob(f"*.{file_type}")
|
/// yield from dir_path.glob(f"*.{file_type}")
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ReturnInGenerator;
|
pub(crate) struct ReturnInGenerator;
|
||||||
|
|
||||||
impl Violation for ReturnInGenerator {
|
impl Violation for ReturnInGenerator {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Comprehension, Expr, Stmt};
|
use ruff_python_ast::{self as ast, Comprehension, Expr, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::visitor::{self, Visitor};
|
use ruff_python_ast::visitor::{self, Visitor};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// for _ in range(5):
|
/// for _ in range(5):
|
||||||
/// do_something_with_the_group(values)
|
/// do_something_with_the_group(values)
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ReuseOfGroupbyGenerator;
|
pub(crate) struct ReuseOfGroupbyGenerator;
|
||||||
|
|
||||||
impl Violation for ReuseOfGroupbyGenerator {
|
impl Violation for ReuseOfGroupbyGenerator {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use ruff_python_ast::{self as ast, Expr, ExprContext, Identifier, Stmt};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
|
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_codegen::Generator;
|
use ruff_python_codegen::Generator;
|
||||||
use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
|
use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private};
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `setattr`](https://docs.python.org/3/library/functions.html#setattr)
|
/// - [Python documentation: `setattr`](https://docs.python.org/3/library/functions.html#setattr)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct SetAttrWithConstant;
|
pub(crate) struct SetAttrWithConstant;
|
||||||
|
|
||||||
impl AlwaysFixableViolation for SetAttrWithConstant {
|
impl AlwaysFixableViolation for SetAttrWithConstant {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{Expr, Keyword};
|
use ruff_python_ast::{Expr, Keyword};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -45,8 +45,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
|
/// - [Python documentation: Calls](https://docs.python.org/3/reference/expressions.html#calls)
|
||||||
/// - [Disallow iterable argument unpacking after a keyword argument?](https://github.com/python/cpython/issues/82741)
|
/// - [Disallow iterable argument unpacking after a keyword argument?](https://github.com/python/cpython/issues/82741)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct StarArgUnpackingAfterKeywordArg;
|
pub(crate) struct StarArgUnpackingAfterKeywordArg;
|
||||||
|
|
||||||
impl Violation for StarArgUnpackingAfterKeywordArg {
|
impl Violation for StarArgUnpackingAfterKeywordArg {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::StoredNameFinder;
|
use ruff_python_ast::helpers::StoredNameFinder;
|
||||||
use ruff_python_ast::visitor::Visitor;
|
use ruff_python_ast::visitor::Visitor;
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
|
@ -30,8 +30,8 @@ use crate::fix::snippet::SourceCodeSnippet;
|
||||||
/// data = ["some", "Data"]
|
/// data = ["some", "Data"]
|
||||||
/// {value: value.upper() for value in data}
|
/// {value: value.upper() for value in data}
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct StaticKeyDictComprehension {
|
pub(crate) struct StaticKeyDictComprehension {
|
||||||
key: SourceCodeSnippet,
|
key: SourceCodeSnippet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use itertools::Itertools;
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -44,8 +44,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `str.strip`](https://docs.python.org/3/library/stdtypes.html#str.strip)
|
/// - [Python documentation: `str.strip`](https://docs.python.org/3/library/stdtypes.html#str.strip)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct StripWithMultiCharacters;
|
pub(crate) struct StripWithMultiCharacters;
|
||||||
|
|
||||||
impl Violation for StripWithMultiCharacters {
|
impl Violation for StripWithMultiCharacters {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Expr, UnaryOp};
|
use ruff_python_ast::{self as ast, Expr, UnaryOp};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -30,8 +30,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: Unary arithmetic and bitwise operations](https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations)
|
/// - [Python documentation: Unary arithmetic and bitwise operations](https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations)
|
||||||
/// - [Python documentation: Augmented assignment statements](https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements)
|
/// - [Python documentation: Augmented assignment statements](https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UnaryPrefixIncrementDecrement {
|
pub(crate) struct UnaryPrefixIncrementDecrement {
|
||||||
operator: UnaryPrefixOperatorType,
|
operator: UnaryPrefixOperatorType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::{self as ast, Expr, Stmt};
|
use ruff_python_ast::{self as ast, Expr, Stmt};
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -22,8 +22,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// ```python
|
/// ```python
|
||||||
/// a["b"] = 1
|
/// a["b"] = 1
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UnintentionalTypeAnnotation;
|
pub(crate) struct UnintentionalTypeAnnotation;
|
||||||
|
|
||||||
impl Violation for UnintentionalTypeAnnotation {
|
impl Violation for UnintentionalTypeAnnotation {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{self as ast, Expr};
|
use ruff_python_ast::{self as ast, Expr};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// - [Python documentation: `hasattr`](https://docs.python.org/3/library/functions.html#hasattr)
|
/// - [Python documentation: `hasattr`](https://docs.python.org/3/library/functions.html#hasattr)
|
||||||
/// - [Python documentation: `__getattr__`](https://docs.python.org/3/reference/datamodel.html#object.__getattr__)
|
/// - [Python documentation: `__getattr__`](https://docs.python.org/3/reference/datamodel.html#object.__getattr__)
|
||||||
/// - [Python documentation: `__call__`](https://docs.python.org/3/reference/datamodel.html#object.__call__)
|
/// - [Python documentation: `__call__`](https://docs.python.org/3/reference/datamodel.html#object.__call__)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UnreliableCallableCheck;
|
pub(crate) struct UnreliableCallableCheck;
|
||||||
|
|
||||||
impl Violation for UnreliableCallableCheck {
|
impl Violation for UnreliableCallableCheck {
|
||||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_ast::helpers;
|
use ruff_python_ast::helpers;
|
||||||
use ruff_python_ast::helpers::{NameFinder, StoredNameFinder};
|
use ruff_python_ast::helpers::{NameFinder, StoredNameFinder};
|
||||||
|
@ -34,8 +34,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [PEP 8: Naming Conventions](https://peps.python.org/pep-0008/#naming-conventions)
|
/// - [PEP 8: Naming Conventions](https://peps.python.org/pep-0008/#naming-conventions)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UnusedLoopControlVariable {
|
pub(crate) struct UnusedLoopControlVariable {
|
||||||
/// The name of the loop control variable.
|
/// The name of the loop control variable.
|
||||||
name: String,
|
name: String,
|
||||||
/// The name to which the variable should be renamed, if it can be
|
/// The name to which the variable should be renamed, if it can be
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{Expr, Stmt};
|
use ruff_python_ast::{Expr, Stmt};
|
||||||
use ruff_python_semantic::ScopeKind;
|
use ruff_python_semantic::ScopeKind;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -33,8 +33,8 @@ use super::super::helpers::at_last_top_level_expression_in_cell;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `assert` statement](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
|
/// - [Python documentation: `assert` statement](https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UselessComparison {
|
pub(crate) struct UselessComparison {
|
||||||
at: ComparisonLocationAt,
|
at: ComparisonLocationAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
|
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
@ -36,8 +36,8 @@ use crate::checkers::ast::Checker;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `contextlib.suppress`](https://docs.python.org/3/library/contextlib.html#contextlib.suppress)
|
/// - [Python documentation: `contextlib.suppress`](https://docs.python.org/3/library/contextlib.html#contextlib.suppress)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UselessContextlibSuppress;
|
pub(crate) struct UselessContextlibSuppress;
|
||||||
|
|
||||||
impl Violation for UselessContextlibSuppress {
|
impl Violation for UselessContextlibSuppress {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{Diagnostic, Violation};
|
use ruff_diagnostics::{Diagnostic, Violation};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::helpers::contains_effect;
|
use ruff_python_ast::helpers::contains_effect;
|
||||||
use ruff_python_ast::Expr;
|
use ruff_python_ast::Expr;
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -50,8 +50,8 @@ use super::super::helpers::at_last_top_level_expression_in_cell;
|
||||||
/// with errors.ExceptionRaisedContext():
|
/// with errors.ExceptionRaisedContext():
|
||||||
/// _ = obj.attribute
|
/// _ = obj.attribute
|
||||||
/// ```
|
/// ```
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct UselessExpression {
|
pub(crate) struct UselessExpression {
|
||||||
kind: Kind,
|
kind: Kind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use ruff_diagnostics::{AlwaysFixableViolation, Applicability, Diagnostic, Fix};
|
use ruff_diagnostics::{AlwaysFixableViolation, Applicability, Diagnostic, Fix};
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
|
|
||||||
use ruff_python_ast::{self as ast, Arguments, Expr};
|
use ruff_python_ast::{self as ast, Arguments, Expr};
|
||||||
use ruff_python_semantic::SemanticModel;
|
use ruff_python_semantic::SemanticModel;
|
||||||
|
@ -37,8 +37,8 @@ use crate::fix::edits::add_argument;
|
||||||
///
|
///
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [Python documentation: `zip`](https://docs.python.org/3/library/functions.html#zip)
|
/// - [Python documentation: `zip`](https://docs.python.org/3/library/functions.html#zip)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct ZipWithoutExplicitStrict;
|
pub(crate) struct ZipWithoutExplicitStrict;
|
||||||
|
|
||||||
impl AlwaysFixableViolation for ZipWithoutExplicitStrict {
|
impl AlwaysFixableViolation for ZipWithoutExplicitStrict {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use ruff_diagnostics::Diagnostic;
|
use ruff_diagnostics::Diagnostic;
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast::{Expr, Parameter};
|
use ruff_python_ast::{Expr, Parameter};
|
||||||
use ruff_python_semantic::analyze::visibility::{is_overload, is_override};
|
use ruff_python_semantic::analyze::visibility::{is_overload, is_override};
|
||||||
use ruff_text_size::Ranged;
|
use ruff_text_size::Ranged;
|
||||||
|
@ -49,8 +49,8 @@ use super::super::helpers::shadows_builtin;
|
||||||
/// ## References
|
/// ## References
|
||||||
/// - [_Is it bad practice to use a built-in function name as an attribute or method identifier?_](https://stackoverflow.com/questions/9109333/is-it-bad-practice-to-use-a-built-in-function-name-as-an-attribute-or-method-ide)
|
/// - [_Is it bad practice to use a built-in function name as an attribute or method identifier?_](https://stackoverflow.com/questions/9109333/is-it-bad-practice-to-use-a-built-in-function-name-as-an-attribute-or-method-ide)
|
||||||
/// - [_Why is it a bad idea to name a variable `id` in Python?_](https://stackoverflow.com/questions/77552/id-is-a-bad-variable-name-in-python)
|
/// - [_Why is it a bad idea to name a variable `id` in Python?_](https://stackoverflow.com/questions/77552/id-is-a-bad-variable-name-in-python)
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BuiltinArgumentShadowing {
|
pub(crate) struct BuiltinArgumentShadowing {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use ruff_diagnostics::Diagnostic;
|
use ruff_diagnostics::Diagnostic;
|
||||||
use ruff_diagnostics::Violation;
|
use ruff_diagnostics::Violation;
|
||||||
use ruff_macros::{derive_message_formats, violation};
|
use ruff_macros::{derive_message_formats, ViolationMetadata};
|
||||||
use ruff_python_ast as ast;
|
use ruff_python_ast as ast;
|
||||||
use ruff_python_semantic::{BindingKind, Scope, ScopeId};
|
use ruff_python_semantic::{BindingKind, Scope, ScopeId};
|
||||||
use ruff_source_file::SourceRow;
|
use ruff_source_file::SourceRow;
|
||||||
|
@ -56,8 +56,8 @@ use crate::rules::flake8_builtins::helpers::shadows_builtin;
|
||||||
///
|
///
|
||||||
/// ## Options
|
/// ## Options
|
||||||
/// - `lint.flake8-builtins.builtins-ignorelist`
|
/// - `lint.flake8-builtins.builtins-ignorelist`
|
||||||
#[violation]
|
#[derive(ViolationMetadata)]
|
||||||
pub struct BuiltinAttributeShadowing {
|
pub(crate) struct BuiltinAttributeShadowing {
|
||||||
kind: Kind,
|
kind: Kind,
|
||||||
name: String,
|
name: String,
|
||||||
row: SourceRow,
|
row: SourceRow,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue