Rename variable to indent_width to match docs (#11230)
Reference: https://github.com/astral-sh/ruff/issues/8705#issuecomment-2084726911
This commit is contained in:
@@ -31,18 +31,21 @@ use super::LogicalLine;
|
||||
/// The rule is also incompatible with the [formatter] when using
|
||||
/// `indent-width` with a value other than `4`.
|
||||
///
|
||||
/// ## Options
|
||||
/// - `indent-width`
|
||||
///
|
||||
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
|
||||
/// [formatter]:https://docs.astral.sh/ruff/formatter/
|
||||
#[violation]
|
||||
pub struct IndentationWithInvalidMultiple {
|
||||
indent_size: usize,
|
||||
indent_width: usize,
|
||||
}
|
||||
|
||||
impl Violation for IndentationWithInvalidMultiple {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let Self { indent_size } = self;
|
||||
format!("Indentation is not a multiple of {indent_size}")
|
||||
let Self { indent_width } = self;
|
||||
format!("Indentation is not a multiple of {indent_width}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,18 +74,21 @@ impl Violation for IndentationWithInvalidMultiple {
|
||||
/// The rule is also incompatible with the [formatter] when using
|
||||
/// `indent-width` with a value other than `4`.
|
||||
///
|
||||
/// ## Options
|
||||
/// - `indent-width`
|
||||
///
|
||||
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
|
||||
/// [formatter]:https://docs.astral.sh/ruff/formatter/
|
||||
#[violation]
|
||||
pub struct IndentationWithInvalidMultipleComment {
|
||||
indent_size: usize,
|
||||
indent_width: usize,
|
||||
}
|
||||
|
||||
impl Violation for IndentationWithInvalidMultipleComment {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let Self { indent_size } = self;
|
||||
format!("Indentation is not a multiple of {indent_size} (comment)")
|
||||
let Self { indent_width } = self;
|
||||
format!("Indentation is not a multiple of {indent_width} (comment)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,9 +263,13 @@ pub(crate) fn indentation(
|
||||
|
||||
if indent_level % indent_size != 0 {
|
||||
diagnostics.push(if logical_line.is_comment_only() {
|
||||
DiagnosticKind::from(IndentationWithInvalidMultipleComment { indent_size })
|
||||
DiagnosticKind::from(IndentationWithInvalidMultipleComment {
|
||||
indent_width: indent_size,
|
||||
})
|
||||
} else {
|
||||
DiagnosticKind::from(IndentationWithInvalidMultiple { indent_size })
|
||||
DiagnosticKind::from(IndentationWithInvalidMultiple {
|
||||
indent_width: indent_size,
|
||||
})
|
||||
});
|
||||
}
|
||||
let indent_expect = prev_logical_line
|
||||
|
||||
Reference in New Issue
Block a user