diff --git a/src/cli.rs b/src/cli.rs index 46f4706fb5..42191a7455 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,15 +1,12 @@ -use std::fmt; use std::path::PathBuf; use clap::{command, Parser}; use fnv::FnvHashMap; -use log::warn; use regex::Regex; use crate::checks_gen::CheckCodePrefix; use crate::logging::LogLevel; use crate::printer::SerializationFormat; -use crate::settings::configuration::Configuration; use crate::settings::types::{PatternPrefixPair, PerFileIgnore, PythonVersion}; #[derive(Debug, Parser)] @@ -137,64 +134,6 @@ pub fn extract_log_level(cli: &Cli) -> LogLevel { } } -pub enum Warnable { - Select, - ExtendSelect, -} - -impl fmt::Display for Warnable { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - match self { - Warnable::Select => fmt.write_str("--select"), - Warnable::ExtendSelect => fmt.write_str("--extend-select"), - } - } -} - -/// Warn the user if they attempt to enable a code that won't be respected. -pub fn warn_on( - flag: Warnable, - codes: &[CheckCodePrefix], - cli_ignore: &[CheckCodePrefix], - cli_extend_ignore: &[CheckCodePrefix], - pyproject_configuration: &Configuration, - pyproject_path: Option<&PathBuf>, -) { - for code in codes { - if !cli_ignore.is_empty() { - if cli_ignore.contains(code) { - warn!("{code:?} was passed to {flag}, but ignored via --ignore") - } - } else if pyproject_configuration.ignore.contains(code) { - if let Some(path) = pyproject_path { - warn!( - "{code:?} was passed to {flag}, but ignored by the `ignore` field in {}", - path.to_string_lossy() - ) - } else { - warn!("{code:?} was passed to {flag}, but ignored by the default `ignore` field",) - } - } - if !cli_extend_ignore.is_empty() { - if cli_extend_ignore.contains(code) { - warn!("{code:?} was passed to {flag}, but ignored via --extend-ignore") - } - } else if pyproject_configuration.extend_ignore.contains(code) { - if let Some(path) = pyproject_path { - warn!( - "{code:?} was passed to {flag}, but ignored by the `extend_ignore` field in {}", - path.to_string_lossy() - ) - } else { - warn!( - "{code:?} was passed to {flag}, but ignored by the default `extend_ignore` \ - field" - ) - } - } - } -} - /// Convert a list of `PatternPrefixPair` structs to `PerFileIgnore`. pub fn collect_per_file_ignores( pairs: Vec, diff --git a/src/main.rs b/src/main.rs index ec44a8b2ad..2e023bbc43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use std::time::Instant; #[cfg(not(target_family = "wasm"))] use ::ruff::cache; use ::ruff::checks::{CheckCode, CheckKind}; -use ::ruff::cli::{collect_per_file_ignores, extract_log_level, warn_on, Cli, Warnable}; +use ::ruff::cli::{collect_per_file_ignores, extract_log_level, Cli}; use ::ruff::fs::iter_python_files; use ::ruff::linter::{add_noqa_to_path, autoformat_path, lint_path, lint_stdin}; use ::ruff::logging::{set_up_logging, LogLevel}; @@ -240,25 +240,9 @@ fn inner_main() -> Result { collect_per_file_ignores(cli.per_file_ignores, project_root.as_ref()); } if !cli.select.is_empty() { - warn_on( - Warnable::Select, - &cli.select, - &cli.ignore, - &cli.extend_ignore, - &configuration, - pyproject.as_ref(), - ); configuration.select = cli.select; } if !cli.extend_select.is_empty() { - warn_on( - Warnable::ExtendSelect, - &cli.extend_select, - &cli.ignore, - &cli.extend_ignore, - &configuration, - pyproject.as_ref(), - ); configuration.extend_select = cli.extend_select; } if !cli.ignore.is_empty() {