mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:25:42 +02:00
Fix a bunch of future clippy warnings (#3586)
* Fix a bunch of future clippy warnings * Fix a bunch of future clippy warnings
This commit is contained in:
@ -20,7 +20,7 @@ impl Trusted {
|
||||
}
|
||||
|
||||
pub fn is_file_trusted(nu_env_file: &Path, content: &[u8]) -> Result<bool, ShellError> {
|
||||
let contentdigest = Sha256::digest(&content).as_slice().to_vec();
|
||||
let contentdigest = Sha256::digest(content).as_slice().to_vec();
|
||||
let nufile = std::fs::canonicalize(nu_env_file)?;
|
||||
|
||||
let trusted = read_trusted()?;
|
||||
|
@ -106,11 +106,11 @@ fn is_existent_local_cfg(cfg_file_path: &Path) -> Result<bool, ShellError> {
|
||||
|
||||
fn is_trusted_local_cfg_content(cfg_file_path: &Path, content: &[u8]) -> Result<bool, ShellError> {
|
||||
//This checks whether user used `autoenv trust` to mark this cfg as secure
|
||||
if !super::is_file_trusted(&cfg_file_path, &content)? {
|
||||
if !super::is_file_trusted(cfg_file_path, content)? {
|
||||
//Notify user about present config, but not trusted
|
||||
Err(ShellError::untagged_runtime_error(
|
||||
format!("{:?} is untrusted. Run 'autoenv trust {:?}' to trust it.\nThis needs to be done after each change to the file.",
|
||||
cfg_file_path, cfg_file_path.parent().unwrap_or_else(|| &Path::new("")))))
|
||||
cfg_file_path, cfg_file_path.parent().unwrap_or_else(|| Path::new("")))))
|
||||
} else {
|
||||
Ok(true)
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ pub fn string_to_lookup_value(str_prim: &str) -> String {
|
||||
fn update_hashmap(key: &str, val: &Value, hm: &mut HashMap<String, Style>) {
|
||||
if let Ok(var) = val.as_string() {
|
||||
let color = lookup_ansi_color_style(var);
|
||||
let prim = string_to_lookup_value(&key);
|
||||
let prim = string_to_lookup_value(key);
|
||||
if let Some(v) = hm.get_mut(&prim) {
|
||||
*v = color;
|
||||
} else {
|
||||
@ -157,64 +157,64 @@ pub fn get_color_config(config: &NuConfig) -> HashMap<String, Style> {
|
||||
for (key, value) in primitive_color_vars.row_entries() {
|
||||
match key.as_ref() {
|
||||
"primitive_int" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_decimal" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_filesize" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_string" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_line" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_columnpath" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_pattern" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_boolean" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_date" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_duration" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_range" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_path" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"primitive_binary" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"separator_color" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"header_align" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"header_color" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"header_bold" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"header_style" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"index_color" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
"leading_trailing_space_bg" => {
|
||||
update_hashmap(&key, &value, &mut hm);
|
||||
update_hashmap(key, value, &mut hm);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ pub fn group(
|
||||
|
||||
for (idx, value) in values.table_entries().enumerate() {
|
||||
let group_key = if let Some(ref grouper) = grouper {
|
||||
grouper(idx, &value)
|
||||
grouper(idx, value)
|
||||
} else {
|
||||
as_string(&value)
|
||||
as_string(value)
|
||||
};
|
||||
|
||||
let group = groups.entry(group_key?).or_insert(vec![]);
|
||||
|
@ -51,7 +51,7 @@ fn formula(
|
||||
calculator: Box<dyn Fn(Vec<&Value>) -> Result<Value, ShellError> + Send + Sync + 'static>,
|
||||
) -> Box<dyn Fn(&Value, Vec<&Value>) -> Result<Value, ShellError> + Send + Sync + 'static> {
|
||||
Box::new(move |acc, datax| -> Result<Value, ShellError> {
|
||||
let result = match unsafe_compute_values(Operator::Multiply, &acc, &acc_begin) {
|
||||
let result = match unsafe_compute_values(Operator::Multiply, acc, &acc_begin) {
|
||||
Ok(v) => v.into_untagged_value(),
|
||||
Err((left_type, right_type)) => {
|
||||
return Err(ShellError::coerce_error(
|
||||
@ -164,7 +164,7 @@ pub fn sum(data: Vec<&Value>) -> Result<Value, ShellError> {
|
||||
for value in data {
|
||||
match value.value {
|
||||
UntaggedValue::Primitive(_) => {
|
||||
acc = match unsafe_compute_values(Operator::Plus, &acc, &value) {
|
||||
acc = match unsafe_compute_values(Operator::Plus, &acc, value) {
|
||||
Ok(v) => v,
|
||||
Err((left_type, right_type)) => {
|
||||
return Err(ShellError::coerce_error(
|
||||
@ -314,8 +314,8 @@ pub fn percentages(
|
||||
.filter_map(|s| {
|
||||
let hundred = UntaggedValue::decimal_from_float(100.0, tag.span);
|
||||
|
||||
match unsafe_compute_values(Operator::Divide, &hundred, &maxima) {
|
||||
Ok(v) => match unsafe_compute_values(Operator::Multiply, &s, &v) {
|
||||
match unsafe_compute_values(Operator::Divide, &hundred, maxima) {
|
||||
Ok(v) => match unsafe_compute_values(Operator::Multiply, s, &v) {
|
||||
Ok(v) => Some(v.into_untagged_value()),
|
||||
Err(_) => None,
|
||||
},
|
||||
|
@ -40,7 +40,7 @@ pub fn report(
|
||||
) -> Result<Model, ShellError> {
|
||||
let tag = tag.into();
|
||||
|
||||
let grouped = group(&values, &options.grouper, &tag)?;
|
||||
let grouped = group(values, &options.grouper, &tag)?;
|
||||
let splitted = split(&grouped, &options.splitter, &tag)?;
|
||||
|
||||
let x = grouped
|
||||
@ -48,7 +48,7 @@ pub fn report(
|
||||
.map(|(key, _)| key.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let x = sort_columns(&x, &options.format)?;
|
||||
let x = sort_columns(&x, options.format)?;
|
||||
|
||||
let mut y = splitted
|
||||
.row_entries()
|
||||
|
@ -28,7 +28,7 @@ pub fn split(
|
||||
));
|
||||
}
|
||||
|
||||
match group(&value, splitter, &tag) {
|
||||
match group(value, splitter, &tag) {
|
||||
Ok(grouped) => {
|
||||
for (split_label, subset) in grouped.row_entries() {
|
||||
let s = splits
|
||||
|
@ -590,7 +590,7 @@ pub fn style_leaf<'a>(
|
||||
let str_len = str.len();
|
||||
let paren_index = str.find('(').unwrap_or(str_len - 1);
|
||||
let prim_type = str[0..paren_index].to_string();
|
||||
style_primitive(&prim_type, &color_hash_map)
|
||||
style_primitive(&prim_type, color_hash_map)
|
||||
}
|
||||
_ => TextStyle::basic_left(),
|
||||
}
|
||||
|
Reference in New Issue
Block a user