Skip to content

Commit 5e174c7

Browse files
adjust
1 parent e51c149 commit 5e174c7

File tree

9 files changed

+7
-120
lines changed

9 files changed

+7
-120
lines changed

crates/pg_cli/src/cli_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct CliOptions {
1818
#[bpaf(long("use-server"), switch, fallback(false))]
1919
pub use_server: bool,
2020

21-
/// Skip over files containing syntax errors instead of emitting an error diagnostic.
21+
/// Skip connecting to the database and only run checks that don't require a database connection.
2222
#[bpaf(long("skip-db"), switch, fallback(false))]
2323
pub skip_db: bool,
2424

crates/pg_cli/src/execute/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::reporter::github::{GithubReporter, GithubReporterVisitor};
99
use crate::reporter::gitlab::{GitLabReporter, GitLabReporterVisitor};
1010
use crate::reporter::junit::{JunitReporter, JunitReporterVisitor};
1111
use crate::reporter::terminal::{ConsoleReporter, ConsoleReporterVisitor};
12-
use crate::reporter::UserHintsPayload;
1312
use crate::{CliDiagnostic, CliSession, DiagnosticsPayload, Reporter};
1413
use pg_diagnostics::{category, Category};
1514
use pg_fs::PgLspPath;
@@ -243,7 +242,6 @@ pub fn execute_mode(
243242
summary,
244243
evaluated_paths,
245244
diagnostics,
246-
user_hints,
247245
} = traverse(&execution, &mut session, cli_options, paths)?;
248246
let console = session.app.console;
249247
let errors = summary.errors;
@@ -262,7 +260,6 @@ pub fn execute_mode(
262260
},
263261
execution: execution.clone(),
264262
evaluated_paths,
265-
user_hints_payload: UserHintsPayload { hints: user_hints },
266263
};
267264
reporter.write(&mut ConsoleReporterVisitor(console))?;
268265
}
@@ -274,7 +271,6 @@ pub fn execute_mode(
274271
diagnostics,
275272
},
276273
execution: execution.clone(),
277-
user_hints: UserHintsPayload { hints: user_hints },
278274
};
279275
reporter.write(&mut GithubReporterVisitor(console))?;
280276
}
@@ -286,7 +282,6 @@ pub fn execute_mode(
286282
diagnostics,
287283
},
288284
execution: execution.clone(),
289-
user_hints: UserHintsPayload { hints: user_hints },
290285
};
291286
reporter.write(&mut GitLabReporterVisitor::new(
292287
console,
@@ -302,7 +297,6 @@ pub fn execute_mode(
302297
diagnostics,
303298
},
304299
execution: execution.clone(),
305-
user_hints: UserHintsPayload { hints: user_hints },
306300
};
307301
reporter.write(&mut JunitReporterVisitor::new(console))?;
308302
}

crates/pg_cli/src/execute/process_file.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub(crate) enum Message {
4646
diagnostics: Vec<Error>,
4747
skipped_diagnostics: u32,
4848
},
49-
Hint(String),
5049
}
5150

