22 Copyright (C) 2018 Jules Lasne <jules.lasne@gmail.com>
33 See full notice in `LICENSE'
44"""
5-
65import os
76import glob
8- import subprocess
9- from PyChecker .utils import author , forbidden_functions , makefile , norme
7+ from PyChecker .utils import author , forbidden_functions , makefile , norme , static
108from PyChecker .testing_suite import maintest , moulitest , libftest
119
1210
@@ -33,6 +31,12 @@ def count_extras(project_path: str, required_functions, bonus_functions):
3331 for file in glob .glob (project_path + '/*.c' ):
3432 file_list .append (file .replace (project_path + '/' , '' ))
3533 extra_functions = [item for item in file_list if item not in required_functions and item not in bonus_functions ]
34+ print ("*---------------------------------------------------------------*" )
35+ print ("*------------------------Extra functions:-----------------------*" )
36+ print ("*---------------------------------------------------------------*" )
37+ print ("You have {} extra functions." .format (len (extra_functions )))
38+ for function in extra_functions :
39+ print (function )
3640 return extra_functions
3741
3842
@@ -58,18 +62,15 @@ def check(root_path: str, args):
5862 bonus_functions = ['ft_lstnew.c' , 'ft_lstdelone.c' , 'ft_lstdel.c' ,
5963 'ft_lstiter.c' , 'ft_lstadd.c' , 'ft_lstmap.c' ]
6064 authorized_functions = ['free' , 'malloc' , 'write' , 'main' ]
61- extra_functions = count_extras ( args .path , required_functions , bonus_functions )
62- print ( "You have {} extra functions." . format ( len ( extra_functions )))
63-
65+ if not args .no_extra :
66+ # @todo Stats on all c/h files of project, like with `cloc' ?
67+ count_extras ( args . path , required_functions , bonus_functions )
6468 if not args .no_author :
6569 author .check (args .path )
6670 if not args .no_norm :
6771 norme .check (args .path , root_path )
6872 if not args .no_static :
69- with open (root_path + "/.mystatic" , 'w+' ) as file :
70- result = subprocess .run (['sh' , 'scripts/check_static.sh' , args .path ],
71- stdout = subprocess .PIPE ).stdout .decode ('utf-8' )
72- file .write (result )
73+ static .check (root_path , args )
7374 if not args .no_makefile :
7475 makefile .check (args .path , "libft.a" , root_path )
7576 if not args .no_forbidden_functions :
0 commit comments