mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-01 22:56:54 -06:00
Refactor the gridcraft apps for strict Clippy checks
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use super::calc::formula_text;
|
||||
use super::package::{REBUILT_KINDS, relationship_kinds, validate_package};
|
||||
use super::*;
|
||||
use super::{BTreeSet, Category, Cell, CellError, CellRef, Diffs, Options, RoundTrip, Sheet, Value, Workbook, number_text, quote_sheet};
|
||||
|
||||
// ---------------------------------------------------------------- round trip
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ fn local_name(name: &[u8]) -> &[u8] {
|
||||
}
|
||||
|
||||
/// `(element local name, attributes)` for every start/empty element of an XML part.
|
||||
fn xml_elements(xml: &[u8]) -> Result<Vec<(String, Vec<(String, String)>)>, String> {
|
||||
type XmlElement = (String, Vec<(String, String)>);
|
||||
|
||||
fn xml_elements(xml: &[u8]) -> Result<Vec<XmlElement>, String> {
|
||||
use quick_xml::events::Event;
|
||||
let mut reader = quick_xml::Reader::from_reader(xml);
|
||||
let mut buf = Vec::new();
|
||||
|
||||
@@ -131,7 +131,7 @@ fn fit(s: &str, w: usize) -> String {
|
||||
if n <= w { s.to_string() } else { format!("…{}", s.chars().skip(n + 1 - w).collect::<String>()) }
|
||||
}
|
||||
|
||||
pub(super) fn print_human(reports: &[FileReport], opts: &Options) {
|
||||
fn print_file_reports(reports: &[FileReport]) {
|
||||
for r in reports {
|
||||
outln!("== {}", r.path);
|
||||
if let Some(e) = &r.error {
|
||||
@@ -186,7 +186,9 @@ pub(super) fn print_human(reports: &[FileReport], opts: &Options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
outln!("");
|
||||
}
|
||||
|
||||
fn print_file_table(reports: &[FileReport]) {
|
||||
let w = reports.iter().map(|r| r.path.chars().count()).max().unwrap_or(4).clamp(4, 50);
|
||||
outln!(
|
||||
"{:<w$} {:>8} {:>8} {:>8} {:>8} {:>9} {:>8} round trip",
|
||||
@@ -220,7 +222,9 @@ pub(super) fn print_human(reports: &[FileReport], opts: &Options) {
|
||||
c.volatile
|
||||
);
|
||||
}
|
||||
let t = totals(reports);
|
||||
}
|
||||
|
||||
fn print_rankings(t: &Totals, opts: &Options) {
|
||||
let top = ranked(&t.functions);
|
||||
if !top.is_empty() {
|
||||
outln!("");
|
||||
@@ -239,6 +243,9 @@ pub(super) fn print_human(reports: &[FileReport], opts: &Options) {
|
||||
outln!(" {n:>8} {sig}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn print_totals(t: &Totals) {
|
||||
outln!("");
|
||||
outln!("files: {} ({} opened, {} failed to open)", t.files, t.opened, t.failed);
|
||||
outln!(
|
||||
@@ -262,3 +269,12 @@ pub(super) fn print_human(reports: &[FileReport], opts: &Options) {
|
||||
if cats.is_empty() { String::new() } else { format!("; categories (files): {}", cats.join(", ")) }
|
||||
);
|
||||
}
|
||||
|
||||
pub(super) fn print_human(reports: &[FileReport], opts: &Options) {
|
||||
print_file_reports(reports);
|
||||
outln!("");
|
||||
print_file_table(reports);
|
||||
let t = totals(reports);
|
||||
print_rankings(&t, opts);
|
||||
print_totals(&t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user