Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ae547e4

Browse files
committedMar 30, 2025·
clean clippy
1 parent 1319d42 commit ae547e4

File tree

13 files changed

+25
-37
lines changed

13 files changed

+25
-37
lines changed
 

‎crates/pgt_cli/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use pgt_workspace::workspace::UpdateSettingsParams;
1515
use pgt_workspace::{DynRef, Workspace, WorkspaceError};
1616
use std::ffi::OsString;
1717
use std::path::PathBuf;
18-
1918
pub(crate) mod check;
2019
pub(crate) mod clean;
2120
pub(crate) mod daemon;
@@ -24,6 +23,7 @@ pub(crate) mod version;
2423

2524
#[derive(Debug, Clone, Bpaf)]
2625
#[bpaf(options, version(VERSION))]
26+
#[allow(clippy::large_enum_variant)]
2727
/// Postgres Tools official CLI. Use it to check the health of your project or run it to check single files.
2828
pub enum PgtCommand {
2929
/// Shows the version information and quit.

‎crates/pgt_cli/src/execute/std_in.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::{CliDiagnostic, CliSession};
44
use pgt_console::{ConsoleExt, markup};
55

6-
pub(crate) fn run<'a>(session: CliSession, content: &'a str) -> Result<(), CliDiagnostic> {
6+
pub(crate) fn run(session: CliSession, content: &str) -> Result<(), CliDiagnostic> {
77
let console = &mut *session.app.console;
88

99
console.append(markup! {{content}});

‎crates/pgt_cli/src/service/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ type JsonRpcResult = Result<Box<RawValue>, TransportError>;
7070
/// This structs holds an instance of the `tokio` runtime, as well as the
7171
/// following fields:
7272
/// - `write_send` is a sender handle to the "write channel", an MPSC channel
73-
/// that's used to queue up requests to be sent to the server (for simplicity
74-
/// the requests are pushed to the channel as serialized byte buffers)
73+
/// that's used to queue up requests to be sent to the server (for simplicity
74+
/// the requests are pushed to the channel as serialized byte buffers)
7575
/// - `pending_requests` is handle to a shared hashmap where the keys are `u64`
76-
/// corresponding to request IDs, and the values are sender handles to oneshot
77-
/// channel instances that can be consumed to fulfill the associated request
76+
/// corresponding to request IDs, and the values are sender handles to oneshot
77+
/// channel instances that can be consumed to fulfill the associated request
7878
///
7979
/// Creating a new `SocketTransport` instance requires providing a `tokio`
8080
/// runtime instance as well as the "read half" and "write half" of the socket
@@ -85,7 +85,7 @@ type JsonRpcResult = Result<Box<RawValue>, TransportError>;
8585
///
8686
/// This concurrent handling of I/O is implemented using two "background tasks":
8787
/// - the `write_task` pulls outgoing messages from the "write channel" and
88-
/// writes them to the "write half" of the socket
88+
/// writes them to the "write half" of the socket
8989
/// - the `read_task` reads incoming messages from the "read half" of the
9090
/// socket, then looks up a request with an ID corresponding to the received
9191
/// message in the "pending requests" map. If a pending request is found, it's

‎crates/pgt_completions/src/providers/functions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use crate::{
66
pub fn complete_functions(ctx: &CompletionContext, builder: &mut CompletionBuilder) {
77
let available_functions = &ctx.schema_cache.functions;
88

9-
for foo in available_functions {
9+
for func in available_functions {
1010
let item = CompletionItem {
11-
label: foo.name.clone(),
12-
score: CompletionRelevanceData::Function(foo).get_score(ctx),
13-
description: format!("Schema: {}", foo.schema),
11+
label: func.name.clone(),
12+
score: CompletionRelevanceData::Function(func).get_score(ctx),
13+
description: format!("Schema: {}", func.schema),
1414
preselected: false,
1515
kind: CompletionItemKind::Function,
1616
};

‎crates/pgt_diagnostics/src/display/diff.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ pub(super) fn print_diff(fmt: &mut fmt::Formatter<'_>, diff: &TextEdit) -> io::R
9999
/// This function scans the list of DiffOps that make up the `diff` and derives
100100
/// the following data structures:
101101
/// - `modified_lines` is the set of [LineKey] that contain at least one insert
102-
/// or delete operation
102+
/// or delete operation
103103
/// - `inserted_lines` maps a [LineKey] to the list of diff operations that
104-
/// happen on the corresponding line
104+
/// happen on the corresponding line
105105
/// - `before_line_to_after` maps line numbers in the old revision of the text
106-
/// to line numbers in the new revision
106+
/// to line numbers in the new revision
107107
/// - `after_line` counts the number of lines in the new revision of the document
108108
/// - `before_line` counts the number of lines in the old revision of the document
109109
fn process_diff_ops<'diff>(

‎crates/pgt_diagnostics_macros/src/parse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use syn::{
99
token::Paren,
1010
};
1111

12+
#[allow(clippy::large_enum_variant)]
1213
pub(crate) enum DeriveInput {
1314
DeriveStructInput(DeriveStructInput),
1415
DeriveEnumInput(DeriveEnumInput),

‎crates/pgt_lsp/src/handlers/code_actions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn get_actions(
6363

6464
Ok(actions
6565
.into_iter()
66-
.map(|ac| CodeActionOrCommand::CodeAction(ac))
66+
.map(CodeActionOrCommand::CodeAction)
6767
.collect())
6868
}
6969

‎crates/pgt_test_macros/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl Arguments {
164164

165165
let span = self.pattern.lit.span();
166166
let test_name = syn::Ident::new(&test_name, span);
167-
let foo = &self.test_function;
167+
let func = &self.test_function;
168168

169169
modules.insert(
170170
path,
@@ -174,7 +174,7 @@ impl Arguments {
174174
let test_fullpath = #test_fullpath;
175175
let test_expected_fullpath = #test_expected_fullpath;
176176
let test_dir = #test_dir;
177-
#foo(test_fullpath, test_expected_fullpath, test_dir);
177+
#func(test_fullpath, test_expected_fullpath, test_dir);
178178
}
179179
},
180180
)

‎crates/pgt_text_size/src/size.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use {
55
fmt, iter,
66
num::TryFromIntError,
77
ops::{Add, AddAssign, Sub, SubAssign},
8-
u32,
98
},
109
};
1110

‎crates/pgt_workspace/src/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub fn strip_jsonc_comments(jsonc_input: &str) -> String {
239239
json_output.push(last_char);
240240
}
241241
} else {
242-
json_output.push_str(" ");
242+
json_output.push(' ');
243243
}
244244
last_char = Some(cur_char);
245245
}

‎crates/pgt_workspace/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl From<PartialDatabaseConfiguration> for DatabaseSettings {
303303
.map(|stringset| {
304304
stringset.iter().any(|pattern| {
305305
let glob = Glob::new(pattern)
306-
.expect(format!("Invalid pattern: {}", pattern).as_str())
306+
.unwrap_or_else(|_| panic!("Invalid pattern: {}", pattern))
307307
.compile_matcher();
308308

309309
glob.is_match(format!("{}/{}", host, database))

‎crates/pgt_workspace/src/workspace/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl Workspace for WorkspaceServer {
337337
}
338338
};
339339

340-
let conn = self.connection.write().unwrap();
340+
let conn = self.connection.read().unwrap();
341341
let pool = match conn.get_pool() {
342342
Some(p) => p,
343343
None => {

‎xtask/codegen/src/generate_configuration.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,7 @@ fn generate_group_struct(
536536
let rule_option_type = quote! {
537537
pgt_analyser::options::#rule_name
538538
};
539-
let rule_option = if kind == RuleCategory::Action {
540-
quote! { Option<#rule_config_type<#rule_option_type>> }
541-
} else {
542-
quote! {
543-
Option<#rule_config_type<#rule_option_type>>
544-
}
545-
};
539+
let rule_option = quote! { Option<#rule_config_type<#rule_option_type>> };
546540
schema_lines_rules.push(quote! {
547541
#[doc = #summary]
548542
#[serde(skip_serializing_if = "Option::is_none")]
@@ -570,15 +564,9 @@ fn generate_group_struct(
570564
}
571565
});
572566

573-
if kind == RuleCategory::Action {
574-
get_rule_configuration_line.push(quote! {
575-
#rule => self.#rule_identifier.as_ref().map(|conf| (conf.level(), conf.get_options()))
576-
});
577-
} else {
578-
get_rule_configuration_line.push(quote! {
579-
#rule => self.#rule_identifier.as_ref().map(|conf| (conf.level(), conf.get_options()))
580-
});
581-
}
567+
get_rule_configuration_line.push(quote! {
568+
#rule => self.#rule_identifier.as_ref().map(|conf| (conf.level(), conf.get_options()))
569+
});
582570
}
583571

584572
let group_pascal_ident = Ident::new(&to_capitalized(group), Span::call_site());

0 commit comments

Comments
 (0)
Please sign in to comment.