Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: codegen clippy #709

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cargo-shuttle/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl Client {

async fn ws_get(&self, path: String) -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>> {
let ws_scheme = self.api_url.clone().replace("http", "ws");
let url = format!("{}{}", ws_scheme, path);
let url = format!("{ws_scheme}{path}");
let mut request = url.into_client_request()?;

if let Some(ref api_key) = self.api_key {
Expand Down
8 changes: 4 additions & 4 deletions cargo-shuttle/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ pub fn cargo_init(path: PathBuf) -> Result<()> {
// Mimic `cargo init` behavior and log status or error to shell
cargo_config
.shell()
.status("Created", format!("{} (shuttle) package", init_result))?;
.status("Created", format!("{init_result} (shuttle) package"))?;

Ok(())
}
Expand All @@ -890,7 +890,7 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Framework) -> Result<()> {
cargo_doc["package"]["publish"] = value(false);

// Get `[dependencies]` table
let mut dependencies = cargo_doc["dependencies"]
let dependencies = cargo_doc["dependencies"]
.as_table_mut()
.expect("manifest to have a dependencies table");

Expand All @@ -910,7 +910,7 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Framework) -> Result<()> {

// Set framework-specific dependencies to the `dependencies` table
init_config.set_cargo_dependencies(
&mut dependencies,
dependencies,
&manifest_path,
&url,
get_latest_dependency_version,
Expand Down Expand Up @@ -985,7 +985,7 @@ fn get_latest_dependency_version(
) -> String {
let latest_version =
get_latest_dependency(crate_name, flag_allow_prerelease, manifest_path, Some(url))
.unwrap_or_else(|_| panic!("Could not query the latest version of {}", crate_name));
.unwrap_or_else(|_| panic!("Could not query the latest version of {crate_name}"));
let latest_version = latest_version
.version()
.expect("No latest shuttle-service version available");
Expand Down
4 changes: 2 additions & 2 deletions cargo-shuttle/src/provisioner_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl LocalProvisioner {
env,
is_ready_cmd,
} = db_type_to_config(db_type);
let container_name = format!("shuttle_{}_{}", service_name, r#type);
let container_name = format!("shuttle_{service_name}_{type}");

let container = match self.docker.inspect_container(&container_name, None).await {
Ok(container) => {
Expand Down Expand Up @@ -297,7 +297,7 @@ fn print_layers(layers: &Vec<CreateImageInfo>) {
(Some(status), _) => status.to_string(),
_ => "Unknown".to_string(),
};
println!("[{id} {}]", text);
println!("[{id} {text}]");
} else {
println!(
"{}",
Expand Down
16 changes: 6 additions & 10 deletions codegen/src/shuttle_main/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Loader {
pub(crate) fn from_item_fn(item_fn: &mut ItemFn) -> Option<Self> {
let fn_ident = item_fn.sig.ident.clone();

if fn_ident.clone().to_string() == "main".to_string() {
if fn_ident.to_string().as_str() == "main" {
emit_error!(
fn_ident,
"shuttle_runtime::main functions cannot be named `main`"
Expand Down Expand Up @@ -127,15 +127,11 @@ impl Loader {
})
.collect();

if let Some(type_path) = check_return_type(item_fn.sig.clone()) {
Some(Self {
fn_ident: fn_ident.clone(),
fn_inputs: inputs,
fn_return: type_path,
})
} else {
None
}
check_return_type(item_fn.sig.clone()).map(|type_path| Self {
fn_ident: fn_ident.clone(),
fn_inputs: inputs,
fn_return: type_path,
})
}
}

Expand Down
5 changes: 2 additions & 3 deletions common/src/models/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Display for State {
State::Destroyed => write!(f, "{}", "destroyed".blue()),
State::Errored { message } => {
writeln!(f, "{}", "errored".red())?;
write!(f, "\tmessage: {}", message)
write!(f, "\tmessage: {message}")
}
}
}
Expand Down Expand Up @@ -199,9 +199,8 @@ pub fn get_table(projects: &Vec<Response>) -> String {
format!(
r#"
These projects are linked to this account
{}
{table}
"#,
table,
)
}
}
3 changes: 1 addition & 2 deletions common/src/models/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ pub fn get_table(secrets: &Vec<Response>) -> String {

format!(
r#"These secrets are linked to this service
{}
{table}
"#,
table
)
}
}
7 changes: 3 additions & 4 deletions common/src/models/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Display for Detailed {
let resources = get_resources_table(&self.resources);
let secrets = secret::get_table(&self.secrets);

write!(f, "{}{}{}", deploys, resources, secrets)
write!(f, "{deploys}{resources}{secrets}")
}
}

Expand Down Expand Up @@ -82,7 +82,7 @@ URI: {}

let resources = get_resources_table(&self.resources);

write!(f, "{}{}", deployment, resources)
write!(f, "{deployment}{resources}")
}
}

Expand Down Expand Up @@ -150,9 +150,8 @@ fn get_resources_table(resources: &Vec<resource::Response>) -> String {

format!(
r#"These resources are linked to this service
{}
{table}
"#,
table
)
}
}
3 changes: 1 addition & 2 deletions common/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ impl Display for ProjectNameError {
ProjectNameError::InvalidName(name) => write!(
f,
r#"
`{}` is an invalid project name. project name must
`{name}` is an invalid project name. project name must
1. start and end with alphanumeric characters.
2. only contain characters inside of the alphanumeric range, except for `-`, or `_`.
3. not be empty.,
4. not contain profanity.
5. not be a reserved word."#,
name
),
}
}
Expand Down