Skip to content

Commit

Permalink
Rename list-reassign-reversed to list-reverse-copy (#10514)
Browse files Browse the repository at this point in the history
After discussion with @MichaReiser.
  • Loading branch information
charliermarsh authored Mar 21, 2024
1 parent 01fe268 commit dc6f639
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/checkers/ast/analyze/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
}
}
}
if checker.enabled(Rule::ListAssignReversed) {
if checker.enabled(Rule::ListReverseCopy) {
refurb::rules::list_assign_reversed(checker, assign);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
(Refurb, "177") => (RuleGroup::Preview, rules::refurb::rules::ImplicitCwd),
(Refurb, "180") => (RuleGroup::Preview, rules::refurb::rules::MetaClassABCMeta),
(Refurb, "181") => (RuleGroup::Preview, rules::refurb::rules::HashlibDigestHex),
(Refurb, "187") => (RuleGroup::Preview, rules::refurb::rules::ListAssignReversed),
(Refurb, "187") => (RuleGroup::Preview, rules::refurb::rules::ListReverseCopy),

// flake8-logging
(Flake8Logging, "001") => (RuleGroup::Stable, rules::flake8_logging::rules::DirectLoggerInstantiation),
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/rules/refurb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod tests {
#[test_case(Rule::RedundantLogBase, Path::new("FURB163.py"))]
#[test_case(Rule::MetaClassABCMeta, Path::new("FURB180.py"))]
#[test_case(Rule::HashlibDigestHex, Path::new("FURB181.py"))]
#[test_case(Rule::ListAssignReversed, Path::new("FURB187.py"))]
#[test_case(Rule::ListReverseCopy, Path::new("FURB187.py"))]
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ use crate::checkers::ast::Checker;
/// ## References
/// - [Python documentation: More on Lists](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists)
#[violation]
pub struct ListAssignReversed {
pub struct ListReverseCopy {
name: String,
}

impl AlwaysFixableViolation for ListAssignReversed {
impl AlwaysFixableViolation for ListReverseCopy {
#[derive_message_formats]
fn message(&self) -> String {
let ListAssignReversed { name } = self;
let ListReverseCopy { name } = self;
format!("Use of assignment of `reversed` on list `{name}`")
}

fn fix_title(&self) -> String {
let ListAssignReversed { name } = self;
let ListReverseCopy { name } = self;
format!("Replace with `{name}.reverse()`")
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ pub(crate) fn list_assign_reversed(checker: &mut Checker, assign: &StmtAssign) {

checker.diagnostics.push(
Diagnostic::new(
ListAssignReversed {
ListReverseCopy {
name: target_expr.id.to_string(),
},
assign.range(),
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_linter/src/rules/refurb/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) use hashlib_digest_hex::*;
pub(crate) use if_expr_min_max::*;
pub(crate) use implicit_cwd::*;
pub(crate) use isinstance_type_none::*;
pub(crate) use list_assign_reversed::*;
pub(crate) use list_reverse_copy::*;
pub(crate) use math_constant::*;
pub(crate) use metaclass_abcmeta::*;
pub(crate) use print_empty_string::*;
Expand All @@ -28,7 +28,7 @@ mod hashlib_digest_hex;
mod if_expr_min_max;
mod implicit_cwd;
mod isinstance_type_none;
mod list_assign_reversed;
mod list_reverse_copy;
mod math_constant;
mod metaclass_abcmeta;
mod print_empty_string;
Expand Down

0 comments on commit dc6f639

Please sign in to comment.