Skip to content

Commit 8f85f9d

Browse files
committed
more fixes
1 parent 5f69a1d commit 8f85f9d

File tree

11 files changed

+18
-33
lines changed

11 files changed

+18
-33
lines changed

crates/pglt_cli/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl PgltCommand {
183183
| PgltCommand::Stop
184184
| PgltCommand::Init
185185
| PgltCommand::RunServer { .. }
186-
| PgltCommand::Clean { .. }
186+
| PgltCommand::Clean
187187
| PgltCommand::PrintSocket => None,
188188
}
189189
}

crates/pglt_cli/src/execute/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub enum TraversalMode {
103103
impl Display for TraversalMode {
104104
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
105105
match self {
106-
TraversalMode::Dummy { .. } => write!(f, "dummy"),
106+
TraversalMode::Dummy => write!(f, "dummy"),
107107
TraversalMode::Check { .. } => write!(f, "check"),
108108
}
109109
}
@@ -165,33 +165,33 @@ impl Execution {
165165

166166
pub(crate) fn as_diagnostic_category(&self) -> &'static Category {
167167
match self.traversal_mode {
168-
TraversalMode::Dummy { .. } => category!("dummy"),
168+
TraversalMode::Dummy => category!("dummy"),
169169
TraversalMode::Check { .. } => category!("check"),
170170
}
171171
}
172172

173173
pub(crate) const fn is_dummy(&self) -> bool {
174-
matches!(self.traversal_mode, TraversalMode::Dummy { .. })
174+
matches!(self.traversal_mode, TraversalMode::Dummy)
175175
}
176176

177177
/// Whether the traversal mode requires write access to files
178178
pub(crate) const fn requires_write_access(&self) -> bool {
179179
match self.traversal_mode {
180-
TraversalMode::Dummy { .. } => false,
180+
TraversalMode::Dummy => false,
181181
TraversalMode::Check { .. } => false,
182182
}
183183
}
184184

185185
pub(crate) fn as_stdin_file(&self) -> Option<&Stdin> {
186186
match &self.traversal_mode {
187-
TraversalMode::Dummy { .. } => None,
187+
TraversalMode::Dummy => None,
188188
TraversalMode::Check { stdin, .. } => stdin.as_ref(),
189189
}
190190
}
191191

192192
pub(crate) fn is_vcs_targeted(&self) -> bool {
193193
match &self.traversal_mode {
194-
TraversalMode::Dummy { .. } => false,
194+
TraversalMode::Dummy => false,
195195
TraversalMode::Check { vcs_targeted, .. } => {
196196
vcs_targeted.staged || vcs_targeted.changed
197197
}
@@ -205,7 +205,7 @@ impl Execution {
205205
/// Returns [true] if the user used the `--write`/`--fix` option
206206
pub(crate) fn is_write(&self) -> bool {
207207
match self.traversal_mode {
208-
TraversalMode::Dummy { .. } => false,
208+
TraversalMode::Dummy => false,
209209
TraversalMode::Check { .. } => false,
210210
}
211211
}

crates/pglt_cli/src/execute/traverse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ impl TraversalContext for TraversalOptions<'_, '_> {
487487
}
488488

489489
match self.execution.traversal_mode() {
490-
TraversalMode::Dummy { .. } => true,
490+
TraversalMode::Dummy => true,
491491
TraversalMode::Check { .. } => true,
492492
}
493493
}

crates/pglt_cli/src/reporter/terminal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl fmt::Display for SummaryTotal<'_> {
151151
fn fmt(&self, fmt: &mut Formatter) -> io::Result<()> {
152152
let files = Files(self.1);
153153
match self.0 {
154-
TraversalMode::Dummy { .. } => fmt.write_markup(markup! {
154+
TraversalMode::Dummy => fmt.write_markup(markup! {
155155
"Dummy "{files}" in "{self.2}"."
156156
}),
157157
TraversalMode::Check { .. } => fmt.write_markup(markup! {

crates/pglt_cli/src/service/unix.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,7 @@ pub(crate) async fn ensure_daemon(
186186

187187
// If the connection couldn't be opened after 10 tries fail with the last
188188
// error message from the OS, or a generic error message otherwise
189-
Err(last_error.unwrap_or_else(|| {
190-
io::Error::new(
191-
io::ErrorKind::Other,
192-
"could not connect to the daemon socket",
193-
)
194-
}))
189+
Err(last_error.unwrap_or_else(|| io::Error::other("could not connect to the daemon socket")))
195190
}
196191

197192
/// Ensure the server daemon is running and ready to receive connections and

crates/pglt_completions/src/context.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ impl<'a> CompletionContext<'a> {
122122

123123
pub fn get_ts_node_content(&self, ts_node: tree_sitter::Node<'a>) -> Option<&'a str> {
124124
let source = self.text;
125-
match ts_node.utf8_text(source.as_bytes()) {
126-
Ok(content) => Some(content),
127-
Err(_) => None,
128-
}
125+
ts_node.utf8_text(source.as_bytes()).ok()
129126
}
130127

131128
fn gather_tree_context(&mut self) {

crates/pglt_configuration/src/analyser/linter/rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::analyser::{RuleConfiguration, RulePlainConfiguration};
44
use biome_deserialize_macros::Merge;
5-
use pglt_analyse::{options::RuleOptions, RuleFilter};
5+
use pglt_analyse::{RuleFilter, options::RuleOptions};
66
use pglt_diagnostics::{Category, Severity};
77
use rustc_hash::FxHashSet;
88
#[cfg(feature = "schema")]

crates/pglt_configuration/src/files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
88
/// Limit the size of files to 1.0 MiB by default
99
pub const DEFAULT_FILE_SIZE_LIMIT: NonZeroU64 =
1010
// SAFETY: This constant is initialized with a non-zero value
11-
unsafe { NonZeroU64::new_unchecked(1024 * 1024) };
11+
NonZeroU64::new(1024 * 1024).unwrap();
1212

1313
/// The configuration of the filesystem
1414
#[derive(Clone, Debug, Deserialize, Eq, Partial, PartialEq, Serialize)]

crates/pglt_console/src/write/termcolor.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ where
5353
if adapter.error.is_err() {
5454
adapter.error
5555
} else {
56-
Err(io::Error::new(
57-
io::ErrorKind::Other,
58-
"a Display formatter returned an error",
59-
))
56+
Err(io::Error::other("a Display formatter returned an error"))
6057
}
6158
}
6259
}

crates/pglt_diagnostics/src/context.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,19 +344,15 @@ mod internal {
344344

345345
impl fmt::Write for DisplayMarkup<'_, '_> {
346346
fn write_str(&mut self, _: &fmt::MarkupElements<'_>, content: &str) -> io::Result<()> {
347-
self.0
348-
.write_str(content)
349-
.map_err(|error| io::Error::new(io::ErrorKind::Other, error))
347+
self.0.write_str(content).map_err(io::Error::other)
350348
}
351349

352350
fn write_fmt(
353351
&mut self,
354352
_: &fmt::MarkupElements<'_>,
355353
content: std::fmt::Arguments<'_>,
356354
) -> io::Result<()> {
357-
self.0
358-
.write_fmt(content)
359-
.map_err(|error| io::Error::new(io::ErrorKind::Other, error))
355+
self.0.write_fmt(content).map_err(io::Error::other)
360356
}
361357
}
362358

0 commit comments

Comments
 (0)