mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Silence clippy warnings and format source code
This commit is contained in:
parent
fe2f3ba889
commit
4ffe1612ff
6 changed files with 55 additions and 49 deletions
|
@ -143,7 +143,7 @@ fn lazy_start(parent_state: ThreadSafeState) -> ResourceId {
|
||||||
}).map_err(|_| ())
|
}).map_err(|_| ())
|
||||||
}));
|
}));
|
||||||
rid
|
rid
|
||||||
}).clone()
|
}).to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn req(specifier: &str, referrer: &str, cmd_id: u32) -> Buf {
|
fn req(specifier: &str, referrer: &str, cmd_id: u32) -> Buf {
|
||||||
|
|
|
@ -579,8 +579,8 @@ fn fetch_remote_source_async(
|
||||||
),
|
),
|
||||||
|(
|
|(
|
||||||
dir,
|
dir,
|
||||||
maybe_initial_module_name,
|
mut maybe_initial_module_name,
|
||||||
maybe_initial_filename,
|
mut maybe_initial_filename,
|
||||||
module_name,
|
module_name,
|
||||||
filename,
|
filename,
|
||||||
)| {
|
)| {
|
||||||
|
@ -595,8 +595,6 @@ fn fetch_remote_source_async(
|
||||||
.map_err(DenoError::from);
|
.map_err(DenoError::from);
|
||||||
match resolve_result {
|
match resolve_result {
|
||||||
Ok((new_module_name, new_filename)) => {
|
Ok((new_module_name, new_filename)) => {
|
||||||
let mut maybe_initial_module_name = maybe_initial_module_name;
|
|
||||||
let mut maybe_initial_filename = maybe_initial_filename;
|
|
||||||
if maybe_initial_module_name.is_none() {
|
if maybe_initial_module_name.is_none() {
|
||||||
maybe_initial_module_name = Some(module_name.clone());
|
maybe_initial_module_name = Some(module_name.clone());
|
||||||
maybe_initial_filename = Some(filename.clone());
|
maybe_initial_filename = Some(filename.clone());
|
||||||
|
@ -623,7 +621,11 @@ fn fetch_remote_source_async(
|
||||||
// Write file and create .headers.json for the file.
|
// Write file and create .headers.json for the file.
|
||||||
deno_fs::write_file(&p, &source, 0o666)?;
|
deno_fs::write_file(&p, &source, 0o666)?;
|
||||||
{
|
{
|
||||||
save_source_code_headers(&filename, maybe_content_type.clone(), None);
|
save_source_code_headers(
|
||||||
|
&filename,
|
||||||
|
maybe_content_type.clone(),
|
||||||
|
None,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Check if this file is downloaded due to some old redirect request.
|
// Check if this file is downloaded due to some old redirect request.
|
||||||
if maybe_initial_filename.is_some() {
|
if maybe_initial_filename.is_some() {
|
||||||
|
@ -834,7 +836,7 @@ fn save_source_code_headers(
|
||||||
value_map.insert(REDIRECT_TO.to_string(), json!(redirect_to.unwrap()));
|
value_map.insert(REDIRECT_TO.to_string(), json!(redirect_to.unwrap()));
|
||||||
}
|
}
|
||||||
// Only save to file when there is actually data.
|
// Only save to file when there is actually data.
|
||||||
if value_map.len() > 0 {
|
if !value_map.is_empty() {
|
||||||
let _ = serde_json::to_string(&value_map).map(|s| {
|
let _ = serde_json::to_string(&value_map).map(|s| {
|
||||||
// It is possible that we need to create file
|
// It is possible that we need to create file
|
||||||
// with parent folders not yet created.
|
// with parent folders not yet created.
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub fn set_flags(
|
||||||
NO_COLOR Set to disable color";
|
NO_COLOR Set to disable color";
|
||||||
|
|
||||||
let clap_app = App::new("deno")
|
let clap_app = App::new("deno")
|
||||||
.global_settings(&vec![AppSettings::ColorNever])
|
.global_settings(&[AppSettings::ColorNever])
|
||||||
.settings(&app_settings[..])
|
.settings(&app_settings[..])
|
||||||
.after_help(env_variables_help)
|
.after_help(env_variables_help)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn resolve_uri_from_location(base_uri: &Uri, location: &str) -> Uri {
|
||||||
// assuming path-noscheme | path-empty
|
// assuming path-noscheme | path-empty
|
||||||
let mut new_uri_parts = base_uri.clone().into_parts();
|
let mut new_uri_parts = base_uri.clone().into_parts();
|
||||||
let base_uri_path_str = base_uri.path().to_owned();
|
let base_uri_path_str = base_uri.path().to_owned();
|
||||||
let segs: Vec<&str> = base_uri_path_str.rsplitn(2, "/").collect();
|
let segs: Vec<&str> = base_uri_path_str.rsplitn(2, '/').collect();
|
||||||
new_uri_parts.path_and_query = Some(
|
new_uri_parts.path_and_query = Some(
|
||||||
format!("{}/{}", segs.last().unwrap_or(&""), location)
|
format!("{}/{}", segs.last().unwrap_or(&""), location)
|
||||||
.parse()
|
.parse()
|
||||||
|
@ -86,7 +86,10 @@ pub fn fetch_string_once(
|
||||||
client
|
client
|
||||||
.get(url.clone())
|
.get(url.clone())
|
||||||
.map_err(DenoError::from)
|
.map_err(DenoError::from)
|
||||||
.and_then(move |response| -> Box<dyn Future<Item = FetchAttempt, Error = DenoError> + Send> {
|
.and_then(
|
||||||
|
move |response| -> Box<
|
||||||
|
dyn Future<Item = FetchAttempt, Error = DenoError> + Send,
|
||||||
|
> {
|
||||||
if response.status().is_redirection() {
|
if response.status().is_redirection() {
|
||||||
let location_string = response
|
let location_string = response
|
||||||
.headers()
|
.headers()
|
||||||
|
@ -98,17 +101,17 @@ pub fn fetch_string_once(
|
||||||
debug!("Redirecting to {}...", &location_string);
|
debug!("Redirecting to {}...", &location_string);
|
||||||
let new_url = resolve_uri_from_location(&url, &location_string);
|
let new_url = resolve_uri_from_location(&url, &location_string);
|
||||||
// Boxed trait object turns out to be the savior for 2+ types yielding same results.
|
// Boxed trait object turns out to be the savior for 2+ types yielding same results.
|
||||||
return Box::new(
|
return Box::new(future::ok(None).join3(
|
||||||
future::ok(None).join3(
|
|
||||||
future::ok(None),
|
future::ok(None),
|
||||||
future::ok(Some(FetchOnceResult::Redirect(new_url))
|
future::ok(Some(FetchOnceResult::Redirect(new_url))),
|
||||||
))
|
|
||||||
);
|
|
||||||
} else if response.status().is_client_error() || response.status().is_server_error() {
|
|
||||||
return Box::new(future::err(
|
|
||||||
errors::new(errors::ErrorKind::Other,
|
|
||||||
format!("Import '{}' failed: {}", &url, response.status()))
|
|
||||||
));
|
));
|
||||||
|
} else if response.status().is_client_error()
|
||||||
|
|| response.status().is_server_error()
|
||||||
|
{
|
||||||
|
return Box::new(future::err(errors::new(
|
||||||
|
errors::ErrorKind::Other,
|
||||||
|
format!("Import '{}' failed: {}", &url, response.status()),
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
let content_type = response
|
let content_type = response
|
||||||
.headers()
|
.headers()
|
||||||
|
@ -119,17 +122,18 @@ pub fn fetch_string_once(
|
||||||
.concat2()
|
.concat2()
|
||||||
.map(|body| String::from_utf8(body.to_vec()).ok())
|
.map(|body| String::from_utf8(body.to_vec()).ok())
|
||||||
.map_err(DenoError::from);
|
.map_err(DenoError::from);
|
||||||
Box::new(body.join3(
|
Box::new(body.join3(future::ok(content_type), future::ok(None)))
|
||||||
future::ok(content_type),
|
},
|
||||||
future::ok(None)
|
)
|
||||||
))
|
|
||||||
})
|
|
||||||
.and_then(move |(maybe_code, maybe_content_type, maybe_redirect)| {
|
.and_then(move |(maybe_code, maybe_content_type, maybe_redirect)| {
|
||||||
if let Some(redirect) = maybe_redirect {
|
if let Some(redirect) = maybe_redirect {
|
||||||
future::ok(redirect)
|
future::ok(redirect)
|
||||||
} else {
|
} else {
|
||||||
// maybe_code should always contain code here!
|
// maybe_code should always contain code here!
|
||||||
future::ok(FetchOnceResult::Code(maybe_code.unwrap(), maybe_content_type))
|
future::ok(FetchOnceResult::Code(
|
||||||
|
maybe_code.unwrap(),
|
||||||
|
maybe_content_type,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ fn op_now(
|
||||||
assert_eq!(data.len(), 0);
|
assert_eq!(data.len(), 0);
|
||||||
let seconds = state.start_time.elapsed().as_secs();
|
let seconds = state.start_time.elapsed().as_secs();
|
||||||
let mut subsec_nanos = state.start_time.elapsed().subsec_nanos();
|
let mut subsec_nanos = state.start_time.elapsed().subsec_nanos();
|
||||||
let reduced_time_precision = 2000000; // 2ms in nanoseconds
|
let reduced_time_precision = 2_000_000; // 2ms in nanoseconds
|
||||||
|
|
||||||
// If the permission is not enabled
|
// If the permission is not enabled
|
||||||
// Round the nano result on 2 milliseconds
|
// Round the nano result on 2 milliseconds
|
||||||
|
|
|
@ -268,7 +268,7 @@ impl DenoPermissions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn allows_high_precision(&self) -> bool {
|
pub fn allows_high_precision(&self) -> bool {
|
||||||
return self.allow_high_precision.is_allow();
|
self.allow_high_precision.is_allow()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn revoke_run(&self) -> DenoResult<()> {
|
pub fn revoke_run(&self) -> DenoResult<()> {
|
||||||
|
@ -297,7 +297,7 @@ impl DenoPermissions {
|
||||||
}
|
}
|
||||||
pub fn revoke_high_precision(&self) -> DenoResult<()> {
|
pub fn revoke_high_precision(&self) -> DenoResult<()> {
|
||||||
self.allow_high_precision.revoke();
|
self.allow_high_precision.revoke();
|
||||||
return Ok(());
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue