@@ -3223,14 +3223,62 @@ verify_strict_module_layout(Config) ->
32233223 Config , elvis_style , strict_module_layout , #{order => Order }, PassPath
32243224 ),
32253225
3226+ % causing trouble with a poor order
3227+ [
3228+ #{line_num := 2 },
3229+ #{line_num := 4 },
3230+ #{line_num := 14 },
3231+ #{line_num := 21 },
3232+ #{line_num := 42 },
3233+ #{line_num := 44 }
3234+ ] =
3235+ elvis_test_utils :elvis_core_apply_rule (
3236+ Config ,
3237+ elvis_style ,
3238+ strict_module_layout ,
3239+ #{order => [module , vsn , moduledoc , behaviour , comment , export_types , exports , body ]},
3240+ PassPath
3241+ ),
3242+
3243+ % empty order list, same as disabling thiss rule
3244+ [] =
3245+ elvis_test_utils :elvis_core_apply_rule (
3246+ Config , elvis_style , strict_module_layout , #{order => []}, PassPath
3247+ ),
3248+
32263249 FailModule = fail_strict_module_layout ,
32273250 FailPath = atom_to_list (FailModule ) ++ " ." ++ Ext ,
32283251
3229- [_ , _ , _ , _ , _ , _ ] =
3252+ [_ , _ , _ , _ , _ , _ , _ ] =
32303253 elvis_test_utils :elvis_core_apply_rule (
32313254 Config , elvis_style , strict_module_layout , #{order => Order }, FailPath
32323255 ),
32333256
3257+ % check a lot of stuff
3258+ [_ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ ] =
3259+ elvis_test_utils :elvis_core_apply_rule (
3260+ Config ,
3261+ elvis_style ,
3262+ strict_module_layout ,
3263+ #{
3264+ order => [
3265+ module ,
3266+ moduledoc ,
3267+ vsn ,
3268+ compile ,
3269+ behaviour ,
3270+ record ,
3271+ import ,
3272+ types ,
3273+ comment ,
3274+ exports ,
3275+ body
3276+ ]
3277+ },
3278+ FailPath
3279+ ),
3280+
3281+ % let's check just a few parts
32343282 [] =
32353283 elvis_test_utils :elvis_core_apply_rule (
32363284 Config , elvis_style , strict_module_layout , #{order => [module ]}, FailPath
@@ -3243,6 +3291,58 @@ verify_strict_module_layout(Config) ->
32433291 strict_module_layout ,
32443292 #{order => [module , exports , body ]},
32453293 FailPath
3294+ ),
3295+
3296+ % empty order list, same as disabling thiss rule
3297+ [] =
3298+ elvis_test_utils :elvis_core_apply_rule (
3299+ Config , elvis_style , strict_module_layout , #{order => []}, FailPath
3300+ ),
3301+
3302+ % this allways will fail
3303+ AllwaysFailModule = fail_strict_module_layout_allways ,
3304+ AllwaysFailPath = atom_to_list (AllwaysFailModule ) ++ " ." ++ Ext ,
3305+
3306+ [#{line_num := 5 }] =
3307+ elvis_test_utils :elvis_core_apply_rule (
3308+ Config ,
3309+ elvis_style ,
3310+ strict_module_layout ,
3311+ #{order => [module , types , export_types ]},
3312+ AllwaysFailPath
3313+ ),
3314+
3315+ [#{line_num := 3 }, #{line_num := 4 }] =
3316+ elvis_test_utils :elvis_core_apply_rule (
3317+ Config ,
3318+ elvis_style ,
3319+ strict_module_layout ,
3320+ #{order => [module , export_types , types ]},
3321+ AllwaysFailPath
3322+ ),
3323+
3324+ % if we don't add the module part, this will not fail
3325+ % because 'type' will not have any defined previous elements,
3326+ % so it basically not violate the rule
3327+ [] =
3328+ elvis_test_utils :elvis_core_apply_rule (
3329+ Config ,
3330+ elvis_style ,
3331+ strict_module_layout ,
3332+ #{order => [types , export_types ]},
3333+ AllwaysFailPath
3334+ ),
3335+
3336+ % repeating a keyword does not have any effect,
3337+ % because we get the first entry from the order list when checking
3338+ % if the the previous element matches with the right order or not
3339+ [#{line_num := 5 }] =
3340+ elvis_test_utils :elvis_core_apply_rule (
3341+ Config ,
3342+ elvis_style ,
3343+ strict_module_layout ,
3344+ #{order => [module , types , export_types , types ]},
3345+ AllwaysFailPath
32463346 ).
32473347
32483348verify_elvis_attr_atom_naming_convention (Config ) ->
0 commit comments