chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but hey, it's a start. Release Notes: - N/A
This commit is contained in:
parent
93249fc82b
commit
e6c1c51b37
361 changed files with 3530 additions and 3587 deletions
|
@ -20,7 +20,7 @@ pub async fn extract_zip<R: AsyncRead + Unpin>(destination: &Path, reader: R) ->
|
|||
std::fs::create_dir_all(&path)?;
|
||||
} else {
|
||||
let parent_dir = path.parent().expect("failed to get parent directory");
|
||||
std::fs::create_dir_all(&parent_dir)?;
|
||||
std::fs::create_dir_all(parent_dir)?;
|
||||
let mut file = smol::fs::File::create(&path).await?;
|
||||
futures::io::copy(entry_reader, &mut file).await?;
|
||||
}
|
||||
|
@ -82,11 +82,11 @@ mod tests {
|
|||
let dir = tempfile::tempdir().unwrap();
|
||||
let dst = dir.path();
|
||||
|
||||
std::fs::write(&dst.join("test"), "Hello world.").unwrap();
|
||||
std::fs::create_dir_all(&dst.join("foo/bar")).unwrap();
|
||||
std::fs::write(&dst.join("foo/bar.txt"), "Foo bar.").unwrap();
|
||||
std::fs::write(&dst.join("foo/dar.md"), "Bar dar.").unwrap();
|
||||
std::fs::write(&dst.join("foo/bar/dar你好.txt"), "你好世界").unwrap();
|
||||
std::fs::write(dst.join("test"), "Hello world.").unwrap();
|
||||
std::fs::create_dir_all(dst.join("foo/bar")).unwrap();
|
||||
std::fs::write(dst.join("foo/bar.txt"), "Foo bar.").unwrap();
|
||||
std::fs::write(dst.join("foo/dar.md"), "Bar dar.").unwrap();
|
||||
std::fs::write(dst.join("foo/bar/dar你好.txt"), "你好世界").unwrap();
|
||||
|
||||
dir
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ mod tests {
|
|||
let zip_file = test_dir.path().join("test.zip");
|
||||
|
||||
smol::block_on(async {
|
||||
compress_zip(&test_dir.path(), &zip_file).await.unwrap();
|
||||
compress_zip(test_dir.path(), &zip_file).await.unwrap();
|
||||
let reader = read_archive(&zip_file).await;
|
||||
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
|
|
@ -72,7 +72,7 @@ pub trait NodeRuntime: Send + Sync {
|
|||
|
||||
async fn npm_package_installed_version(
|
||||
&self,
|
||||
local_package_directory: &PathBuf,
|
||||
local_package_directory: &Path,
|
||||
name: &str,
|
||||
) -> Result<Option<String>>;
|
||||
|
||||
|
@ -80,7 +80,7 @@ pub trait NodeRuntime: Send + Sync {
|
|||
&self,
|
||||
package_name: &str,
|
||||
local_executable_path: &Path,
|
||||
local_package_directory: &PathBuf,
|
||||
local_package_directory: &Path,
|
||||
latest_version: &str,
|
||||
) -> bool {
|
||||
// In the case of the local system not having the package installed,
|
||||
|
@ -102,7 +102,7 @@ pub trait NodeRuntime: Send + Sync {
|
|||
let Some(installed_version) = Version::parse(&installed_version).log_err() else {
|
||||
return true;
|
||||
};
|
||||
let Some(latest_version) = Version::parse(&latest_version).log_err() else {
|
||||
let Some(latest_version) = Version::parse(latest_version).log_err() else {
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -360,10 +360,10 @@ impl NodeRuntime for RealNodeRuntime {
|
|||
|
||||
async fn npm_package_installed_version(
|
||||
&self,
|
||||
local_package_directory: &PathBuf,
|
||||
local_package_directory: &Path,
|
||||
name: &str,
|
||||
) -> Result<Option<String>> {
|
||||
let mut package_json_path = local_package_directory.clone();
|
||||
let mut package_json_path = local_package_directory.to_owned();
|
||||
package_json_path.extend(["node_modules", name, "package.json"]);
|
||||
|
||||
let mut file = match fs::File::open(package_json_path).await {
|
||||
|
@ -394,7 +394,7 @@ impl NodeRuntime for RealNodeRuntime {
|
|||
packages: &[(&str, &str)],
|
||||
) -> Result<()> {
|
||||
let packages: Vec<_> = packages
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|(name, version)| format!("{name}@{version}"))
|
||||
.collect();
|
||||
|
||||
|
@ -448,7 +448,7 @@ impl NodeRuntime for FakeNodeRuntime {
|
|||
|
||||
async fn npm_package_installed_version(
|
||||
&self,
|
||||
_local_package_directory: &PathBuf,
|
||||
_local_package_directory: &Path,
|
||||
name: &str,
|
||||
) -> Result<Option<String>> {
|
||||
unreachable!("Should not query npm package '{name}' for installed version")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue