@@ -9,9 +9,7 @@ use itertools::{Itertools, iterate};
99use ruff_linter:: linter:: FixTable ;
1010use serde:: Serialize ;
1111
12- use ruff_db:: diagnostic:: {
13- Diagnostic , DiagnosticFormat , DisplayDiagnosticConfig , DisplayDiagnostics , SecondaryCode ,
14- } ;
12+ use ruff_db:: diagnostic:: { Diagnostic , DisplayDiagnosticConfig , SecondaryCode } ;
1513use ruff_linter:: fs:: relativize_path;
1614use ruff_linter:: logging:: LogLevel ;
1715use ruff_linter:: message:: { EmitterContext , render_diagnostics} ;
@@ -389,30 +387,19 @@ impl Printer {
389387 }
390388
391389 let context = EmitterContext :: new ( & diagnostics. notebook_indexes ) ;
392- if preview {
393- let config = DisplayDiagnosticConfig :: default ( )
394- . preview ( preview)
395- . hide_severity ( true )
396- . color ( !cfg ! ( test) && colored:: control:: SHOULD_COLORIZE . should_colorize ( ) )
397- . with_show_fix_status ( show_fix_status ( self . fix_mode , fixables. as_ref ( ) ) )
398- . with_fix_applicability ( self . unsafe_fixes . required_applicability ( ) )
399- . show_fix_diff ( preview) ;
400-
401- render_diagnostics ( writer, self . format , config, & context, & diagnostics. inner ) ?;
390+ let format = if preview {
391+ self . format
402392 } else {
403- let config = DisplayDiagnosticConfig :: default ( )
404- . hide_severity ( true )
405- . color ( !cfg ! ( test) && colored:: control:: SHOULD_COLORIZE . should_colorize ( ) )
406- . with_show_fix_status ( show_fix_status ( self . fix_mode , fixables. as_ref ( ) ) )
407- . format ( DiagnosticFormat :: Concise )
408- . with_fix_applicability ( self . unsafe_fixes . required_applicability ( ) ) ;
409-
410- write ! (
411- writer,
412- "{}" ,
413- DisplayDiagnostics :: new( & context, & config, & diagnostics. inner)
414- ) ?;
415- }
393+ OutputFormat :: Concise
394+ } ;
395+ let config = DisplayDiagnosticConfig :: default ( )
396+ . preview ( preview)
397+ . hide_severity ( true )
398+ . color ( !cfg ! ( test) && colored:: control:: SHOULD_COLORIZE . should_colorize ( ) )
399+ . with_show_fix_status ( show_fix_status ( self . fix_mode , fixables. as_ref ( ) ) )
400+ . with_fix_applicability ( self . unsafe_fixes . required_applicability ( ) )
401+ . show_fix_diff ( preview) ;
402+ render_diagnostics ( writer, format, config, & context, & diagnostics. inner ) ?;
416403 }
417404 writer. flush ( ) ?;
418405
0 commit comments