@@ -266,29 +266,49 @@ impl MainLoop {
266
266
Severity :: Error
267
267
} ;
268
268
269
- let failed = result
270
- . iter ( )
271
- . any ( |diagnostic| diagnostic. severity ( ) >= min_error_severity) ;
272
-
273
269
if check_revision == revision {
274
270
let mut stdout = stdout ( ) . lock ( ) ;
275
- for diagnostic in result {
276
- writeln ! ( stdout, "{}" , diagnostic. display( db, & display_config) ) ?;
271
+ if result. is_empty ( ) {
272
+ if db. project ( ) . files ( db) . is_empty ( ) {
273
+ tracing:: warn!( "No python files found under the given path(s)" ) ;
274
+ }
275
+
276
+ writeln ! ( stdout, "All checks passed!" ) ?;
277
+
278
+ if self . watcher . is_none ( ) {
279
+ return Ok ( ExitStatus :: Success ) ;
280
+ }
281
+ } else {
282
+ let mut failed = false ;
283
+ let diagnostics_count = result. len ( ) ;
284
+
285
+ for diagnostic in result {
286
+ writeln ! ( stdout, "{}" , diagnostic. display( db, & display_config) ) ?;
287
+
288
+ failed |= diagnostic. severity ( ) >= min_error_severity;
289
+ }
290
+
291
+ writeln ! (
292
+ stdout,
293
+ "Found {} diagnostic{}" ,
294
+ diagnostics_count,
295
+ if diagnostics_count > 1 { "s" } else { "" }
296
+ ) ?;
297
+
298
+ if self . watcher . is_none ( ) {
299
+ return Ok ( if failed {
300
+ ExitStatus :: Failure
301
+ } else {
302
+ ExitStatus :: Success
303
+ } ) ;
304
+ }
277
305
}
278
306
} else {
279
307
tracing:: debug!(
280
308
"Discarding check result for outdated revision: current: {revision}, result revision: {check_revision}"
281
309
) ;
282
310
}
283
311
284
- if self . watcher . is_none ( ) {
285
- return Ok ( if failed {
286
- ExitStatus :: Failure
287
- } else {
288
- ExitStatus :: Success
289
- } ) ;
290
- }
291
-
292
312
tracing:: trace!( "Counts after last check:\n {}" , countme:: get_all( ) ) ;
293
313
}
294
314
@@ -333,7 +353,9 @@ impl MainLoopCancellationToken {
333
353
enum MainLoopMessage {
334
354
CheckWorkspace ,
335
355
CheckCompleted {
356
+ /// The diagnostics that were found during the check.
336
357
result : Vec < Box < dyn Diagnostic > > ,
358
+
337
359
revision : u64 ,
338
360
} ,
339
361
ApplyChanges ( Vec < watch:: ChangeEvent > ) ,
0 commit comments