5251
impl Message {

crates/pg_cli/src/execute/traverse.rs

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use pg_workspace::workspace::IsPathIgnoredParams;
1414
use pg_workspace::{Workspace, WorkspaceError};
1515
use rustc_hash::FxHashSet;
1616
use std::collections::BTreeSet;
17-
use std::sync::atomic::{AtomicBool, AtomicU32};
17+
use std::sync::atomic::AtomicU32;
1818
use std::sync::RwLock;
1919
use std::{
2020
env::current_dir,
@@ -33,7 +33,6 @@ pub(crate) struct TraverseResult {
3333
pub(crate) summary: TraversalSummary,
3434
pub(crate) evaluated_paths: BTreeSet<PgLspPath>,
3535
pub(crate) diagnostics: Vec<Error>,
36-
pub(crate) user_hints: Vec<String>,
3736
}
3837

3938
pub(crate) fn traverse(
@@ -73,7 +72,6 @@ pub(crate) fn traverse(
7372
let unchanged = AtomicUsize::new(0);
7473
let matches = AtomicUsize::new(0);
7574
let skipped = AtomicUsize::new(0);
76-
let skipped_db_conn = AtomicBool::new(false);
7775

7876
let fs = &*session.app.fs;
7977
let workspace = &*session.app.workspace;
@@ -86,7 +84,7 @@ pub(crate) fn traverse(
8684
.with_diagnostic_level(cli_options.diagnostic_level)
8785
.with_max_diagnostics(max_diagnostics);
8886

89-
let (duration, evaluated_paths, diagnostics, mut user_hints) = thread::scope(|s| {
87+
let (duration, evaluated_paths, diagnostics) = thread::scope(|s| {
9088
let handler = thread::Builder::new()
9189
.name(String::from("pglsp::console"))
9290
.spawn_scoped(s, || printer.run(receiver, recv_files))
@@ -106,16 +104,15 @@ pub(crate) fn traverse(
106104
changed: &changed,
107105
unchanged: &unchanged,
108106
skipped: &skipped,
109-
skipped_db_conn: &skipped_db_conn,
110107
messages: sender,
111108
remaining_diagnostics: &remaining_diagnostics,
112109
evaluated_paths: RwLock::default(),
113110
},
114111
);
115112
// wait for the main thread to finish
116-
let (diagnostics, user_hints) = handler.join().unwrap();
113+
let diagnostics = handler.join().unwrap();
117114

118-
(elapsed, evaluated_paths, diagnostics, user_hints)
115+
(elapsed, evaluated_paths, diagnostics)
119116
});
120117

121118
let errors = printer.errors();
@@ -127,19 +124,6 @@ pub(crate) fn traverse(
127124
let suggested_fixes_skipped = printer.skipped_fixes();
128125
let diagnostics_not_printed = printer.not_printed_diagnostics();
129126

130-
if duration.as_secs() >= 2 {
131-
user_hints.push(format!(
132-
"The traversal took longer than expected ({}s). Consider using the `--skip-db` option if your Postgres connection is slow.",
133-
duration.as_secs()
134-
));
135-
}
136-
137-
if skipped_db_conn.load(Ordering::Relaxed) {
138-
user_hints.push(format!(
139-
"Skipped all checks requiring database connections.",
140-
));
141-
}
142-
143127
Ok(TraverseResult {
144128
summary: TraversalSummary {
145129
changed,
@@ -154,7 +138,6 @@ pub(crate) fn traverse(
154138
},
155139
evaluated_paths,
156140
diagnostics,
157-
user_hints,
158141
})
159142
}
160143

@@ -306,15 +289,10 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
306289
should_print
307290
}
308291

309-
fn run(
310-
&self,
311-
receiver: Receiver<Message>,
312-
interner: Receiver<PathBuf>,
313-
) -> (Vec<Error>, Vec<String>) {
292+
fn run(&self, receiver: Receiver<Message>, interner: Receiver<PathBuf>) -> Vec<Error> {
314293
let mut paths: FxHashSet<String> = FxHashSet::default();
315294

316295
let mut diagnostics_to_print = vec![];
317-
let mut hints_to_print = vec![];
318296

319297
while let Ok(msg) = receiver.recv() {
320298
match msg {
@@ -329,10 +307,6 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
329307
self.errors.fetch_add(1, Ordering::Relaxed);
330308
}
331309

332-
Message::Hint(hint) => {
333-
hints_to_print.push(hint);
334-
}
335-
336310
Message::Error(mut err) => {
337311
let location = err.location();
338312
if self.should_skip_diagnostic(err.severity(), err.tags()) {
@@ -409,7 +383,7 @@ impl<'ctx> DiagnosticsPrinter<'ctx> {
409383
}
410384
}
411385

412-
(diagnostics_to_print, hints_to_print)
386+
diagnostics_to_print
413387
}
414388
}
415389

@@ -431,8 +405,6 @@ pub(crate) struct TraversalOptions<'ctx, 'app> {
431405
matches: &'ctx AtomicUsize,
432406
/// Shared atomic counter storing the number of skipped files
433407
skipped: &'ctx AtomicUsize,
434-
/// Shared atomic bool tracking whether we used a DB connection
435-
skipped_db_conn: &'ctx AtomicBool,
436408
/// Channel sending messages to the display thread
437409
pub(crate) messages: Sender<Message>,
438410
/// The approximate number of diagnostics the console will print before
@@ -464,10 +436,6 @@ impl TraversalOptions<'_, '_> {
464436
self.messages.send(msg.into()).ok();
465437
}
466438

467-
pub(crate) fn set_skipped_db_conn(&self, has_skipped: bool) {
468-
self.skipped_db_conn.store(has_skipped, Ordering::Relaxed);
469-
}
470-
471439
pub(crate) fn protected_file(&self, pglsp_path: &PgLspPath) {
472440
self.push_diagnostic(
473441
WorkspaceError::protected_file(pglsp_path.display().to_string()).into(),

crates/pg_cli/src/reporter/github.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ use pg_console::{markup, Console, ConsoleExt};
33
use pg_diagnostics::PrintGitHubDiagnostic;
44
use std::io;
55

6-
use super::UserHintsPayload;
7-
86
pub(crate) struct GithubReporter {
97
pub(crate) diagnostics_payload: DiagnosticsPayload,
108
pub(crate) execution: Execution,
11-
pub(crate) user_hints: UserHintsPayload,
129
}
1310

1411
impl Reporter for GithubReporter {
1512
fn write(self, visitor: &mut dyn ReporterVisitor) -> io::Result<()> {
1613
visitor.report_diagnostics(&self.execution, self.diagnostics_payload)?;
17-
visitor.report_user_hints(&self.execution, self.user_hints)?;
1814
Ok(())
1915
}
2016
}
@@ -46,15 +42,4 @@ impl ReporterVisitor for GithubReporterVisitor<'_> {
4642

4743
Ok(())
4844
}
49-
50-
fn report_user_hints(
51-
&mut self,
52-
_execution: &Execution,
53-
payload: super::UserHintsPayload,
54-
) -> io::Result<()> {
55-
for hint in payload.hints {
56-
self.0.log(markup! {{hint}});
57-
}
58-
Ok(())
59-
}
6045
}

crates/pg_cli/src/reporter/gitlab.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@ use std::{
1212
path::{Path, PathBuf},
1313
};
1414

15-
use super::UserHintsPayload;
16-
1715
pub struct GitLabReporter {
1816
pub(crate) execution: Execution,
1917
pub(crate) diagnostics: DiagnosticsPayload,
20-
pub(crate) user_hints: UserHintsPayload,
2118
}
2219

2320
impl Reporter for GitLabReporter {
2421
fn write(self, visitor: &mut dyn ReporterVisitor) -> std::io::Result<()> {
2522
visitor.report_diagnostics(&self.execution, self.diagnostics)?;
26-
visitor.report_user_hints(&self.execution, self.user_hints)?;
2723
Ok(())
2824
}
2925
}
@@ -76,17 +72,6 @@ impl ReporterVisitor for GitLabReporterVisitor<'_> {
7672
self.console.log(markup!({ diagnostics }));
7773
Ok(())
7874
}
79-
80-
fn report_user_hints(
81-
&mut self,
82-
_execution: &Execution,
83-
payload: super::UserHintsPayload,
84-
) -> std::io::Result<()> {
85-
for hint in payload.hints {
86-
self.console.log(markup! {{hint}});
87-
}
88-
Ok(())
89-
}
9075
}
9176

9277
struct GitLabDiagnostics<'a>(

crates/pg_cli/src/reporter/junit.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@ use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite};
66
use std::fmt::{Display, Formatter};
77
use std::io;
88

9-
use super::UserHintsPayload;
10-
119
pub(crate) struct JunitReporter {
1210
pub(crate) diagnostics_payload: DiagnosticsPayload,
1311
pub(crate) execution: Execution,
1412
pub(crate) summary: TraversalSummary,
15-
pub(crate) user_hints: UserHintsPayload,
1613
}
1714

1815
impl Reporter for JunitReporter {
1916
fn write(self, visitor: &mut dyn ReporterVisitor) -> io::Result<()> {
2017
visitor.report_summary(&self.execution, self.summary)?;
2118
visitor.report_diagnostics(&self.execution, self.diagnostics_payload)?;
22-
visitor.report_user_hints(&self.execution, self.user_hints)?;
2319
Ok(())
2420
}
2521
}
@@ -122,17 +118,4 @@ impl ReporterVisitor for JunitReporterVisitor<'_> {
122118

123119
Ok(())
124120
}
125-
126-
fn report_user_hints(
127-
&mut self,
128-
_execution: &Execution,
129-
payload: super::UserHintsPayload,
130-
) -> io::Result<()> {
131-
for hint in payload.hints {
132-
self.1.log(markup! {
133-
{hint}
134-
});
135-
}
136-
Ok(())
137-
}
138121
}

crates/pg_cli/src/reporter/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ pub struct DiagnosticsPayload {
1717
pub diagnostic_level: Severity,
1818
}
1919

20-
pub struct UserHintsPayload {
21-
pub hints: Vec<String>,
22-
}
23-
2420
/// A type that holds the result of the traversal
2521
#[derive(Debug, Default, Serialize, Copy, Clone)]
2622
pub struct TraversalSummary {
@@ -64,11 +60,4 @@ pub trait ReporterVisitor {
6460
execution: &Execution,
6561
payload: DiagnosticsPayload,
6662
) -> io::Result<()>;
67-
68-
/// Writes a diagnostics
69-
fn report_user_hints(
70-
&mut self,
71-
execution: &Execution,
72-
payload: UserHintsPayload,
73-
) -> io::Result<()>;
7463
}

crates/pg_cli/src/reporter/terminal.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ use std::collections::BTreeSet;
1010
use std::io;
1111
use std::time::Duration;
1212

13-
use super::UserHintsPayload;
14-
1513
pub(crate) struct ConsoleReporter {
1614
pub(crate) summary: TraversalSummary,
1715
pub(crate) diagnostics_payload: DiagnosticsPayload,
1816
pub(crate) execution: Execution,
1917
pub(crate) evaluated_paths: BTreeSet<PgLspPath>,
20-
pub(crate) user_hints_payload: UserHintsPayload,
2118
}
2219

2320
impl Reporter for ConsoleReporter {
2421
fn write(self, visitor: &mut dyn ReporterVisitor) -> io::Result<()> {
2522
let verbose = self.diagnostics_payload.verbose;
2623
visitor.report_diagnostics(&self.execution, self.diagnostics_payload)?;
2724
visitor.report_summary(&self.execution, self.summary)?;
28-
visitor.report_user_hints(&self.execution, self.user_hints_payload)?;
2925
if verbose {
3026
visitor.report_handled_paths(self.evaluated_paths)?;
3127
}
@@ -119,18 +115,6 @@ impl ReporterVisitor for ConsoleReporterVisitor<'_> {
119115

120116
Ok(())
121117
}
122-
123-
fn report_user_hints(
124-
&mut self,
125-
_execution: &Execution,
126-
payload: UserHintsPayload,
127-
) -> io::Result<()> {
128-
for hint in payload.hints {
129-
self.0.log(markup! {{hint}});
130-
}
131-
self.0.log(markup! {{"\n"}});
132-
Ok(())
133-
}
134118
}
135119

136120
struct Files(usize);

0 commit comments

Comments
 (0)