@@ -72,6 +72,19 @@ impl Lint {
72
72
}
73
73
}
74
74
75
+ /// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
76
+ pub fn gen_lint_group_list ( lints : Vec < Lint > ) -> Vec < String > {
77
+ lints. into_iter ( )
78
+ . filter_map ( |l| {
79
+ if l. is_internal ( ) || l. deprecation . is_some ( ) {
80
+ None
81
+ } else {
82
+ Some ( format ! ( " {}::{}," , l. module, l. name. to_uppercase( ) ) )
83
+ }
84
+ } )
85
+ . sorted ( )
86
+ }
87
+
75
88
/// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
76
89
pub fn gen_modules_list ( lints : Vec < Lint > ) -> Vec < String > {
77
90
lints. into_iter ( )
@@ -390,3 +403,18 @@ fn test_gen_modules_list() {
390
403
] ;
391
404
assert_eq ! ( expected, gen_modules_list( lints) ) ;
392
405
}
406
+
407
+ #[ test]
408
+ fn test_gen_lint_group_list ( ) {
409
+ let lints = vec ! [
410
+ Lint :: new( "abc" , "group1" , "abc" , None , "module_name" ) ,
411
+ Lint :: new( "should_assert_eq" , "group1" , "abc" , None , "module_name" ) ,
412
+ Lint :: new( "should_assert_eq2" , "group2" , "abc" , Some ( "abc" ) , "deprecated" ) ,
413
+ Lint :: new( "incorrect_internal" , "internal_style" , "abc" , None , "module_name" ) ,
414
+ ] ;
415
+ let expected = vec ! [
416
+ " module_name::ABC," . to_string( ) ,
417
+ " module_name::SHOULD_ASSERT_EQ," . to_string( ) ,
418
+ ] ;
419
+ assert_eq ! ( expected, gen_lint_group_list( lints) ) ;
420
+ }
0 commit comments