Add a check for poorly designed arg list

This commit is contained in:
sinn3r 2012-02-13 21:03:13 -06:00
parent 55ed89cf41
commit 4e32bfce22
1 changed files with 9 additions and 0 deletions

View File

@ -98,6 +98,15 @@ def check_single_file(dparts, fparts, f_rel)
show_missing(f, 'WARNING: contains "stack overflow" You mean "stack exhaustion"?', bad_term)
end
# If a function has more than 6 arguments, it should use a hash instead
functions = content.scan(/def (\w+)\(*(.+)\)*/)
functions.each do |func_name, args|
args_length = args.split(",").length
if args_length > 6
show_missing(f, "WARNING: Poorly designed argument list in '#{func_name}'. Try a hash.", false)
end
end
# check criteria based on individual lines
spaces = 0
bi = []