Skip to content

Commit f22e23c

Browse files
committed
Apply new cargo fmt
1 parent 77b158b commit f22e23c

24 files changed

Lines changed: 127 additions & 107 deletions

File tree

cli/src/api/endpoints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ mod test {
383383
"https://example.com/a/api/v0/",
384384
);
385385

386-
// Maybe an error should be reported in this case instead of stripping the
387-
// extras.
386+
// Maybe an error should be reported in this case instead of stripping
387+
// the extras.
388388
assert_eq!(
389389
get_api_path("https://example.com/search?q=invalid#search").unwrap().as_str(),
390390
"https://example.com/search/api/v0/",

cli/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const FILTER_ABOUT: &str = r#"Provide a filter used to limit the issues displaye
2525
"#;
2626

2727
pub fn app() -> Command {
28-
// NOTE: We do not use the `arg!` macro here since it causes a stack overflow on
29-
// Windows.
28+
// NOTE: We do not use the `arg!` macro here since it causes a stack
29+
// overflow on Windows.
3030
#[allow(unused_mut)]
3131
let mut app = Command::new("phylum")
3232
.bin_name("phylum")

cli/src/bin/phylum.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ fn exit_fail(message: impl Display, exit_code: ExitCode) -> ! {
3838
async fn api_factory(config: Config, timeout: Option<u64>) -> Result<PhylumApi> {
3939
let api = PhylumApi::new(config, timeout).await?;
4040

41-
// PhylumApi may have had to log in, updating the auth info so we should save
42-
// the config
41+
// PhylumApi may have had to log in, updating the auth info so we should
42+
// save the config
4343
let api_config = api.config();
4444
api_config
4545
.save()
@@ -119,9 +119,9 @@ async fn handle_commands() -> CommandResult {
119119
check_for_updates(&mut config).await?;
120120
}
121121

122-
// Get the future, but don't await. Commands that require access to the API will
123-
// await on this, so that the API is not instantiated ahead of time for
124-
// subcommands that don't require it.
122+
// Get the future, but don't await. Commands that require access to the API
123+
// will await on this, so that the API is not instantiated ahead of time
124+
// for subcommands that don't require it.
125125
let api = api_factory(config.clone(), timeout);
126126

127127
match subcommand {

cli/src/commands/extensions/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ async fn create_project(
360360
let state = ExtensionState::from(op_state);
361361
let api = state.api().await?;
362362

363-
// Retrieve the id if the project already exists, otherwise return the id or the
364-
// error.
363+
// Retrieve the id if the project already exists, otherwise return the id or
364+
// the error.
365365
match api.create_project(&name, organization.clone(), group.clone(), repository_url).await {
366366
Err(PhylumApiError::Response(ResponseError { code: StatusCode::CONFLICT, .. })) => api
367367
.get_project_id(&name, organization.as_deref(), group.as_deref())

cli/src/commands/extensions/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ async fn handle_install_extension(
179179
accept_permissions: bool,
180180
overwrite: bool,
181181
) -> CommandResult {
182-
// NOTE: Extension installation without slashes is reserved for the marketplace.
182+
// NOTE: Extension installation without slashes is reserved for the
183+
// marketplace.
183184
if !path.contains('/') && !path.contains('\\') {
184185
return Err(anyhow!("Ambiguous extension URI '{}', use './{0}' instead", path));
185186
}
@@ -318,8 +319,8 @@ async fn handle_uninstall_extension(name: &str) -> CommandResult {
318319
pub async fn handle_create_extension(path: &str) -> CommandResult {
319320
// Error out when target is already occupied.
320321
//
321-
// This allows use to use [`fs::create_dir_all`] without having to worry about
322-
// reusing an existing directory.
322+
// This allows use to use [`fs::create_dir_all`] without having to worry
323+
// about reusing an existing directory.
323324
let extension_path = PathBuf::from(path);
324325
if extension_path.exists() {
325326
return Err(anyhow!("Destination {path:?} already exists"));

cli/src/commands/parse.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ fn depfile_parsing_sandbox(canonical_manifest_path: &Path) -> Result<Birdcage> {
427427

428428
// Allow any executable in common binary directories.
429429
//
430-
// Reading binaries shouldn't be an attack vector, but significantly simplifies
431-
// complex ecosystems (like Python's symlinks).
430+
// Reading binaries shouldn't be an attack vector, but significantly
431+
// simplifies complex ecosystems (like Python's symlinks).
432432
permissions::add_exception(&mut birdcage, Exception::ExecuteAndRead("/usr/bin".into()))?;
433433
permissions::add_exception(&mut birdcage, Exception::ExecuteAndRead("/bin".into()))?;
434434

@@ -577,43 +577,46 @@ mod tests {
577577
let tempdir = tempfile::tempdir().unwrap();
578578
let tempdir = tempdir.path().canonicalize().unwrap();
579579

580-
// Create a sample project directory named "sample" inside the "projects"
581-
// directory. Also create a "Cargo.lock" file inside the "sample"
582-
// directory.
580+
// Create a sample project directory named "sample" inside the
581+
// "projects" directory. Also create a "Cargo.lock" file inside
582+
// the "sample" directory.
583583
let sample_dir = tempdir.join("sample");
584584
let lockfile_path = sample_dir.join("Cargo.lock");
585585
fs::create_dir_all(&sample_dir).unwrap();
586586
File::create(&lockfile_path).unwrap();
587587

588588
// Change the current directory to the "sample" project directory.
589589
let path = relative_path(&sample_dir, &lockfile_path).unwrap();
590-
// The path to the lockfile should now be just the filename since it's in the
591-
// current directory.
590+
// The path to the lockfile should now be just the filename since it's
591+
// in the current directory.
592592
assert_eq!(path.as_os_str(), "Cargo.lock");
593593

594-
// Create a subdirectory named "sub" within the "sample" project directory.
594+
// Create a subdirectory named "sub" within the "sample" project
595+
// directory.
595596
let sub_dir = sample_dir.join("sub");
596597
fs::create_dir_all(&sub_dir).unwrap();
597598

598599
// Change the current directory to the new "sub" directory.
599600
let rel_lockfile_path = sub_dir.join("../Cargo.lock");
600601

601-
// Get the relative path from the sub directory to the lockfile in the sample
602-
// directory.
602+
// Get the relative path from the sub directory to the lockfile in the
603+
// sample directory.
603604
let path = relative_path(&sample_dir, &rel_lockfile_path).unwrap();
604-
// The path to the lockfile should be the same as before since we are looking
605-
// relative to the sample directory.
605+
// The path to the lockfile should be the same as before since we are
606+
// looking relative to the sample directory.
606607
assert_eq!(path.as_os_str(), "Cargo.lock");
607608

608-
// Create another "Cargo.lock" file one level above the "sample" directory.
609+
// Create another "Cargo.lock" file one level above the "sample"
610+
// directory.
609611
let above_lockfile_path = tempdir.join("Cargo.lock");
610612
File::create(above_lockfile_path).unwrap();
611613
let rel_lockfile_path = sub_dir.join("../../Cargo.lock");
612614

613-
// Although the current directory is still "sub", get the relative path to the
614-
// lockfile above the "sample" directory.
615+
// Although the current directory is still "sub", get the relative path
616+
// to the lockfile above the "sample" directory.
615617
let path = relative_path(&sample_dir, &rel_lockfile_path).unwrap();
616-
// The path to the lockfile should be relative to the "sample" directory.
618+
// The path to the lockfile should be relative to the "sample"
619+
// directory.
617620
assert_eq!(path, Path::new("../Cargo.lock"));
618621
}
619622
}

cli/src/commands/sandbox.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ pub async fn handle_sandbox(matches: &ArgMatches) -> CommandResult {
3232
};
3333

3434
if let Some(mut code) = status.code() {
35-
// Remap exit code if it matches our sandbox start failure indicator, to ensure
36-
// we can detect the failure reliably.
35+
// Remap exit code if it matches our sandbox start failure indicator, to
36+
// ensure we can detect the failure reliably.
3737
if code == i32::from(&ExitCode::SandboxStart) {
3838
code = i32::from(&ExitCode::SandboxStartCollision);
3939
}

cli/src/config.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ where
156156

157157
// Use target directory for temporary file path.
158158
//
159-
// It's not possible to create the file on tmpfs since the configuration file is
160-
// usually not on the same device, which causes `fs::rename` to fail.
159+
// It's not possible to create the file on tmpfs since the configuration
160+
// file is usually not on the same device, which causes `fs::rename` to
161+
// fail.
161162
let file_name = path
162163
.file_name()
163164
.and_then(|name| name.to_str())

cli/src/deno.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ impl ModuleLoader for ExtensionsModuleLoader {
190190
}
191191

192192
// Determine source file type.
193-
// We do not care about invalid URLs yet: This match statement is inexpensive,
194-
// bears no risk and does not do I/O -- it operates fully off of the
195-
// contents of the URL.
193+
// We do not care about invalid URLs yet: This match statement is
194+
// inexpensive, bears no risk and does not do I/O -- it
195+
// operates fully off of the contents of the URL.
196196
let media_type = MediaType::from_specifier(&module_specifier);
197197
let (module_type, should_transpile) = match media_type {
198198
MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => {
@@ -210,9 +210,9 @@ impl ModuleLoader for ExtensionsModuleLoader {
210210
_ => return Err(anyhow!("Unknown JS module format: {}", module_specifier)),
211211
};
212212

213-
// Load either a local file under the extensions directory, or a Deno standard
214-
// library module. Reject all URLs that do not fit these two use
215-
// cases.
213+
// Load either a local file under the extensions directory, or a
214+
// Deno standard library module. Reject all URLs that do
215+
// not fit these two use cases.
216216
let code = match module_specifier.scheme() {
217217
"file" => {
218218
ExtensionsModuleLoader::load_from_filesystem(&extension_path, &module_specifier)

cli/src/fs_compare.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ fn file_compare<A: AsRef<Path>, B: AsRef<Path>>(a: A, b: B) -> Result<bool> {
6868
let cmp_len = std::cmp::min(a_buf.len(), b_buf.len());
6969
if cmp_len == 0 {
7070
// Only 1 EOF. Files are different
71-
// Note: Because of the file length check above, this should be impossible
72-
// except perhaps if a file is actively being changed.
71+
// Note: Because of the file length check above, this should be
72+
// impossible except perhaps if a file is actively
73+
// being changed.
7374
log::trace!("File length mismatch (race condition?)");
7475
return Ok(false);
7576
}

0 commit comments

Comments
 (0)