fix(rome_cli): better printing of message
MODIFY
crates/rome_cli/src/commands/check.rs
crates/rome_cli/src/commands/check.rs
@@ -13,7 +13,7 @@ pub(crate) fn check(mut session: CliSession) -> Result<(), Termination> {
let configuration = load_config(&session.app.fs)?;
let mut workspace_settings = WorkspaceSettings::default();
- let max_diagnostics: Option<u8> = session
+ let max_diagnostics: Option<u16> = session
.args
.opt_value_from_str("--max-diagnostics")
.map_err(|source| Termination::ParseError {
@@ -24,7 +24,7 @@ pub(crate) fn check(mut session: CliSession) -> Result<(), Termination> {
if max_diagnostics > MAXIMUM_DISPLAYABLE_DIAGNOSTICS {
return Err(Termination::OverflowNumberArgument(
"--max-diagnostics",
- "50",
+ MAXIMUM_DISPLAYABLE_DIAGNOSTICS,
));
}

MODIFY
crates/rome_cli/src/termination.rs
crates/rome_cli/src/termination.rs
@@ -52,7 +52,7 @@ pub enum Termination {
CheckError,
#[error("the value of the argument {0} is too high, maximum accepted {1}")]
- OverflowNumberArgument(&'static str, &'static str),
+ OverflowNumberArgument(&'static str, u16),
/// Wrapper for an underlying `rome_service` error
#[error(transparent)]

MODIFY
crates/rome_cli/src/traversal.rs
crates/rome_cli/src/traversal.rs
@@ -156,7 +156,7 @@ fn print_messages_to_console(
) -> bool {
let mut has_errors = false;
let mut paths = HashMap::new();
- let mut printed_diagnostics: u8 = 0;
+ let mut printed_diagnostics: u16 = 0;
let mut not_printed_diagnostics = 0;
while let Ok(msg) = recv_msgs.recv() {
@@ -225,13 +225,6 @@ fn print_messages_to_console(
}
}
}
-
- if !mode.is_ci() && not_printed_diagnostics > 0 {
- console.log(markup! {
- <Warn>"The number of diagnostics exceeds the number allowed by Rome."</Warn>
- <Info>"Diagnostics not shown: "</Info><Emphasis>{not_printed_diagnostics}</Emphasis><Info>"."</Info>
- })
- }
}
Message::Diff {
@@ -281,6 +274,13 @@ fn print_messages_to_console(
}
}
+ if !mode.is_ci() && not_printed_diagnostics > 0 {
+ console.log(markup! {
+ <Warn>"The number of diagnostics exceeds the number allowed by Rome.\n"</Warn>
+ <Info>"Diagnostics not shown: "</Info><Emphasis>{not_printed_diagnostics}</Emphasis><Info>"."</Info>
+ })
+ }
+
has_errors
}
@@ -288,7 +288,7 @@ fn print_messages_to_console(
pub(crate) enum TraversalMode {
/// This mode is enabled when running the command `rome check`
Check {
- max_diagnostics: u8,
+ max_diagnostics: u16,
/// `true` when running the command `check` with the `--apply` argument
should_fix: bool,
},
@@ -299,7 +299,7 @@ pub(crate) enum TraversalMode {
}
impl TraversalMode {
- fn get_max_diagnostics(&self) -> Option<u8> {
+ fn get_max_diagnostics(&self) -> Option<u16> {
match self {
TraversalMode::Check {
max_diagnostics, ..

MODIFY
crates/rome_cli/tests/main.rs
crates/rome_cli/tests/main.rs
@@ -704,6 +704,7 @@ mod help {
mod main {
use super::*;
+ use rome_diagnostics::MAXIMUM_DISPLAYABLE_DIAGNOSTICS;
#[test]
fn unknown_command() {
@@ -805,14 +806,14 @@ mod main {
),
args: Arguments::from_vec(vec![
OsString::from("check"),
- OsString::from("--max-diagnostics=100"),
+ OsString::from("--max-diagnostics=500"),
]),
});
match result {
Err(Termination::OverflowNumberArgument(argument, limit)) => {
assert_eq!(argument, "--max-diagnostics");
- assert_eq!(limit, "50");
+ assert_eq!(limit, MAXIMUM_DISPLAYABLE_DIAGNOSTICS);
}
_ => panic!("run_cli returned {result:?} for a malformed, expected an error"),
}

MODIFY
crates/rome_diagnostics/src/lib.rs
crates/rome_diagnostics/src/lib.rs
@@ -32,7 +32,7 @@ impl DiagnosticTag {
}
}
-/// Indicicates how a tool should manage this suggestion.
+/// Indicates how a tool should manage this suggestion.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Applicability {
@@ -50,4 +50,4 @@ pub enum Applicability {
Unspecified,
}
-pub const MAXIMUM_DISPLAYABLE_DIAGNOSTICS: u8 = 50;
+pub const MAXIMUM_DISPLAYABLE_DIAGNOSTICS: u16 = 200;

fix(rome_cli): better printing of message (#2929)