Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Dec 20, 2023
1 parent cc0f93e commit b1822b5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
8 changes: 4 additions & 4 deletions cargo-workspaces/src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ impl Create {
.collect::<Vec<_>>();

let edition = match &self.edition {
Some(edition) => match edition {
&Edition::Fifteen => 0,
&Edition::Eighteen => 1,
&Edition::TwentyOne => 2,
Some(edition) => match *edition {
Edition::Fifteen => 0,
Edition::Eighteen => 1,
Edition::TwentyOne => 2,
},
None => Select::with_theme(&theme)
.items(&editions)
Expand Down
2 changes: 1 addition & 1 deletion cargo-workspaces/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Init {

members
.into_iter()
.for_each(|m| content.push_str(&format!(" \"{}\",\n", m.to_string())));
.for_each(|m| content.push_str(&format!(" \"{m}\",\n")));

content.push_str("]\n");

Expand Down
11 changes: 4 additions & 7 deletions cargo-workspaces/src/utils/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,12 @@ where
#[allow(clippy::if_same_then_else)]
if trimmed.starts_with("[package]") || trimmed.starts_with("[workspace.package]") {
context = Context::Package;
} else if let Some(_) = DEP_TABLE.captures(trimmed) {
} else if DEP_TABLE.captures(trimmed).is_some() {
context = Context::Dependencies;
} else if let Some(_) = BUILD_DEP_TABLE.captures(trimmed) {
} else if BUILD_DEP_TABLE.captures(trimmed).is_some() {
context = Context::Dependencies;
} else if DEV_DEP_TABLE.captures(trimmed).is_some() && dev_deps {
context = Context::Dependencies;
} else if let Some(_) = DEV_DEP_TABLE.captures(trimmed) {
// TODO: let-chain
if dev_deps {
context = Context::Dependencies;
}
} else if let Some(caps) = DEP_ENTRY.captures(trimmed) {
context = Context::DependencyEntry(caps[3].to_string());
} else if let Some(caps) = BUILD_DEP_ENTRY.captures(trimmed) {
Expand Down
18 changes: 10 additions & 8 deletions cargo-workspaces/src/utils/dev_dep_remover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ pub fn should_remove_dev_deps(deps: &[Dependency], pkgs: &[(Package, String)]) -
}

for dep in deps {
if dep.kind == DependencyKind::Development {
if names.contains(&&dep.name) && dep.source.is_none() && dep.req != no_version {
return true;
}
if dep.kind == DependencyKind::Development
&& names.contains(&&dep.name)
&& dep.source.is_none()
&& dep.req != no_version
{
return true;
}
}

Expand Down Expand Up @@ -160,7 +162,7 @@ mod tests {
path = "lib.rs"
"#;

create_dir(&tempdir.path().join("bar")).unwrap();
create_dir(tempdir.path().join("bar")).unwrap();
write(tempdir.path().join("bar").join("Cargo.toml"), member_toml).unwrap();

let (deps, pkgs) = args(&manifest_path, "foo");
Expand Down Expand Up @@ -199,7 +201,7 @@ mod tests {
path = "lib.rs"
"#;

create_dir(&tempdir.path().join("bar")).unwrap();
create_dir(tempdir.path().join("bar")).unwrap();
write(tempdir.path().join("bar").join("Cargo.toml"), member_toml).unwrap();

let (deps, pkgs) = args(&manifest_path, "foo");
Expand Down Expand Up @@ -245,7 +247,7 @@ mod tests {
path = "lib.rs"
"#;

create_dir(&tempdir.path().join("bar")).unwrap();
create_dir(tempdir.path().join("bar")).unwrap();
write(tempdir.path().join("bar").join("Cargo.toml"), member_toml).unwrap();

let (deps, pkgs) = args(&manifest_path, "foo");
Expand All @@ -256,7 +258,7 @@ mod tests {
fn args(manifest_path: &PathBuf, dep: &str) -> (Vec<Dependency>, Vec<(Package, String)>) {
let mut cmd = MetadataCommand::new();

cmd.manifest_path(&manifest_path);
cmd.manifest_path(manifest_path);
cmd.no_deps();

let metadata = cmd.exec().unwrap();
Expand Down
9 changes: 3 additions & 6 deletions cargo-workspaces/src/utils/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ use std::{
process::{Command, ExitStatus},
};

pub fn git<'a>(
root: &Utf8PathBuf,
args: &[&'a str],
) -> Result<(ExitStatus, String, String), Error> {
pub fn git(root: &Utf8PathBuf, args: &[&str]) -> Result<(ExitStatus, String, String), Error> {
debug!("git", args.to_vec().join(" "));

let output = Command::new("git")
Expand Down Expand Up @@ -145,9 +142,9 @@ impl GitOpt {
branch.clone()
};

let pattern = Glob::new(&allow_branch)?;
let pattern = Glob::new(allow_branch)?;

if !pattern.compile_matcher().is_match(&test_branch) {
if !pattern.compile_matcher().is_match(test_branch) {
return Err(Error::BranchNotAllowed {
branch,
pattern: pattern.glob().to_string(),
Expand Down

0 comments on commit b1822b5

Please sign in to comment.