Skip to content

Commit f87081d

Browse files
committed
style: improve code formatting and organization
1 parent c9bb3e6 commit f87081d

File tree

7 files changed

+32
-25
lines changed

7 files changed

+32
-25
lines changed

loco-gen/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ pub use rrgen::{GenResult, RRgen};
66
use serde::{Deserialize, Serialize};
77
use serde_json::{json, Value};
88
mod controller;
9-
use colored::Colorize;
109
use std::{
1110
collections::HashMap,
1211
fs,
1312
path::{Path, PathBuf},
1413
sync::OnceLock,
1514
};
1615

16+
use colored::Colorize;
17+
1718
#[cfg(feature = "with-db")]
1819
mod infer;
1920
#[cfg(feature = "with-db")]
@@ -34,7 +35,6 @@ pub struct GenerateResults {
3435
}
3536
const DEPLOYMENT_SHUTTLE_RUNTIME_VERSION: &str = "0.51.0";
3637

37-
3838
#[derive(thiserror::Error, Debug)]
3939
pub enum Error {
4040
#[error("{0}")]
@@ -240,8 +240,8 @@ pub enum DeploymentKind {
240240
is_client_side_rendering: bool,
241241
postgres: bool,
242242
sqlite: bool,
243-
background_queue: bool
244-
}
243+
background_queue: bool,
244+
},
245245
}
246246

247247
#[derive(Debug)]
@@ -395,7 +395,7 @@ pub fn generate(rrgen: &RRgen, component: Component, appinfo: &AppInfo) -> Resul
395395
is_client_side_rendering,
396396
postgres,
397397
sqlite,
398-
background_queue
398+
background_queue,
399399
} => {
400400
let vars = json!({
401401
"pkg_name": appinfo.app_name,

loco-gen/src/model.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ pub fn get_columns_and_references(
6565
let array_kind = match params.as_slice() {
6666
[array_kind] => Ok(array_kind),
6767
_ => Err(Error::Message(format!(
68-
"type: `{ftype}` requires exactly {arity} parameter{}, but {} were given (`{}`).",
69-
if arity == 1 { "" } else { "s" },
70-
params.len(),
71-
params.join(",")
72-
))),
68+
"type: `{ftype}` requires exactly {arity} parameter{}, but {} \
69+
were given (`{}`).",
70+
if arity == 1 { "" } else { "s" },
71+
params.len(),
72+
params.join(",")
73+
))),
7374
}?;
7475

7576
format!(

loco-gen/src/tera_ext.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub fn new() -> Tera {
99
tera
1010
}
1111

12-
const DEFAULT_INPUT_CLASS: &str = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm md:text-sm";
12+
const DEFAULT_INPUT_CLASS: &str = "flex h-9 w-full rounded-md border border-input bg-transparent \
13+
px-3 py-1 text-base shadow-sm md:text-sm";
1314
struct FormField;
1415

1516
impl tera::Function for FormField {
@@ -322,10 +323,10 @@ fn input_description<S: AsRef<str>>(description: S) -> String {
322323

323324
#[cfg(test)]
324325
pub mod tests {
325-
use super::*;
326+
use insta::assert_snapshot;
326327

328+
use super::*;
327329
use crate::get_mappings;
328-
use insta::assert_snapshot;
329330

330331
#[test]
331332
fn can_render_form_field() {

loco-gen/tests/db.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use std::{collections::HashMap, env::current_dir, fs::read_to_string};
2+
13
use duct::cmd;
24
use insta::assert_snapshot;
35
use loco_gen::get_mappings;
46
use rstest::rstest;
57
use serial_test::serial;
6-
use std::{collections::HashMap, env::current_dir, fs::read_to_string};
78

89
#[rstest]
910
#[serial]

loco-gen/tests/templates/deployment.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn can_generate_docker(
4141
app_name: "tester".to_string(),
4242
},
4343
)
44-
.expect("Generation failed");
44+
.expect("Generation failed");
4545

4646
assert_eq!(
4747
collect_messages(&gen_result),
@@ -93,7 +93,7 @@ fn can_generate_nginx() {
9393
app_name: "tester".to_string(),
9494
},
9595
)
96-
.expect("Generation failed");
96+
.expect("Generation failed");
9797

9898
assert_eq!(
9999
collect_messages(&gen_result),
@@ -151,7 +151,7 @@ playground = "run --example playground"
151151
app_name: "tester".to_string(),
152152
},
153153
)
154-
.expect("Generation failed");
154+
.expect("Generation failed");
155155

156156
assert_eq!(
157157
collect_messages(&gen_result),
@@ -210,7 +210,7 @@ fn can_generate_kamal_sqlite_without_background_queue() {
210210
app_name: "tester".to_string(),
211211
},
212212
)
213-
.expect("Generation failed");
213+
.expect("Generation failed");
214214

215215
assert_eq!(
216216
collect_messages(&gen_result),
@@ -290,7 +290,7 @@ fn can_generate_kamal_sqlite_with_background_queue() {
290290
app_name: "tester".to_string(),
291291
},
292292
)
293-
.expect("Generation failed");
293+
.expect("Generation failed");
294294

295295
assert_eq!(
296296
collect_messages(&gen_result),
@@ -368,7 +368,7 @@ fn can_generate_kamal_postgres_without_background_queue() {
368368
app_name: "tester".to_string(),
369369
},
370370
)
371-
.expect("Generation failed");
371+
.expect("Generation failed");
372372

373373
assert_eq!(
374374
collect_messages(&gen_result),
@@ -446,7 +446,7 @@ fn can_generate_kamal_postgres_with_background_queue() {
446446
app_name: "tester".to_string(),
447447
},
448448
)
449-
.expect("Generation failed");
449+
.expect("Generation failed");
450450

451451
assert_eq!(
452452
collect_messages(&gen_result),

src/controller/views/engines.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use std::path::{Path, PathBuf};
22

3+
use serde::Serialize;
4+
35
use super::tera_builtins;
46
use crate::{controller::views::ViewRenderer, Error, Result};
5-
use serde::Serialize;
67

78
pub static DEFAULT_ASSET_FOLDER: &str = "assets";
89

src/schema.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ pub enum ColType {
8282
Unsigned,
8383
UnsignedNull,
8484
UnsignedUniq,
85-
// Tiny fields are not supported due to differences in data types between PostgreSQL and SQLite:
85+
// Tiny fields are not supported due to differences in data types between PostgreSQL and
86+
// SQLite:
8687
// * Postgres: i16
8788
// * Sqlite: i8
8889
// TinyUnsigned,
@@ -94,7 +95,8 @@ pub enum ColType {
9495
BigUnsigned,
9596
BigUnsignedNull,
9697
BigUnsignedUniq,
97-
// Tiny fields are not supported due to differences in data types between PostgreSQL and SQLite:
98+
// Tiny fields are not supported due to differences in data types between PostgreSQL and
99+
// SQLite:
98100
// * Postgres: i16
99101
// * Sqlite: i8
100102
// TinyInteger,
@@ -120,7 +122,8 @@ pub enum ColType {
120122
DoubleUniq,
121123
Boolean,
122124
BooleanNull,
123-
// Timestamp fields are not supported due to differences in data types between PostgreSQL and SQLite:
125+
// Timestamp fields are not supported due to differences in data types between PostgreSQL and
126+
// SQLite:
124127
// * Postgres: DateTime
125128
// * Sqlite: DateTimeUtc
126129
// Timestamp,

0 commit comments

Comments
 (0)