Skip to content

Commit

Permalink
clippy and fmt fixes from #182 and elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMichaelTDM committed Apr 3, 2023
1 parent e32badb commit b15eb73
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion create-rust-app/src/database/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use diesel::r2d2::{self, ConnectionManager, PooledConnection};
use diesel::PgConnection;

use once_cell::sync::OnceCell;

#[cfg(feature = "database_postgres")]
Expand All @@ -8,6 +8,7 @@ type DbCon = diesel::PgConnection;
#[cfg(feature = "database_sqlite")]
type DbCon = diesel::SqliteConnection;

#[allow(dead_code)]
#[cfg(feature = "database_postgres")]
pub type DieselBackend = diesel::pg::Pg;

Expand Down
13 changes: 10 additions & 3 deletions create-rust-app/src/util/actix_web_utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#[cfg(debug_assertions)]
use actix_http::Uri;
#[cfg(debug_assertions)]
use std::str::FromStr;
#[cfg(debug_assertions)]
use std::sync::Mutex;

use super::template_utils::SinglePageApplication;
use crate::util::template_utils::{to_template_name, DEFAULT_TEMPLATE, TEMPLATES};
use actix_files::NamedFile;
use actix_http::Uri;

use actix_web::http::StatusCode;
use actix_web::{web, HttpRequest, HttpResponse, Scope};
use tera::Context;
Expand Down Expand Up @@ -136,11 +140,14 @@ pub async fn render_views(req: HttpRequest) -> HttpResponse {
template_response(req, content)
}

fn template_response(req: HttpRequest, content: String) -> HttpResponse {
fn template_response(_req: HttpRequest, content: String) -> HttpResponse {
#[cfg(not(debug_assertions))]
let content = content;
#[cfg(debug_assertions)]
let mut content = content;
#[cfg(debug_assertions)]
{
let uri = Uri::from_str(req.connection_info().host());
let uri = Uri::from_str(_req.connection_info().host());
let hostname = match &uri {
Ok(uri) => uri.host().unwrap_or("localhost"),
Err(_) => "localhost",
Expand Down
8 changes: 5 additions & 3 deletions create-rust-app/src/util/template_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ impl tera::Function for InjectBundle {
{
let manifest_entry = VITE_MANIFEST
.get(&format!("bundles/{bundle_name}"))
.expect(&format!("could not get bundle `{bundle_name}`"));
.unwrap_or_else(|| {
panic!("{}", "could not get bundle `{bundle_name}`")
});
let entry_file = format!(
r#"<script type="module" src="/{file}"></script>"#,
file = manifest_entry.file
Expand All @@ -63,7 +65,7 @@ impl tera::Function for InjectBundle {
.css
.as_ref()
.unwrap_or(&vec![])
.into_iter()
.iter()
.map(|css_file| {
format!(
r#"<link rel="stylesheet" href="/{file}" />"#,
Expand All @@ -76,7 +78,7 @@ impl tera::Function for InjectBundle {
.dynamicImports
.as_ref()
.unwrap_or(&vec![])
.into_iter()
.iter()
.map(|dyn_script_file| {
// TODO: make this deferred or async -- look this up!~
format!(
Expand Down
2 changes: 1 addition & 1 deletion create-rust-app_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ console = "0.15.5"
dialoguer = "0.10.3"
indoc = "1.0.8"
walkdir = "2.3.2"
rust-embed = "6.4.2"
rust-embed = { version = "6.6.1", features = ["debug-embed"] }
clap = {version = "4.1", features = ["wrap_help", "derive", "cargo"]}
toml = "0.5.11"
tsync = "1"
Expand Down
1 change: 0 additions & 1 deletion create-rust-app_cli/qsync/src/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ impl Hook {
.endpoint_url
.trim_start_matches("/api/")
.split('/')
.into_iter()
.map(|t| {
// in actix-web, paths which have {} denote a path param
if t.starts_with('{') && t.ends_with('}') {
Expand Down
2 changes: 1 addition & 1 deletion create-rust-app_cli/qsync/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn has_qsync_attribute(
if has_actix_attribute && has_qsync_attribute {
Some(QsyncAttributeProps {
is_mutation: is_mutation.unwrap_or_default(),
return_type: return_type,
return_type,
})
} else {
None
Expand Down
5 changes: 5 additions & 0 deletions create-rust-app_cli/src/content/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ use crate::inflector::Inflector;
use anyhow::Result;
use indoc::indoc;

#[allow(dead_code)]
pub struct Model {
pub config: ModelConfig,
pub file_contents: String,
}

#[allow(dead_code)]
pub struct ModelConfig {
pub model_name: String,
pub table_name: String,
pub file_name: String,
}

#[allow(dead_code)]
pub fn create(resource_name: &str) -> Result<Model> {
let resource = generate(resource_name);

Expand All @@ -25,6 +28,7 @@ pub fn create(resource_name: &str) -> Result<Model> {
Ok(resource)
}

#[allow(dead_code)]
fn config(resource_name: &str) -> ModelConfig {
let model_name = resource_name.to_pascal_case();
let file_name = model_name.to_snake_case();
Expand All @@ -37,6 +41,7 @@ fn config(resource_name: &str) -> ModelConfig {
}
}

#[allow(dead_code)]
fn generate(resource_name: &str) -> Model {
let config = config(resource_name);

Expand Down
2 changes: 1 addition & 1 deletion create-rust-app_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn create_project(
//

let install_config = plugins::InstallConfig {
project_name: project_name.clone(),
project_name,
project_dir: PathBuf::from("."),
backend_framework,
backend_database,
Expand Down

0 comments on commit b15eb73

Please sign in to comment.