Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1305 from cloudflare/alewis/clippy-warnings
Browse files Browse the repository at this point in the history
low hanging clippy warnings
  • Loading branch information
EverlastingBugstopper committed May 20, 2020
2 parents 274086d + d3a36ce commit cee6c54
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
14 changes: 6 additions & 8 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ pub fn generate(
Err(_) => true,
};

let new_name: String;

if dirname_exists {
new_name = match generate_name(name) {
let new_name = if dirname_exists {
match generate_name(name) {
Ok(val) => val,
Err(_) => {
log::debug!(
Expand All @@ -32,10 +30,10 @@ pub fn generate(
);
String::from(name)
}
};
}
} else {
new_name = String::from(name);
}
String::from(name)
};

log::info!("Generating a new worker project with name '{}'", new_name);
run_generate(&new_name, template)?;
Expand Down Expand Up @@ -74,7 +72,7 @@ fn generate_name(name: &str) -> Result<String, failure::Error> {
let mut new_name = construct_name(&name, num);

while entry_names.contains(&OsString::from(&new_name)) {
num = num + 1;
num += 1;
new_name = construct_name(&name, num);
}
Ok(new_name)
Expand Down
1 change: 0 additions & 1 deletion src/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::path::PathBuf;
use std::thread;

use tempfile::TempDir;
use toml;

const BUNDLE_OUT: &str = "worker";

Expand Down
2 changes: 0 additions & 2 deletions src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ use std::io;
use std::path::Path;
use std::process;

use atty;
use failure::{self, bail, ResultExt};
use which;

pub fn install() -> ! {
if let Err(e) = do_install() {
Expand Down
22 changes: 11 additions & 11 deletions src/preview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn preview(
}

// Make a the initial request to the URL
client_request(&request_payload, &script_id, &sites_preview);
client_request(&request_payload, &script_id, sites_preview);

let broadcaster = server.broadcaster();
thread::spawn(move || server.run());
Expand All @@ -96,7 +96,7 @@ pub fn preview(
))?;
}

client_request(&request_payload, &script_id, &sites_preview);
client_request(&request_payload, &script_id, sites_preview);
}

Ok(())
Expand All @@ -118,7 +118,7 @@ fn open_browser(url: &str) -> Result<(), failure::Error> {
Ok(())
}

fn client_request(payload: &RequestPayload, script_id: &String, sites_preview: &bool) {
fn client_request(payload: &RequestPayload, script_id: &str, sites_preview: bool) {
let client = http::client();

let method = &payload.method;
Expand All @@ -132,7 +132,7 @@ fn client_request(payload: &RequestPayload, script_id: &String, sites_preview: &
HttpMethod::Post => post(&url, &cookie, &body, &client).unwrap(),
};

let msg = if *sites_preview {
let msg = if sites_preview {
"Your Worker is a Workers Site, please preview it in browser window.".to_string()
} else {
format!("Your Worker responded with: {}", worker_res)
Expand All @@ -141,25 +141,25 @@ fn client_request(payload: &RequestPayload, script_id: &String, sites_preview: &
}

fn get(
url: &String,
cookie: &String,
url: &str,
cookie: &str,
client: &reqwest::blocking::Client,
) -> Result<String, failure::Error> {
let res = client.get(url).header("Cookie", cookie).send();
Ok(res?.text()?)
}

fn post(
url: &String,
cookie: &String,
url: &str,
cookie: &str,
body: &Option<String>,
client: &reqwest::blocking::Client,
) -> Result<String, failure::Error> {
let res = match body {
Some(s) => client
.post(url)
.header("Cookie", cookie)
.body(format!("{}", s))
.body(s.to_string())
.send(),
None => client.post(url).header("Cookie", cookie).send(),
};
Expand All @@ -183,7 +183,7 @@ fn watch_for_changes(

while let Ok(_) = rx.recv() {
if let Ok(new_id) = upload(&mut target, user, sites_preview, verbose) {
let script_id = format!("{}", new_id);
let script_id = new_id.to_string();

let msg = FiddleMessage {
session_id: request_payload.session.clone(),
Expand All @@ -201,7 +201,7 @@ fn watch_for_changes(
}
}

client_request(&request_payload, &script_id, &sites_preview);
client_request(&request_payload, &script_id, sites_preview);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/preview/request_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl RequestPayload {
}
}

pub fn cookie(&self, script_id: &String) -> String {
pub fn cookie(&self, script_id: &str) -> String {
format!(
"__ew_fiddle_preview={}{}{}{}",
script_id, self.session, self.https, self.domain
Expand Down
1 change: 0 additions & 1 deletion src/settings/global_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::fs;
use std::path::{Path, PathBuf};

use cloudflare::framework::auth::Credentials;
use config;
use serde::{Deserialize, Serialize};

use crate::settings::{Environment, QueryEnvironment};
Expand Down
2 changes: 1 addition & 1 deletion src/tail/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Tunnel {

let child = command
.spawn()
.expect(&format!("{} failed to spawn", command_name));
.unwrap_or_else(|_| panic!("{} failed to spawn", command_name));

Ok(Tunnel { child })
}
Expand Down

0 comments on commit cee6c54

Please sign in to comment.