Skip to content

Commit

Permalink
fix: formatting in crates/ and xtask/
Browse files Browse the repository at this point in the history
  • Loading branch information
hamirmahal committed Jun 26, 2024
1 parent 47e3c7e commit add4ec9
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 86 deletions.
4 changes: 1 addition & 3 deletions crates/biome_css_analyze/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ fn check_code_action(
assert_eq!(new_tree.to_string(), output);

if has_bogus_nodes_or_empty_slots(&new_tree) {
panic!(
"modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}"
)
panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}")
}

// Checks the returned tree contains no missing children node
Expand Down
8 changes: 2 additions & 6 deletions crates/biome_css_parser/tests/spec_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ pub fn run(test_case: &str, _snapshot_name: &str, test_directory: &str, outcome_

let syntax = parsed.syntax();
if has_bogus_nodes_or_empty_slots(&syntax) {
panic!(
"modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}"
)
panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}")
}
}
ExpectedOutcome::Fail => {
Expand Down Expand Up @@ -187,8 +185,6 @@ pub fn quick_test() {
let syntax = root.syntax();
dbg!(&syntax, root.diagnostics(), root.has_errors());
if has_bogus_nodes_or_empty_slots(&syntax) {
panic!(
"modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}"
)
panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}")
}
}
4 changes: 1 addition & 3 deletions crates/biome_graphql_analyze/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ fn check_code_action(
assert_eq!(new_tree.to_string(), output);

if has_bogus_nodes_or_empty_slots(&new_tree) {
panic!(
"modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}"
)
panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}")
}

// Checks the returned tree contains no missing children node
Expand Down
6 changes: 1 addition & 5 deletions crates/biome_html_parser/src/lexer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ fn losslessness(string: String) -> bool {
});
let token_ranges = receiver
.recv_timeout(Duration::from_secs(2))
.unwrap_or_else(|_| {
panic!(
"Lexer is infinitely recursing with this code: ->{string}<-"
)
});
.unwrap_or_else(|_| panic!("Lexer is infinitely recursing with this code: ->{string}<-"));

let mut new_str = String::with_capacity(string.len());
let mut idx = TextSize::from(0);
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_html_parser/tests/spec_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ pub fn run(test_case: &str, _snapshot_name: &str, test_directory: &str, outcome_

let syntax = parsed.syntax();
if has_bogus_nodes_or_empty_slots(&syntax) {
panic!(
"modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}"
)
panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}")
}
}
ExpectedOutcome::Fail => {
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_js_analyze/src/utils/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ pub fn assert_remove_identifier_a_ok<Anc: AstNode<Language = JsLanguage> + Debug
type_name::<Anc>()
)
}),
_ => panic!(
"Expected exactly one identifier named a, but got {identifiers_a:?}"
),
_ => panic!("Expected exactly one identifier named a, but got {identifiers_a:?}"),
};

let mut batch = r.tree().begin();
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_js_analyze/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ fn check_code_action(
assert_eq!(new_tree.to_string(), output);

if has_bogus_nodes_or_empty_slots(&new_tree) {
panic!(
"modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}"
)
panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}")
}

// Checks the returned tree contains no missing children node
Expand Down
6 changes: 1 addition & 5 deletions crates/biome_js_parser/src/lexer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ fn losslessness(string: String) -> bool {
});
let token_ranges = receiver
.recv_timeout(Duration::from_secs(2))
.unwrap_or_else(|_| {
panic!(
"Lexer is infinitely recursing with this code: ->{string}<-"
)
});
.unwrap_or_else(|_| panic!("Lexer is infinitely recursing with this code: ->{string}<-"));

let mut new_str = String::with_capacity(string.len());
let mut idx = TextSize::from(0);
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_js_parser/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ where
let has_missing_children = debug_tree.contains("missing (required)");

if has_bogus_nodes_or_empty_slots(&syntax) {
panic!(
"modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}"
)
panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}")
}

if !program.has_errors() && !has_missing_children {
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_js_parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ pub fn quick_test() {
dbg!(&syntax, root.diagnostics(), root.has_errors());

if has_bogus_nodes_or_empty_slots(&syntax) {
panic!(
"modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}"
)
panic!("modified tree has bogus nodes or empty slots:\n{syntax:#?} \n\n {syntax}")
}
}
20 changes: 4 additions & 16 deletions crates/biome_js_semantic/src/semantic_model/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,14 @@ mod test {
JsSyntaxKind::JS_IDENTIFIER_BINDING => {
let binding = JsIdentifierBinding::cast(node).unwrap();
// These do the same thing, but with different APIs
assert!(
is_exported == model.is_exported(&binding),
"at \"{code}\""
);
assert!(
is_exported == binding.is_exported(&model),
"at \"{code}\""
);
assert!(is_exported == model.is_exported(&binding), "at \"{code}\"");
assert!(is_exported == binding.is_exported(&model), "at \"{code}\"");
}
JsSyntaxKind::TS_IDENTIFIER_BINDING => {
let binding = TsIdentifierBinding::cast(node).unwrap();
// These do the same thing, but with different APIs
assert!(
is_exported == model.is_exported(&binding),
"at \"{code}\""
);
assert!(
is_exported == binding.is_exported(&model),
"at \"{code}\""
);
assert!(is_exported == model.is_exported(&binding), "at \"{code}\"");
assert!(is_exported == binding.is_exported(&model), "at \"{code}\"");
}
JsSyntaxKind::JS_REFERENCE_IDENTIFIER => {
// Do nothing.
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_js_transform/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ fn check_transformation(
assert_eq!(new_tree.to_string(), output);

if has_bogus_nodes_or_empty_slots(&new_tree) {
panic!(
"modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}"
)
panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}")
}

// Checks the returned tree contains no missing children node
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_json_analyze/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ fn check_code_action(path: &Path, source: &str, action: &AnalyzerAction<JsonLang
assert_eq!(new_tree.to_string(), output);

if has_bogus_nodes_or_empty_slots(&new_tree) {
panic!(
"modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}"
)
panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}")
}

// Checks the returned tree contains no missing children node
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_migrate/tests/spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ fn check_code_action(path: &Path, source: &str, action: &AnalyzerAction<JsonLang
assert_eq!(new_tree.to_string(), output);

if has_bogus_nodes_or_empty_slots(&new_tree) {
panic!(
"modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}"
)
panic!("modified tree has bogus nodes or empty slots:\n{new_tree:#?} \n\n {new_tree}")
}

// Checks the returned tree contains no missing children node
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_parser/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ impl ParseDiagnostic {
}

let msg = if p.source().text().text_len() <= range.start() {
format!(
"Expected {joined_names} but instead found the end of the file."
)
format!("Expected {joined_names} but instead found the end of the file.")
} else {
format!(
"Expected {} but instead found '{}'.",
Expand Down
12 changes: 6 additions & 6 deletions crates/biome_rowan/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,9 @@ pub mod support {
match parent.slots().nth(slot_index)? {
SyntaxSlot::Empty { .. } => None,
SyntaxSlot::Node(node) => Some(N::unwrap_cast(node)),
SyntaxSlot::Token(token) => panic!(
"expected a node in the slot {slot_index} but found token {token:?}"
),
SyntaxSlot::Token(token) => {
panic!("expected a node in the slot {slot_index} but found token {token:?}")
}
}
}

Expand All @@ -833,9 +833,9 @@ pub mod support {
match parent.slots().nth(slot_index)? {
SyntaxSlot::Empty { .. } => None,
SyntaxSlot::Token(token) => Some(token),
SyntaxSlot::Node(node) => panic!(
"expected a token in the slot {slot_index} but found node {node:?}"
),
SyntaxSlot::Node(node) => {
panic!("expected a token in the slot {slot_index} but found node {node:?}")
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions crates/biome_rowan/src/syntax_node_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ mod tests {
let t2 = build_tree(t2).text();
let expected = t1.to_string() == t2.to_string();
let actual = t1 == t2;
assert_eq!(
expected, actual,
"`{t1}` (SyntaxText) `{t2}` (SyntaxText)"
);
assert_eq!(expected, actual, "`{t1}` (SyntaxText) `{t2}` (SyntaxText)");
let actual = t1 == *t2.to_string();
assert_eq!(expected, actual, "`{t1}` (SyntaxText) `{t2}` (&str)");
}
Expand Down
15 changes: 4 additions & 11 deletions xtask/coverage/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ pub fn coverage_compare(
};

if !base_result_dir.exists() {
panic!(
"The path to the base results doesn't exist: {base_result_dir:?}"
);
panic!("The path to the base results doesn't exist: {base_result_dir:?}");
}

if !&new_result_dir.exists() {
panic!(
"The path to the new results doesn't exist: {new_result_dir:?}"
);
panic!("The path to the new results doesn't exist: {new_result_dir:?}");
}

let mut base_results = read_test_results(base_result_dir.as_path(), "base")
Expand Down Expand Up @@ -71,9 +67,6 @@ fn read_test_results(path: &Path, name: &'static str) -> HashMap<String, TestRes
let content = decode_maybe_utf16_string(&buffer)
.unwrap_or_else(|err| panic!("Can't read the file of the {name} results: {err:?}"));

serde_json::from_str(&content).unwrap_or_else(|err| {
panic!(
"Can't parse the JSON file of the {name} results: {err:?}"
)
})
serde_json::from_str(&content)
.unwrap_or_else(|err| panic!("Can't parse the JSON file of the {name} results: {err:?}"))
}

0 comments on commit add4ec9

Please sign in to comment.