@@ -57,37 +57,44 @@ impl Violation for Airflow3Removal {
57
57
}
58
58
}
59
59
60
- struct DeprecatedArgument ( Vec < & ' static str > , Option < & ' static str > ) ;
60
+ fn diagnostic_for_argument (
61
+ arguments : & Arguments ,
62
+ deprecated : & str ,
63
+ replacement : Option < & str > ,
64
+ ) -> Option < Diagnostic > {
65
+ let keyword = arguments. find_keyword ( deprecated) ?;
66
+ Some ( Diagnostic :: new (
67
+ Airflow3Removal {
68
+ deprecated : ( * deprecated) . to_string ( ) ,
69
+ replacement : match replacement {
70
+ Some ( name) => Replacement :: Name ( name. to_owned ( ) ) ,
71
+ None => Replacement :: None ,
72
+ } ,
73
+ } ,
74
+ keyword
75
+ . arg
76
+ . as_ref ( )
77
+ . map_or_else ( || keyword. range ( ) , Ranged :: range) ,
78
+ ) )
79
+ }
61
80
62
81
fn removed_argument ( checker : & mut Checker , qualname : & QualifiedName , arguments : & Arguments ) {
63
- let deprecations = match qualname. segments ( ) {
64
- [ "airflow" , .., "DAG" | "dag" ] => vec ! [ DeprecatedArgument (
65
- vec![ "timetable" , "schedule_interval" ] ,
66
- Some ( "schedule" ) ,
67
- ) ] ,
68
- _ => {
69
- return ;
82
+ #[ allow( clippy:: single_match) ]
83
+ match qualname. segments ( ) {
84
+ [ "airflow" , .., "DAG" | "dag" ] => {
85
+ checker. diagnostics . extend ( diagnostic_for_argument (
86
+ arguments,
87
+ "schedule_interval" ,
88
+ Some ( "schedule" ) ,
89
+ ) ) ;
90
+ checker. diagnostics . extend ( diagnostic_for_argument (
91
+ arguments,
92
+ "timetable" ,
93
+ Some ( "schedule" ) ,
94
+ ) ) ;
70
95
}
96
+ _ => { }
71
97
} ;
72
- for deprecation in deprecations {
73
- for arg in deprecation. 0 {
74
- if let Some ( keyword) = arguments. find_keyword ( arg) {
75
- checker. diagnostics . push ( Diagnostic :: new (
76
- Airflow3Removal {
77
- deprecated : arg. to_string ( ) ,
78
- replacement : match deprecation. 1 {
79
- Some ( name) => Replacement :: Name ( name. to_owned ( ) ) ,
80
- None => Replacement :: None ,
81
- } ,
82
- } ,
83
- keyword
84
- . arg
85
- . as_ref ( )
86
- . map_or_else ( || keyword. range ( ) , Ranged :: range) ,
87
- ) ) ;
88
- } ;
89
- }
90
- }
91
98
}
92
99
93
100
fn removed_name ( checker : & mut Checker , expr : & Expr , ranged : impl Ranged ) {
0 commit comments