Skip to content

Commit 3386a15

Browse files
committed
progress
1 parent 80b645e commit 3386a15

File tree

40 files changed

+83
-114
lines changed

40 files changed

+83
-114
lines changed

crates/pgt_analyse/src/categories.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl TryFrom<&str> for RuleCategory {
3232
"lint" => Ok(Self::Lint),
3333
"action" => Ok(Self::Action),
3434
"transformation" => Ok(Self::Transformation),
35-
_ => Err(format!("Invalid Rule Category: {}", value)),
35+
_ => Err(format!("Invalid Rule Category: {value}")),
3636
}
3737
}
3838
}

crates/pgt_analyser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ mod tests {
150150
let text = markup_to_string(markup! {
151151
{PrintDiagnostic::simple(result)}
152152
});
153-
eprintln!("{}", text);
153+
eprintln!("{text}");
154154
}
155155
println!("*******************");
156156

crates/pgt_analyser/tests/rules_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn rule_test(full_path: &'static str, _: &str, _: &str) {
2323
};
2424

2525
let query =
26-
read_to_string(full_path).unwrap_or_else(|_| panic!("Failed to read file: {} ", full_path));
26+
read_to_string(full_path).unwrap_or_else(|_| panic!("Failed to read file: {full_path} "));
2727

2828
let options = AnalyserOptions::default();
2929
let analyser = Analyser::new(AnalyserConfig {

crates/pgt_cli/src/service/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn spawn_daemon(
7777
}
7878

7979
if let Some(log_file_name_prefix) = log_file_name_prefix {
80-
cmd.arg(format!("--log-prefix-name={}", log_file_name_prefix));
80+
cmd.arg(format!("--log-prefix-name={log_file_name_prefix}"));
8181
}
8282

8383
// Create a new session for the process and make it the leader, this will

crates/pgt_completions/benches/sanitization.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn to_params<'a>(
3535

3636
pub fn criterion_benchmark(c: &mut Criterion) {
3737
c.bench_function("small sql, adjusted", |b| {
38-
let content = format!("select {} from users;", CURSOR_POS);
38+
let content = format!("select {CURSOR_POS} from users;");
3939

4040
let cache = SchemaCache::default();
4141
let (sql, pos) = sql_and_pos(content.as_str());
@@ -52,16 +52,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
5252
u.rolname as "owner!"
5353
from
5454
pg_namespace n,
55-
{}
55+
{CURSOR_POS}
5656
where
5757
n.nspowner = u.oid
5858
and (
5959
pg_has_role(n.nspowner, 'USAGE')
6060
or has_schema_privilege(n.oid, 'CREATE, USAGE')
6161
)
6262
and not pg_catalog.starts_with(n.nspname, 'pg_temp_')
63-
and not pg_catalog.starts_with(n.nspname, 'pg_toast_temp_');"#,
64-
CURSOR_POS
63+
and not pg_catalog.starts_with(n.nspname, 'pg_toast_temp_');"#
6564
);
6665

6766
let cache = SchemaCache::default();
@@ -98,7 +97,7 @@ where
9897
ix.indisunique as is_unique,
9998
ix.indrelid as table_oid
10099
from
101-
{}
100+
{CURSOR_POS}
102101
where
103102
c.relkind = 'i'
104103
)
@@ -128,8 +127,7 @@ from
128127
where
129128
-- system columns, such as `cmax` or `tableoid`, have negative `attnum`s
130129
atts.attnum >= 0;
131-
"#,
132-
CURSOR_POS
130+
"#
133131
);
134132

135133
let cache = SchemaCache::default();
@@ -140,7 +138,7 @@ where
140138
});
141139

142140
c.bench_function("small sql, unadjusted", |b| {
143-
let content = format!("select e{} from users;", CURSOR_POS);
141+
let content = format!("select e{CURSOR_POS} from users;");
144142

145143
let cache = SchemaCache::default();
146144
let (sql, pos) = sql_and_pos(content.as_str());
@@ -157,16 +155,15 @@ where
157155
u.rolname as "owner!"
158156
from
159157
pg_namespace n,
160-
pg_r{}
158+
pg_r{CURSOR_POS}
161159
where
162160
n.nspowner = u.oid
163161
and (
164162
pg_has_role(n.nspowner, 'USAGE')
165163
or has_schema_privilege(n.oid, 'CREATE, USAGE')
166164
)
167165
and not pg_catalog.starts_with(n.nspname, 'pg_temp_')
168-
and not pg_catalog.starts_with(n.nspname, 'pg_toast_temp_');"#,
169-
CURSOR_POS
166+
and not pg_catalog.starts_with(n.nspname, 'pg_toast_temp_');"#
170167
);
171168

172169
let cache = SchemaCache::default();
@@ -235,8 +232,7 @@ where
235232
-- system columns, such as `cmax` or `tableoid`, have negative `attnum`s
236233
atts.attnum >= 0
237234
order by
238-
sch{} "#,
239-
CURSOR_POS
235+
sch{CURSOR_POS} "#
240236
);
241237

242238
let cache = SchemaCache::default();

crates/pgt_completions/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a> CompletionBuilder<'a> {
7676
detail: item.detail,
7777

7878
// wonderous Rust syntax ftw
79-
sort_text: format!("{:0>padding$}", idx, padding = max_padding),
79+
sort_text: format!("{idx:0>max_padding$}"),
8080
completion_text: item.completion_text,
8181
}
8282
})

crates/pgt_completions/src/providers/helper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) fn with_schema_or_alias(
5252

5353
if schema_or_alias_name.is_none_or(|s| s == "public") || is_already_prefixed_with_schema_name {
5454
if single_leading_quote {
55-
format!(r#"{}""#, item_name)
55+
format!(r#"{item_name}""#)
5656
} else {
5757
item_name.to_string()
5858
}
@@ -64,7 +64,7 @@ pub(crate) fn with_schema_or_alias(
6464
} else if with_quotes {
6565
format!(r#"{}"."{}"#, schema_or_als.replace('"', ""), item_name)
6666
} else {
67-
format!("{}.{}", schema_or_als, item_name)
67+
format!("{schema_or_als}.{item_name}")
6868
}
6969
}
7070
}

crates/pgt_completions/src/test_helper.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,13 @@ impl CompletionAssertion {
106106
CompletionAssertion::LabelNotExists(label) => {
107107
assert_ne!(
108108
&item.label, label,
109-
"Expected label {} not to exist, but found it",
110-
label
109+
"Expected label {label} not to exist, but found it"
111110
);
112111
}
113112
CompletionAssertion::KindNotExists(kind) => {
114113
assert_ne!(
115114
&item.kind, kind,
116-
"Expected kind {:?} not to exist, but found it",
117-
kind
115+
"Expected kind {kind:?} not to exist, but found it"
118116
);
119117
}
120118
CompletionAssertion::LabelAndDesc(label, desc) => {

crates/pgt_configuration/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl PartialConfiguration {
103103
/// Returns the initial configuration.
104104
pub fn init() -> Self {
105105
Self {
106-
schema: Some(format!("{}/schemas/{VERSION}/schema.json", PGLS_WEBSITE)),
106+
schema: Some(format!("{PGLS_WEBSITE}/schemas/{VERSION}/schema.json")),
107107
extends: Some(StringSet::default()),
108108
files: Some(PartialFilesConfiguration {
109109
ignore: Some(Default::default()),

crates/pgt_hover/src/hoverables/column.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ impl ToHoverMarkdown for pgt_schema_cache::Column {
2424
_schema_cache: &SchemaCache,
2525
) -> Result<bool, std::fmt::Error> {
2626
if let Some(comment) = &self.comment {
27-
write!(writer, "Comment: '{}'", comment)?;
27+
write!(writer, "Comment: '{comment}'")?;
2828
writeln!(writer)?;
2929
}
3030

3131
if let Some(tname) = self.type_name.as_ref() {
32-
write!(writer, "{}", tname)?;
32+
write!(writer, "{tname}")?;
3333
if let Some(l) = self.varchar_length {
34-
write!(writer, "({})", l)?;
34+
write!(writer, "({l})")?;
3535
}
3636
} else {
3737
write!(writer, "typeid: {}", self.type_id)?;
@@ -61,7 +61,7 @@ impl ToHoverMarkdown for pgt_schema_cache::Column {
6161
) -> Result<bool, std::fmt::Error> {
6262
if let Some(default) = &self.default_expr {
6363
writeln!(writer)?;
64-
write!(writer, "Default: {}", default)?;
64+
write!(writer, "Default: {default}")?;
6565
Ok(true)
6666
} else {
6767
Ok(false)

0 commit comments

Comments
 (0)