@@ -11,8 +11,7 @@ fn is_conventional_commit(message: &str) -> bool {
1111 "revert" ,
1212 ] ;
1313 for prefix in & prefixes {
14- if subject. starts_with ( prefix) {
15- let rest = & subject[ prefix. len ( ) ..] ;
14+ if let Some ( rest) = subject. strip_prefix ( prefix) {
1615 // "prefix: " or "prefix!: "
1716 if rest. starts_with ( ": " ) || rest. starts_with ( "!: " ) {
1817 return true ;
@@ -31,7 +30,6 @@ fn is_conventional_commit(message: &str) -> bool {
3130 false
3231}
3332
34-
3533/// Runs individual checks against GitHub API data
3634pub struct CheckRunner < ' a > {
3735 client : & ' a GithubClient ,
@@ -85,9 +83,7 @@ impl<'a> CheckRunner<'a> {
8583 Ok ( files) => {
8684 let yaml_files: Vec < & GithubContent > = files
8785 . iter ( )
88- . filter ( |f| {
89- f. name . ends_with ( ".yml" ) || f. name . ends_with ( ".yaml" )
90- } )
86+ . filter ( |f| f. name . ends_with ( ".yml" ) || f. name . ends_with ( ".yaml" ) )
9187 . collect ( ) ;
9288
9389 if yaml_files. is_empty ( ) {
@@ -97,11 +93,14 @@ impl<'a> CheckRunner<'a> {
9793 "Créez un fichier .github/workflows/ci.yml pour votre pipeline CI/CD" ,
9894 )
9995 } else {
100- let names: Vec < String > =
101- yaml_files. iter ( ) . map ( |f| f. name . clone ( ) ) . collect ( ) ;
96+ let names: Vec < String > = yaml_files. iter ( ) . map ( |f| f. name . clone ( ) ) . collect ( ) ;
10297 CheckResult :: passed (
10398 check,
104- format ! ( "{} workflow(s) trouvé(s) : {}" , names. len( ) , names. join( ", " ) ) ,
99+ format ! (
100+ "{} workflow(s) trouvé(s) : {}" ,
101+ names. len( ) ,
102+ names. join( ", " )
103+ ) ,
105104 )
106105 }
107106 }
@@ -145,7 +144,10 @@ impl<'a> CheckRunner<'a> {
145144 ) ,
146145 }
147146 }
148- Err ( _) => CheckResult :: skipped ( check, "Impossible de récupérer les runs (repo privé ou pas de workflows)" ) ,
147+ Err ( _) => CheckResult :: skipped (
148+ check,
149+ "Impossible de récupérer les runs (repo privé ou pas de workflows)" ,
150+ ) ,
149151 }
150152 }
151153
@@ -240,10 +242,10 @@ impl<'a> CheckRunner<'a> {
240242 let workflow_content = self . aggregate_workflow_content ( ) . await ;
241243
242244 let secret_patterns = [
243- "AKIA" , // AWS access key prefix
244- "sk-" , // OpenAI / Stripe key prefix
245- "ghp_" , // GitHub PAT
246- "password: " , // Inline password
245+ "AKIA" , // AWS access key prefix
246+ "sk-" , // OpenAI / Stripe key prefix
247+ "ghp_" , // GitHub PAT
248+ "password: " , // Inline password
247249 "passwd" ,
248250 "secret_key" ,
249251 ] ;
@@ -259,10 +261,7 @@ impl<'a> CheckRunner<'a> {
259261 } else {
260262 CheckResult :: failed (
261263 check,
262- format ! (
263- "Patterns suspects détectés : {}" ,
264- found_secrets. join( ", " )
265- ) ,
264+ format ! ( "Patterns suspects détectés : {}" , found_secrets. join( ", " ) ) ,
266265 "Utilisez des GitHub Secrets (${{ secrets.MY_SECRET }}) au lieu de valeurs en dur" ,
267266 )
268267 }
@@ -339,10 +338,7 @@ impl<'a> CheckRunner<'a> {
339338 "Ajoutez un outil de coverage (codecov, tarpaulin, istanbul) dans votre CI" ,
340339 )
341340 } else {
342- CheckResult :: passed (
343- check,
344- format ! ( "Coverage détectée : {}" , found. join( ", " ) ) ,
345- )
341+ CheckResult :: passed ( check, format ! ( "Coverage détectée : {}" , found. join( ", " ) ) )
346342 }
347343 }
348344
@@ -415,11 +411,18 @@ impl<'a> CheckRunner<'a> {
415411 let completed_runs: Vec < & WorkflowRun > = runs
416412 . workflow_runs
417413 . iter ( )
418- . filter ( |r| r. conclusion . is_some ( ) && r. run_started_at . is_some ( ) && r. updated_at . is_some ( ) )
414+ . filter ( |r| {
415+ r. conclusion . is_some ( )
416+ && r. run_started_at . is_some ( )
417+ && r. updated_at . is_some ( )
418+ } )
419419 . collect ( ) ;
420420
421421 if completed_runs. is_empty ( ) {
422- return CheckResult :: skipped ( check, "Pas assez de runs pour évaluer la vitesse" ) ;
422+ return CheckResult :: skipped (
423+ check,
424+ "Pas assez de runs pour évaluer la vitesse" ,
425+ ) ;
423426 }
424427
425428 // Simple duration estimation: we can't do precise parsing in WASM easily,
@@ -459,7 +462,10 @@ impl<'a> CheckRunner<'a> {
459462 if has_multi_env {
460463 CheckResult :: passed (
461464 check,
462- format ! ( "Indicateurs multi-environnement détectés : {}" , found. join( ", " ) ) ,
465+ format ! (
466+ "Indicateurs multi-environnement détectés : {}" ,
467+ found. join( ", " )
468+ ) ,
463469 )
464470 } else {
465471 CheckResult :: failed (
@@ -475,33 +481,17 @@ impl<'a> CheckRunner<'a> {
475481 let content_lower = workflow_content. to_lowercase ( ) ;
476482
477483 let deploy_indicators = [
478- "deploy" ,
479- "publish" ,
480- "release" ,
481- "gh-pages" ,
482- "pages" ,
483- "aws" ,
484- "azure" ,
485- "gcloud" ,
486- "heroku" ,
487- "vercel" ,
488- "netlify" ,
489- "render" ,
490- "fly.io" ,
484+ "deploy" , "publish" , "release" , "gh-pages" , "pages" , "aws" , "azure" , "gcloud" ,
485+ "heroku" , "vercel" , "netlify" , "render" , "fly.io" ,
491486 ] ;
492487
493488 let has_push_trigger =
494489 content_lower. contains ( "on:\n push:" ) || content_lower. contains ( "on: [push" ) ;
495490
496- let has_deploy = deploy_indicators
497- . iter ( )
498- . any ( |d| content_lower. contains ( d) ) ;
491+ let has_deploy = deploy_indicators. iter ( ) . any ( |d| content_lower. contains ( d) ) ;
499492
500493 if has_push_trigger && has_deploy {
501- CheckResult :: passed (
502- check,
503- "Déploiement automatique détecté sur push" ,
504- )
494+ CheckResult :: passed ( check, "Déploiement automatique détecté sur push" )
505495 } else if has_deploy {
506496 CheckResult :: warning (
507497 check,
@@ -525,10 +515,7 @@ impl<'a> CheckRunner<'a> {
525515 . client
526516 . file_exists ( self . repo , ".github/CODEOWNERS" )
527517 . await
528- || self
529- . client
530- . file_exists ( self . repo , "docs/CODEOWNERS" )
531- . await ;
518+ || self . client . file_exists ( self . repo , "docs/CODEOWNERS" ) . await ;
532519
533520 if exists {
534521 CheckResult :: passed ( check, "Fichier CODEOWNERS trouvé" )
@@ -581,7 +568,10 @@ impl<'a> CheckRunner<'a> {
581568 ) ,
582569 Some ( c) => CheckResult :: failed (
583570 check,
584- format ! ( "Pipeline terminé avec le statut '{}' — les tests ont peut-être échoué" , c) ,
571+ format ! (
572+ "Pipeline terminé avec le statut '{}' — les tests ont peut-être échoué" ,
573+ c
574+ ) ,
585575 "Corrigez les tests en échec pour passer ce check" ,
586576 ) ,
587577 None => CheckResult :: skipped ( check, "Run encore en cours" ) ,
@@ -605,10 +595,7 @@ impl<'a> CheckRunner<'a> {
605595 || content_lower. contains ( "build-push-action" ) ;
606596
607597 if has_ghcr && has_push {
608- CheckResult :: passed (
609- check,
610- "Publication vers ghcr.io détectée dans le pipeline" ,
611- )
598+ CheckResult :: passed ( check, "Publication vers ghcr.io détectée dans le pipeline" )
612599 } else if has_ghcr {
613600 CheckResult :: warning (
614601 check,
@@ -688,10 +675,7 @@ impl<'a> CheckRunner<'a> {
688675 } ;
689676
690677 if !cache_type. is_empty ( ) {
691- CheckResult :: passed (
692- check,
693- format ! ( "Cache CI détecté : {}" , cache_type) ,
694- )
678+ CheckResult :: passed ( check, format ! ( "Cache CI détecté : {}" , cache_type) )
695679 } else {
696680 CheckResult :: failed (
697681 check,
@@ -787,7 +771,10 @@ impl<'a> CheckRunner<'a> {
787771 if defines_reusable {
788772 CheckResult :: passed ( check, "Workflow réutilisable défini (workflow_call) — peut être invoqué par d'autres repos" )
789773 } else if calls_reusable {
790- CheckResult :: passed ( check, "Workflow réutilisable appelé (uses: ./.github/workflows/) — bonne pratique DRY" )
774+ CheckResult :: passed (
775+ check,
776+ "Workflow réutilisable appelé (uses: ./.github/workflows/) — bonne pratique DRY" ,
777+ )
791778 } else {
792779 CheckResult :: failed (
793780 check,
@@ -949,7 +936,10 @@ impl<'a> CheckRunner<'a> {
949936 if !found. is_empty ( ) {
950937 return CheckResult :: passed (
951938 check,
952- format ! ( "Outil de changelog automatisé détecté : {}" , found. join( ", " ) ) ,
939+ format ! (
940+ "Outil de changelog automatisé détecté : {}" ,
941+ found. join( ", " )
942+ ) ,
953943 ) ;
954944 }
955945
@@ -1004,20 +994,14 @@ impl<'a> CheckRunner<'a> {
1004994 || content_lower. contains ( "undo-deploy" )
1005995 || content_lower. contains ( "undo_deploy" )
1006996 {
1007- return CheckResult :: passed (
1008- check,
1009- "Mécanisme de rollback détecté dans les workflows" ,
1010- ) ;
997+ return CheckResult :: passed ( check, "Mécanisme de rollback détecté dans les workflows" ) ;
1011998 }
1012999
10131000 // Check for workflow_dispatch with rollback input (manual redeploy)
10141001 if workflow_content. contains ( "workflow_dispatch:" )
10151002 && ( content_lower. contains ( "revert" ) || content_lower. contains ( "rollback" ) )
10161003 {
1017- return CheckResult :: passed (
1018- check,
1019- "workflow_dispatch avec option de revert détecté" ,
1020- ) ;
1004+ return CheckResult :: passed ( check, "workflow_dispatch avec option de revert détecté" ) ;
10211005 }
10221006
10231007 // Partial credit: workflow_dispatch alone = manual recovery possible
@@ -1049,7 +1033,9 @@ impl<'a> CheckRunner<'a> {
10491033 for file in & files {
10501034 let is_yaml = file. name . ends_with ( ".yml" ) || file. name . ends_with ( ".yaml" ) ;
10511035 if is_yaml {
1052- if let Ok ( file_content) = self . client . fetch_file_content ( self . repo , & file. path ) . await {
1036+ if let Ok ( file_content) =
1037+ self . client . fetch_file_content ( self . repo , & file. path ) . await
1038+ {
10531039 content. push_str ( & file_content) ;
10541040 content. push ( '\n' ) ;
10551041 }
0 commit comments