@@ -11,7 +11,7 @@ use std::{
1111} ;
1212
1313// non-std crates
14- use anyhow:: { anyhow , Context , Result } ;
14+ use anyhow:: { Context , Result , anyhow } ;
1515use git2:: { DiffOptions , Patch } ;
1616use regex:: Regex ;
1717use semver:: Version ;
@@ -22,12 +22,12 @@ use which::{which, which_in};
2222use super :: common_fs:: FileObj ;
2323use crate :: {
2424 cli:: { ClangParams , RequestedVersion } ,
25- rest_api:: { RestApiClient , COMMENT_MARKER , USER_OUTREACH } ,
25+ rest_api:: { COMMENT_MARKER , RestApiClient , USER_OUTREACH } ,
2626} ;
2727pub mod clang_format;
2828use clang_format:: run_clang_format;
2929pub mod clang_tidy;
30- use clang_tidy:: { run_clang_tidy , CompilationUnit } ;
30+ use clang_tidy:: { CompilationUnit , run_clang_tidy } ;
3131
3232#[ derive( Debug ) ]
3333pub enum ClangTool {
@@ -229,14 +229,14 @@ pub async fn capture_clang_tools_output(
229229 }
230230
231231 // parse database (if provided) to match filenames when parsing clang-tidy's stdout
232- if let Some ( db_path) = & clang_params. database {
233- if let Ok ( db_str) = fs:: read ( db_path. join ( "compile_commands.json" ) ) {
234- clang_params . database_json = Some (
235- // A compilation database should be UTF-8 encoded, but file paths are not; use lossy conversion.
236- serde_json :: from_str :: < Vec < CompilationUnit > > ( & String :: from_utf8_lossy ( & db_str ) )
237- . with_context ( || "Failed to parse compile_commands.json" ) ? ,
238- )
239- }
232+ if let Some ( db_path) = & clang_params. database
233+ && let Ok ( db_str) = fs:: read ( db_path. join ( "compile_commands.json" ) )
234+ {
235+ clang_params . database_json = Some (
236+ // A compilation database should be UTF-8 encoded, but file paths are not; use lossy conversion.
237+ serde_json :: from_str :: < Vec < CompilationUnit > > ( & String :: from_utf8_lossy ( & db_str ) )
238+ . with_context ( || "Failed to parse compile_commands.json" ) ? ,
239+ )
240240 } ;
241241
242242 let mut executors = JoinSet :: new ( ) ;
@@ -503,24 +503,26 @@ mod tests {
503503 let req_version = RequestedVersion :: from_str ( requirement) . unwrap ( ) ;
504504 let tool_exe = CLANG_FORMAT . get_exe_path ( & req_version) ;
505505 println ! ( "tool_exe: {:?}" , tool_exe) ;
506- assert ! ( tool_exe. is_ok_and( |val| val
507- . file_name( )
508- . unwrap( )
509- . to_string_lossy( )
510- . to_string( )
511- . contains( CLANG_FORMAT . as_str( ) ) ) ) ;
506+ assert ! ( tool_exe. is_ok_and( |val| {
507+ val. file_name( )
508+ . unwrap( )
509+ . to_string_lossy( )
510+ . to_string( )
511+ . contains( CLANG_FORMAT . as_str( ) )
512+ } ) ) ;
512513 }
513514
514515 #[ test]
515516 fn get_exe_by_default ( ) {
516517 let tool_exe = CLANG_FORMAT . get_exe_path ( & RequestedVersion :: from_str ( "" ) . unwrap ( ) ) ;
517518 println ! ( "tool_exe: {:?}" , tool_exe) ;
518- assert ! ( tool_exe. is_ok_and( |val| val
519- . file_name( )
520- . unwrap( )
521- . to_string_lossy( )
522- . to_string( )
523- . contains( CLANG_FORMAT . as_str( ) ) ) ) ;
519+ assert ! ( tool_exe. is_ok_and( |val| {
520+ val. file_name( )
521+ . unwrap( )
522+ . to_string_lossy( )
523+ . to_string( )
524+ . contains( CLANG_FORMAT . as_str( ) )
525+ } ) ) ;
524526 }
525527
526528 #[ test]
@@ -531,12 +533,13 @@ mod tests {
531533 println ! ( "binary exe path: {bin_path}" ) ;
532534 let tool_exe = CLANG_FORMAT . get_exe_path ( & RequestedVersion :: from_str ( bin_path) . unwrap ( ) ) ;
533535 println ! ( "tool_exe: {:?}" , tool_exe) ;
534- assert ! ( tool_exe. is_ok_and( |val| val
535- . file_name( )
536- . unwrap( )
537- . to_string_lossy( )
538- . to_string( )
539- . contains( TOOL_NAME ) ) ) ;
536+ assert ! ( tool_exe. is_ok_and( |val| {
537+ val. file_name( )
538+ . unwrap( )
539+ . to_string_lossy( )
540+ . to_string( )
541+ . contains( TOOL_NAME )
542+ } ) ) ;
540543 }
541544
542545 #[ test]
0 commit comments