Remove output-format=text setting (#12836)

This commit is contained in:
Micha Reiser 2024-10-08 13:46:42 +02:00 committed by Alex Waygood
parent 5c3c0c4705
commit 202c6a6d75
7 changed files with 19 additions and 103 deletions

View file

@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
use anyhow::{anyhow, bail};
use anyhow::bail;
use clap::builder::{TypedValueParser, ValueParserFactory};
use clap::{command, Parser, Subcommand};
use colored::Colorize;
@ -729,7 +729,7 @@ impl CheckCommand {
unsafe_fixes: resolve_bool_arg(self.unsafe_fixes, self.no_unsafe_fixes)
.map(UnsafeFixes::from),
force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude),
output_format: resolve_output_format(self.output_format)?,
output_format: self.output_format,
show_fixes: resolve_bool_arg(self.show_fixes, self.no_show_fixes),
extension: self.extension,
..ExplicitConfigOverrides::default()
@ -984,17 +984,6 @@ The path `{value}` does not point to a configuration file"
}
}
#[allow(deprecated)]
fn resolve_output_format(
output_format: Option<OutputFormat>,
) -> anyhow::Result<Option<OutputFormat>> {
if let Some(OutputFormat::Text) = output_format {
Err(anyhow!("`--output-format=text` is no longer supported. Use `--output-format=full` or `--output-format=concise` instead."))
} else {
Ok(output_format)
}
}
/// CLI settings that are distinct from configuration (commands, lists of files,
/// etc.).
#[allow(clippy::struct_excessive_bools)]

View file

@ -244,10 +244,7 @@ impl Printer {
#[allow(deprecated)]
if matches!(
self.format,
OutputFormat::Text
| OutputFormat::Full
| OutputFormat::Concise
| OutputFormat::Grouped
OutputFormat::Full | OutputFormat::Concise | OutputFormat::Grouped
) {
if self.flags.intersects(Flags::SHOW_FIX_SUMMARY) {
if !diagnostics.fixed.is_empty() {
@ -325,8 +322,6 @@ impl Printer {
OutputFormat::Sarif => {
SarifEmitter.emit(writer, &diagnostics.messages, &context)?;
}
#[allow(deprecated)]
OutputFormat::Text => unreachable!("Text is deprecated and should have been automatically converted to the default serialization format")
}
writer.flush()?;
@ -368,8 +363,7 @@ impl Printer {
}
match self.format {
#[allow(deprecated)]
OutputFormat::Text | OutputFormat::Full | OutputFormat::Concise => {
OutputFormat::Full | OutputFormat::Concise => {
// Compute the maximum number of digits in the count and code, for all messages,
// to enable pretty-printing.
let count_width = num_digits(

View file

@ -1,36 +0,0 @@
//! A test suite that ensures deprecated command line options have appropriate warnings / behaviors
use ruff_linter::settings::types::OutputFormat;
use std::process::Command;
use insta_cmd::{assert_cmd_snapshot, get_cargo_bin};
const BIN_NAME: &str = "ruff";
const STDIN: &str = "l = 1";
fn ruff_check(output_format: OutputFormat) -> Command {
let mut cmd = Command::new(get_cargo_bin(BIN_NAME));
let output_format = output_format.to_string();
cmd.arg("check")
.arg("--output-format")
.arg(output_format)
.arg("--no-cache");
cmd.arg("-");
cmd
}
#[test]
#[allow(deprecated)]
fn ensure_output_format_is_deprecated() {
assert_cmd_snapshot!(ruff_check(OutputFormat::Text).pass_stdin(STDIN), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
ruff failed
Cause: `--output-format=text` is no longer supported. Use `--output-format=full` or `--output-format=concise` instead.
"###);
}

View file

@ -1,5 +1,3 @@
#![allow(deprecated)]
use std::fmt::{Display, Formatter};
use std::hash::{Hash, Hasher};
use std::ops::Deref;
@ -511,12 +509,6 @@ impl FromIterator<ExtensionPair> for ExtensionMapping {
#[serde(rename_all = "kebab-case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum OutputFormat {
// Remove the module level `#![allow(deprecated)` when removing the text variant.
// Adding the `#[deprecated]` attribute to text creates clippy warnings about
// using a deprecated item in the derived code and there seems to be no way to suppress the clippy error
// other than disabling the warning for the entire module and/or moving `OutputFormat` to another module.
#[deprecated(note = "Use `concise` or `full` instead")]
Text,
Concise,
#[default]
Full,
@ -535,7 +527,6 @@ pub enum OutputFormat {
impl Display for OutputFormat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Text => write!(f, "text"),
Self::Concise => write!(f, "concise"),
Self::Full => write!(f, "full"),
Self::Json => write!(f, "json"),

View file

@ -454,17 +454,6 @@ impl Configuration {
return Err(anyhow!("The `tab-size` option has been renamed to `indent-width` to emphasize that it configures the indentation used by the formatter as well as the tab width. Please update {config_to_update} to use `indent-width = <value>` instead."));
}
#[allow(deprecated)]
if options.output_format == Some(OutputFormat::Text) {
let config_to_update = path.map_or_else(
|| String::from("your `--config` CLI arguments"),
|path| format!("`{}`", fs::relativize_path(path)),
);
return Err(anyhow!(
r#"The option `output_format=text` is no longer supported. Update {config_to_update} to use `output-format="concise"` or `output-format="full"` instead."#
));
}
Ok(Self {
builtins: options.builtins,
cache_dir: options

View file

@ -589,7 +589,7 @@ Options:
Ignore any `# noqa` comments
--output-format <OUTPUT_FORMAT>
Output serialization format for violations. The default serialization
format is "full" [env: RUFF_OUTPUT_FORMAT=] [possible values: text,
format is "full" [env: RUFF_OUTPUT_FORMAT=] [possible values:
concise, full, json, json-lines, junit, grouped, github, gitlab,
pylint, rdjson, azure, sarif]
-o, --output-file <OUTPUT_FILE>

11
ruff.schema.json generated
View file

@ -2423,8 +2423,6 @@
"type": "string"
},
"OutputFormat": {
"oneOf": [
{
"type": "string",
"enum": [
"concise",
@ -2441,15 +2439,6 @@
"sarif"
]
},
{
"deprecated": true,
"type": "string",
"enum": [
"text"
]
}
]
},
"ParametrizeNameType": {
"type": "string",
"enum": [