Skip to content

Commit

Permalink
fix: handle clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jul 31, 2023
1 parent 53c2eb4 commit 89fcc32
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 5 additions & 1 deletion crates/lockfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ impl Lockfile {

pub fn create_or_open() -> Result<Lockfile, LockfileError> {
let yaml_path = Lockfile::path()?;
if yaml_path.exists() { Ok(Lockfile::open()?) } else { Ok(Lockfile::create()?) }
if yaml_path.exists() {
Ok(Lockfile::open()?)
} else {
Ok(Lockfile::create()?)
}
}

pub fn save(&self) -> Result<(), LockfileError> {
Expand Down
20 changes: 11 additions & 9 deletions crates/package_json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ impl PackageJson {
}
}

if if_present { Ok(None) } else { Err(PackageJsonError::NoScript(command.to_string())) }
if if_present {
Ok(None)
} else {
Err(PackageJsonError::NoScript(command.to_string()))
}
}
}

Expand Down Expand Up @@ -291,13 +295,11 @@ mod tests {
let tmp = NamedTempFile::new().unwrap();
write!(tmp.as_file(), "{}", data).unwrap();
let package_json = PackageJson::create_if_needed(&tmp.path().to_path_buf()).unwrap();
assert!(
package_json
.get_dependencies(vec![DependencyGroup::Peer])
.contains_key("fast-querystring")
);
assert!(
package_json.get_dependencies(vec![DependencyGroup::Default]).contains_key("fastify")
);
assert!(package_json
.get_dependencies(vec![DependencyGroup::Peer])
.contains_key("fast-querystring"));
assert!(package_json
.get_dependencies(vec![DependencyGroup::Default])
.contains_key("fastify"));
}
}
4 changes: 2 additions & 2 deletions tasks/benchmark/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{fs, path::PathBuf};
use std::{fs, path::Path};

use criterion::{Criterion, Throughput};
use mockito::ServerGuard;
use pico_args::Arguments;
use project_root::get_project_root;
use tempfile::tempdir;

fn bench_tarball(c: &mut Criterion, server: &mut ServerGuard, fixtures_folder: &PathBuf) {
fn bench_tarball(c: &mut Criterion, server: &mut ServerGuard, fixtures_folder: &Path) {
let mut group = c.benchmark_group("tarball");
let file = fs::read(fixtures_folder.join("@fastify+error-3.3.0.tgz")).unwrap();
server.mock("GET", "/@fastify+error-3.3.0.tgz").with_status(201).with_body(&file).create();
Expand Down

0 comments on commit 89fcc32

Please sign in to comment.