Rename list-reassign-reversed to list-reverse-copy (#10514)

After discussion with @MichaReiser.
This commit is contained in:
Charlie Marsh 2024-03-21 13:33:00 -04:00 committed by GitHub
parent 01fe268612
commit dc6f6398e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 10 additions and 10 deletions

View file

@ -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); refurb::rules::list_assign_reversed(checker, assign);
} }
} }

View file

@ -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, "177") => (RuleGroup::Preview, rules::refurb::rules::ImplicitCwd),
(Refurb, "180") => (RuleGroup::Preview, rules::refurb::rules::MetaClassABCMeta), (Refurb, "180") => (RuleGroup::Preview, rules::refurb::rules::MetaClassABCMeta),
(Refurb, "181") => (RuleGroup::Preview, rules::refurb::rules::HashlibDigestHex), (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 // flake8-logging
(Flake8Logging, "001") => (RuleGroup::Stable, rules::flake8_logging::rules::DirectLoggerInstantiation), (Flake8Logging, "001") => (RuleGroup::Stable, rules::flake8_logging::rules::DirectLoggerInstantiation),

View file

@ -35,7 +35,7 @@ mod tests {
#[test_case(Rule::RedundantLogBase, Path::new("FURB163.py"))] #[test_case(Rule::RedundantLogBase, Path::new("FURB163.py"))]
#[test_case(Rule::MetaClassABCMeta, Path::new("FURB180.py"))] #[test_case(Rule::MetaClassABCMeta, Path::new("FURB180.py"))]
#[test_case(Rule::HashlibDigestHex, Path::new("FURB181.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<()> { fn rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let diagnostics = test_path( let diagnostics = test_path(

View file

@ -39,19 +39,19 @@ use crate::checkers::ast::Checker;
/// ## References /// ## References
/// - [Python documentation: More on Lists](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists) /// - [Python documentation: More on Lists](https://docs.python.org/3/tutorial/datastructures.html#more-on-lists)
#[violation] #[violation]
pub struct ListAssignReversed { pub struct ListReverseCopy {
name: String, name: String,
} }
impl AlwaysFixableViolation for ListAssignReversed { impl AlwaysFixableViolation for ListReverseCopy {
#[derive_message_formats] #[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
let ListAssignReversed { name } = self; let ListReverseCopy { name } = self;
format!("Use of assignment of `reversed` on list `{name}`") format!("Use of assignment of `reversed` on list `{name}`")
} }
fn fix_title(&self) -> String { fn fix_title(&self) -> String {
let ListAssignReversed { name } = self; let ListReverseCopy { name } = self;
format!("Replace with `{name}.reverse()`") format!("Replace with `{name}.reverse()`")
} }
} }
@ -83,7 +83,7 @@ pub(crate) fn list_assign_reversed(checker: &mut Checker, assign: &StmtAssign) {
checker.diagnostics.push( checker.diagnostics.push(
Diagnostic::new( Diagnostic::new(
ListAssignReversed { ListReverseCopy {
name: target_expr.id.to_string(), name: target_expr.id.to_string(),
}, },
assign.range(), assign.range(),

View file

@ -5,7 +5,7 @@ pub(crate) use hashlib_digest_hex::*;
pub(crate) use if_expr_min_max::*; pub(crate) use if_expr_min_max::*;
pub(crate) use implicit_cwd::*; pub(crate) use implicit_cwd::*;
pub(crate) use isinstance_type_none::*; 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 math_constant::*;
pub(crate) use metaclass_abcmeta::*; pub(crate) use metaclass_abcmeta::*;
pub(crate) use print_empty_string::*; pub(crate) use print_empty_string::*;
@ -28,7 +28,7 @@ mod hashlib_digest_hex;
mod if_expr_min_max; mod if_expr_min_max;
mod implicit_cwd; mod implicit_cwd;
mod isinstance_type_none; mod isinstance_type_none;
mod list_assign_reversed; mod list_reverse_copy;
mod math_constant; mod math_constant;
mod metaclass_abcmeta; mod metaclass_abcmeta;
mod print_empty_string; mod print_empty_string;