mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
Use identifier_range
for a few more rules (#3254)
This commit is contained in:
parent
d2a6ed7be6
commit
c65585e14a
10 changed files with 117 additions and 113 deletions
|
@ -5,6 +5,7 @@ use ruff_macros::{define_violation, derive_message_formats};
|
|||
use rustc_hash::FxHashSet;
|
||||
use rustpython_parser::ast::StmtKind;
|
||||
|
||||
use crate::ast::helpers::identifier_range;
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::whitespace::LinesWithTrailingNewline;
|
||||
use crate::ast::{cast, whitespace};
|
||||
|
@ -837,7 +838,7 @@ fn missing_args(checker: &mut Checker, docstring: &Docstring, docstrings_args: &
|
|||
let names = missing_arg_names.into_iter().sorted().collect();
|
||||
checker.diagnostics.push(Diagnostic::new(
|
||||
UndocumentedParam { names },
|
||||
Range::from_located(parent),
|
||||
identifier_range(parent, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 283
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 293
|
||||
column: 16
|
||||
row: 283
|
||||
column: 11
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -20,10 +20,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 300
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 306
|
||||
column: 7
|
||||
row: 300
|
||||
column: 28
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -34,10 +34,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 324
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 330
|
||||
column: 11
|
||||
row: 324
|
||||
column: 25
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -48,10 +48,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 336
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 343
|
||||
column: 11
|
||||
row: 336
|
||||
column: 38
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -62,10 +62,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 349
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 355
|
||||
column: 11
|
||||
row: 349
|
||||
column: 39
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -75,10 +75,10 @@ expression: diagnostics
|
|||
- b
|
||||
location:
|
||||
row: 361
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 367
|
||||
column: 11
|
||||
row: 361
|
||||
column: 30
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -87,10 +87,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 389
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 398
|
||||
column: 7
|
||||
row: 389
|
||||
column: 27
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -101,10 +101,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 425
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 434
|
||||
column: 11
|
||||
row: 425
|
||||
column: 25
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -115,10 +115,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 440
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 453
|
||||
column: 11
|
||||
row: 440
|
||||
column: 38
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -128,10 +128,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 459
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 469
|
||||
column: 11
|
||||
row: 459
|
||||
column: 39
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -140,10 +140,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 489
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 497
|
||||
column: 11
|
||||
row: 489
|
||||
column: 29
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 11
|
||||
column: 12
|
||||
row: 1
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -22,10 +22,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 14
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 24
|
||||
column: 12
|
||||
row: 14
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -35,10 +35,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 27
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 36
|
||||
column: 12
|
||||
row: 27
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -48,10 +48,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 39
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 49
|
||||
column: 12
|
||||
row: 39
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -60,10 +60,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 52
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 62
|
||||
column: 12
|
||||
row: 52
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -72,10 +72,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 65
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 74
|
||||
column: 12
|
||||
row: 65
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -84,10 +84,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 77
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 84
|
||||
column: 12
|
||||
row: 77
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -96,10 +96,10 @@ expression: diagnostics
|
|||
- x
|
||||
location:
|
||||
row: 98
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 105
|
||||
column: 12
|
||||
row: 98
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -108,10 +108,10 @@ expression: diagnostics
|
|||
- "*args"
|
||||
location:
|
||||
row: 108
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 115
|
||||
column: 12
|
||||
row: 108
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ expression: diagnostics
|
|||
- z
|
||||
location:
|
||||
row: 27
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 36
|
||||
column: 12
|
||||
row: 27
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -21,10 +21,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 65
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 74
|
||||
column: 12
|
||||
row: 65
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -33,10 +33,10 @@ expression: diagnostics
|
|||
- y
|
||||
location:
|
||||
row: 77
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 84
|
||||
column: 12
|
||||
row: 77
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -45,10 +45,10 @@ expression: diagnostics
|
|||
- x
|
||||
location:
|
||||
row: 98
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 105
|
||||
column: 12
|
||||
row: 98
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -57,10 +57,10 @@ expression: diagnostics
|
|||
- "*args"
|
||||
location:
|
||||
row: 108
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 115
|
||||
column: 12
|
||||
row: 108
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{define_violation, derive_message_formats};
|
||||
use rustpython_parser::ast::{Arguments, Expr, ExprKind, Stmt};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{define_violation, derive_message_formats};
|
||||
|
||||
use crate::ast::helpers::identifier_range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
@ -15,6 +16,7 @@ impl Violation for PropertyWithParameters {
|
|||
format!("Cannot have defined parameters for properties")
|
||||
}
|
||||
}
|
||||
|
||||
/// PLR0206
|
||||
pub fn property_with_parameters(
|
||||
checker: &mut Checker,
|
||||
|
@ -39,7 +41,7 @@ pub fn property_with_parameters(
|
|||
{
|
||||
checker.diagnostics.push(Diagnostic::new(
|
||||
PropertyWithParameters,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use ruff_macros::{define_violation, derive_message_formats};
|
||||
use rustpython_parser::ast::{Arguments, Stmt};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use ruff_macros::{define_violation, derive_message_formats};
|
||||
|
||||
use crate::ast::helpers::identifier_range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::registry::Diagnostic;
|
||||
use crate::violation::Violation;
|
||||
|
@ -34,7 +35,7 @@ pub fn too_many_arguments(checker: &mut Checker, args: &Arguments, stmt: &Stmt)
|
|||
c_args: num_args,
|
||||
max_args: checker.settings.pylint.max_args,
|
||||
},
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
---
|
||||
source: src/rules/pylint/mod.rs
|
||||
source: crates/ruff/src/rules/pylint/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
PropertyWithParameters: ~
|
||||
location:
|
||||
row: 7
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 8
|
||||
column: 29
|
||||
row: 7
|
||||
column: 17
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
PropertyWithParameters: ~
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 12
|
||||
column: 29
|
||||
row: 11
|
||||
column: 30
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
PropertyWithParameters: ~
|
||||
location:
|
||||
row: 15
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 16
|
||||
column: 29
|
||||
row: 15
|
||||
column: 33
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
source: src/rules/pylint/mod.rs
|
||||
source: crates/ruff/src/rules/pylint/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
|
@ -8,10 +8,10 @@ expression: diagnostics
|
|||
max_args: 5
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 2
|
||||
column: 8
|
||||
row: 1
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -20,10 +20,10 @@ expression: diagnostics
|
|||
max_args: 5
|
||||
location:
|
||||
row: 17
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 18
|
||||
column: 8
|
||||
row: 17
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -32,10 +32,10 @@ expression: diagnostics
|
|||
max_args: 5
|
||||
location:
|
||||
row: 33
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 34
|
||||
column: 8
|
||||
row: 33
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
source: src/rules/pylint/mod.rs
|
||||
source: crates/ruff/src/rules/pylint/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
|
@ -8,10 +8,10 @@ expression: diagnostics
|
|||
max_args: 4
|
||||
location:
|
||||
row: 3
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 4
|
||||
column: 8
|
||||
row: 3
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
|
@ -20,10 +20,10 @@ expression: diagnostics
|
|||
max_args: 4
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 10
|
||||
column: 8
|
||||
row: 9
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
source: src/rules/pylint/mod.rs
|
||||
source: crates/ruff/src/rules/pylint/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
|
@ -8,10 +8,10 @@ expression: diagnostics
|
|||
max_args: 5
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 10
|
||||
column: 8
|
||||
row: 9
|
||||
column: 5
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue