def execute(): output_start('phpcs') dirs = get_dirs() phpcs_standard = dirs['project'] + get_value('phpcs-standard') check_dir = get_value('check-dir') exclude_dirs = [] for exclude_dir in get_value('exclude-dirs'): exclude_dirs.append(exclude_dir + '/*') excludes = ','.join(exclude_dirs) if excludes != '': excludes = '--ignore=' + excludes if not os.path.isfile(phpcs_standard): print( '>>> No phpcs-standard found. Fallback is the default move-elevator/symfony-coding-standard:' ) phpcs_standard = get_value( 'checker-dir' ) + 'vendor/move-elevator/symfony-coding-standard/Standards/Symfony2' print('>>> phpcs standard: ' + phpcs_standard) print('>>> Excludes: ' + excludes) code = php( 'phpcs', '--standard=' + phpcs_standard + ' --extensions=php --report-checkstyle=' + check_dir + 'checkstyle.xml ' + excludes + ' ' + dirs['scan']) if code == 512: output_error('There was a error/exception while executing phpcs.')
def execute(): output_start('phpcs') dirs = get_dirs() phpcs_standard = dirs['project']+get_value('phpcs-standard') check_dir = get_value('check-dir') exclude_dirs = [] for exclude_dir in get_value('exclude-dirs'): exclude_dirs.append(exclude_dir+'/*') excludes = ','.join(exclude_dirs) if excludes != '': excludes = '--ignore='+excludes if not os.path.isfile(phpcs_standard): print('>>> No phpcs-standard found. Fallback is the default move-elevator/symfony-coding-standard:') phpcs_standard = get_value('checker-dir')+'vendor/move-elevator/symfony-coding-standard/Standards/Symfony2' print('>>> phpcs standard: '+phpcs_standard) print('>>> Excludes: '+excludes) code = php('phpcs', '--standard='+phpcs_standard+' --extensions=php --report-checkstyle='+check_dir+'checkstyle.xml '+excludes+' '+dirs['scan']) if code == 512: output_error('There was a error/exception while executing phpcs.')
def check_forbidden_methods(methods, file): for method in methods: try: content = open(file).read().decode('utf-8') except AttributeError: content = open(file, 'r', 1, 'utf-8').read() if method in content: output_error('There is a forbidden method "'+method+'" in the file '+file)
def execute(): output_start('security-checker') composer_lock = get_value('project-dir') + 'composer.lock' print('>>> composer.lock: ' + composer_lock) code = php('security-checker.phar', 'security:check ' + composer_lock) if code != 0: output_error('You have a security issue with your composer.lock')
def execute(): output_start('security-checker') composer_lock = get_value('project-dir')+'composer.lock' print('>>> composer.lock: '+composer_lock) code = php('security-checker.phar', 'security:check '+composer_lock) if code != 0: output_error('You have a security issue with your composer.lock')
def execute(): output_start('phpunit') check_dir = get_value('check-dir') argument = get_test_argument(check_dir) if get_value('phpunit-coverage') == 'true': argument = argument+get_coverage_argument(check_dir) code = php('phpunit', argument) if code != 0: output_error('Some tests failed.')
def execute(): output_start('phpunit') check_dir = get_value('check-dir') argument = get_test_argument(check_dir) if get_value('phpunit-coverage') == 'true': argument = argument + get_coverage_argument(check_dir) code = php('phpunit', argument) if code != 0: output_error('Some tests failed.')
def execute(): output_start('pdepend') metric_dir = get_value('metric-dir') scan_dir = get_value('project-dir')+get_value('scan-dir') excludes = ','.join(get_value('exclude-dirs')) if excludes != '': excludes = '--ignore='+excludes print('>>> Metric dir: '+metric_dir) print('>>> Excludes: '+excludes) code = php('pdepend', '--summary-xml='+metric_dir+'pdepend.xml --overview-pyramid='+metric_dir+'pdepend.svg --jdepend-chart='+metric_dir+'dependencies.svg '+excludes+' '+scan_dir) if code != 0: output_error('There was a error/exception while executing pdepend.')
def execute(): output_start('phpmetrics') metric_dir = get_value('metric-dir') scan_dir = get_value('project-dir')+get_value('scan-dir') excludes = '|'.join(get_value('exclude-dirs')) if excludes != '': excludes = '--excluded-dirs="'+excludes+'"' print('>>> Metric dir: '+metric_dir) print('>>> Excludes: '+excludes) code = php('phpmetrics.phar', '--extensions=php --report-xml='+metric_dir+'phpmetrics.xml --report-html='+metric_dir+'phpmetrics.html '+excludes+' '+scan_dir) if code != 0: output_error('There was a error/exception while executing phpmetrics.')
def execute(): output_start('phploc') metric_dir = get_value('metric-dir') scan_dir = get_value('project-dir')+get_value('scan-dir') exclude_dirs = get_value('exclude-dirs') excludes = '' for exclude in exclude_dirs: excludes = excludes+' --exclude '+exclude print('>>> Metric dir: '+metric_dir) print('>>> Excludes: '+excludes) code = php('phploc', '--count-tests --log-csv '+metric_dir+'phploc.csv --log-xml '+metric_dir+'phploc.xml '+excludes+' '+scan_dir) if code != 0: output_error('There was a error/exception while executing phploc.')
def execute(): output_start('phpmetrics') metric_dir = get_value('metric-dir') scan_dir = get_value('project-dir') + get_value('scan-dir') excludes = '|'.join(get_value('exclude-dirs')) if excludes != '': excludes = '--excluded-dirs="' + excludes + '"' print('>>> Metric dir: ' + metric_dir) print('>>> Excludes: ' + excludes) code = php( 'phpmetrics.phar', '--extensions=php --report-xml=' + metric_dir + 'phpmetrics.xml --report-html=' + metric_dir + 'phpmetrics.html ' + excludes + ' ' + scan_dir) if code != 0: output_error('There was a error/exception while executing phpmetrics.')
def execute(): output_start('pdepend') metric_dir = get_value('metric-dir') scan_dir = get_value('project-dir') + get_value('scan-dir') excludes = ','.join(get_value('exclude-dirs')) if excludes != '': excludes = '--ignore=' + excludes print('>>> Metric dir: ' + metric_dir) print('>>> Excludes: ' + excludes) code = php( 'pdepend', '--summary-xml=' + metric_dir + 'pdepend.xml --overview-pyramid=' + metric_dir + 'pdepend.svg --jdepend-chart=' + metric_dir + 'dependencies.svg ' + excludes + ' ' + scan_dir) if code != 0: output_error('There was a error/exception while executing pdepend.')
def execute(): output_start('lint') dirs = get_dirs() exclude_dirs = get_value('exclude-dirs') forbidden_methods = get_value('forbidden-methods') print('>>> Excludes dirs: ', exclude_dirs) print('>>> Forbidden methods: ', forbidden_methods) for root, dirs, files in os.walk(dirs['scan']): for exclude in exclude_dirs: if exclude in dirs: dirs.remove(exclude) for file in files: if file.endswith(".php"): php_file = os.path.join(root, file) code = os.system(get_value('php')+' -l '+php_file) if code != 0: output_error('PHP lint found an error in the file '+php_file) check_forbidden_methods(forbidden_methods, php_file)
def execute(): output_start('phploc') metric_dir = get_value('metric-dir') scan_dir = get_value('project-dir') + get_value('scan-dir') exclude_dirs = get_value('exclude-dirs') excludes = '' for exclude in exclude_dirs: excludes = excludes + ' --exclude ' + exclude print('>>> Metric dir: ' + metric_dir) print('>>> Excludes: ' + excludes) code = php( 'phploc', '--count-tests --log-csv ' + metric_dir + 'phploc.csv --log-xml ' + metric_dir + 'phploc.xml ' + excludes + ' ' + scan_dir) if code != 0: output_error('There was a error/exception while executing phploc.')
def execute(): output_start('coverfish') phpunit_xml = get_value('project-dir')+get_value('phpunit-xml') phpunit_xml_folder = os.path.dirname(phpunit_xml) root = xml.etree.ElementTree.parse(phpunit_xml).getroot() output_level = get_value('coverfish-output-level') bootstrap = root.get('bootstrap', False) if bootstrap is False: output_error('You have to define the bootstrap attribute in you phpunit.yml in the root node.') autoload = phpunit_xml_folder+'/'+bootstrap for testsuites in root.findall('testsuites'): for testsuite in testsuites: for directory in testsuite: scan_path = phpunit_xml_folder+'/'+directory.text if not os.path.isdir(scan_path): output_error('Only directories are supported in the phpunit.xml in the testsuites.') print('>>> coverfish scan path: '+scan_path) print('>>> coverfish autoload file: '+autoload) code = php('coverfish', 'scan --raw-scan-path='+scan_path+' --raw-autoload-file='+autoload+' --output-level='+output_level+' --no-ansi') if code != 0: output_error('The coverfish command failed with the code '+str(code))
def execute(): output_start('phpmd') dirs = get_dirs() phpmd_xml = dirs['project']+get_value('phpmd-xml') check_dir = get_value('check-dir') excludes = ','.join(get_value('exclude-dirs')) if excludes != '': excludes = '--exclude '+excludes if not os.path.isfile(phpmd_xml): print('>>> No phpmd-xml found. Fallback is the default phpmd.xml:') phpmd_xml = get_value('checker-dir')+'data/phpmd.xml.dist' print('>>> phpmd.xml: '+phpmd_xml) print('>>> Excludes: '+excludes) code = php('phpmd', dirs['scan']+' xml '+phpmd_xml+' --reportfile '+check_dir+'pmd.xml '+excludes) if code == 1: output_error('There was a error/exception while executing phpmd.')
def execute(): output_start('phpmd') dirs = get_dirs() phpmd_xml = dirs['project'] + get_value('phpmd-xml') check_dir = get_value('check-dir') excludes = ','.join(get_value('exclude-dirs')) if excludes != '': excludes = '--exclude ' + excludes if not os.path.isfile(phpmd_xml): print('>>> No phpmd-xml found. Fallback is the default phpmd.xml:') phpmd_xml = get_value('checker-dir') + 'data/phpmd.xml.dist' print('>>> phpmd.xml: ' + phpmd_xml) print('>>> Excludes: ' + excludes) code = php( 'phpmd', dirs['scan'] + ' xml ' + phpmd_xml + ' --reportfile ' + check_dir + 'pmd.xml ' + excludes) if code == 1: output_error('There was a error/exception while executing phpmd.')
def execute(): output_start('coverfish') phpunit_xml = get_value('project-dir') + get_value('phpunit-xml') phpunit_xml_folder = os.path.dirname(phpunit_xml) root = xml.etree.ElementTree.parse(phpunit_xml).getroot() output_level = get_value('coverfish-output-level') bootstrap = root.get('bootstrap', False) if bootstrap is False: output_error( 'You have to define the bootstrap attribute in you phpunit.yml in the root node.' ) autoload = phpunit_xml_folder + '/' + bootstrap for testsuites in root.findall('testsuites'): for testsuite in testsuites: for directory in testsuite: scan_path = phpunit_xml_folder + '/' + directory.text if not os.path.isdir(scan_path): output_error( 'Only directories are supported in the phpunit.xml in the testsuites.' ) print('>>> coverfish scan path: ' + scan_path) print('>>> coverfish autoload file: ' + autoload) code = php( 'coverfish', 'scan --raw-scan-path=' + scan_path + ' --raw-autoload-file=' + autoload + ' --output-level=' + output_level + ' --no-ansi') if code != 0: output_error( 'The coverfish command failed with the code ' + str(code))
def project_installation(): code = php('composer', 'install --optimize-autoloader') if code != 0: output_error('The composer install command for the project failed with the code '+str(code))