Move to using clippy (#1142)

* Clippy fixes

* Finish converting to use clippy

* fix warnings in new master

* fix windows

* fix windows

Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me>
This commit is contained in:
Jonathan Turner
2019-12-31 20:36:08 +13:00
committed by GitHub
parent 8093612cac
commit 72838cc083
93 changed files with 754 additions and 852 deletions

View File

@ -81,8 +81,8 @@ impl Plugin for Str {
}) = args.get("find-replace")
{
self.for_replace(ReplaceAction::FindAndReplace(
arguments.get(0).unwrap().as_string()?.to_string(),
arguments.get(1).unwrap().as_string()?.to_string(),
arguments.get(0).unwrap().as_string()?,
arguments.get(1).unwrap().as_string()?,
));
}
}

View File

@ -72,7 +72,7 @@ mod integration {
CallStub::new()
.with_named_parameter(
"find-replace",
table(&vec![string(&search_argument), string(&replace_argument)]),
table(&[string(&search_argument), string(&replace_argument)]),
)
.create(),
)
@ -91,7 +91,7 @@ mod integration {
.create(),
)
.setup(|plugin, _| {
plugin.expect_field(column_path(&vec![string("package"), string("description")]))
plugin.expect_field(column_path(&[string("package"), string("description")]))
});
}
@ -194,7 +194,7 @@ mod integration {
.with_parameter("staff")
.with_named_parameter(
"find-replace",
table(&vec![string("kittens"), string("jotandrehuda")]),
table(&[string("kittens"), string("jotandrehuda")]),
)
.create(),
)
@ -353,7 +353,7 @@ mod integration {
CallStub::new()
.with_named_parameter(
"find-replace",
table(&vec![string("kittens"), string("jotandrehuda")]),
table(&[string("kittens"), string("jotandrehuda")]),
)
.create(),
)

View File

@ -20,6 +20,7 @@ pub enum ReplaceAction {
FindAndReplace(String, String),
}
#[derive(Default)]
pub struct Str {
pub field: Option<Tagged<ColumnPath>>,
pub error: Option<String>,
@ -27,12 +28,8 @@ pub struct Str {
}
impl Str {
pub fn new() -> Str {
Str {
field: None,
error: None,
action: None,
}
pub fn new() -> Self {
Default::default()
}
fn apply(&self, input: &str) -> Result<UntaggedValue, ShellError> {
@ -174,12 +171,11 @@ impl Str {
);
let got = replace_for?;
let replacement = self.strutils(got.clone())?;
let replacement = self.strutils(got)?;
match value.replace_data_at_column_path(
&f,
replacement.value.clone().into_untagged_value(),
) {
match value
.replace_data_at_column_path(&f, replacement.value.into_untagged_value())
{
Some(v) => Ok(v),
None => Err(ShellError::labeled_error(
"str could not find field to replace",