File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -274,18 +274,26 @@ def validate_module_name_content(name):
274274 "Module name proper is empty" ,
275275 )
276276
277+ # build a suggested fix for the module name:
278+ suggested_proper_name = re .sub (r"[^a-z0-9]+" , "-" , proper_name .lower ()).strip ("-" )
279+ if suggested_proper_name and re .fullmatch (r , suggested_proper_name ):
280+ suggestion = " Consider renaming it to '{}'." .format (suggested_proper_name )
281+ else :
282+ suggestion = ""
283+
277284 if proper_name [0 ] not in "abcdefghijklmnopqrstuvwxyz" :
278285 raise CFBSValidationError (
279286 name ,
280- "Module name must start with a lowercase ASCII letter ('{}' starts with '{}')" .format (
281- proper_name , proper_name [0 ]
287+ "Module name must start with a lowercase ASCII letter ('{}' starts with '{}'){} " .format (
288+ proper_name , proper_name [0 ], suggestion
282289 ),
283290 )
284291
285292 if not re .fullmatch (r , proper_name ):
286293 raise CFBSValidationError (
287294 name ,
288- "Module name contains illegal characters (only lowercase ASCII alphanumeric characters and single dash separators are allowed)" ,
295+ "Module name contains illegal characters (only lowercase ASCII alphanumeric characters and single dash separators are allowed)"
296+ + suggestion ,
289297 )
290298
291299 log .debug ("Successfully validated name of module %s" % name )
You can’t perform that action at this time.
0 commit comments