Esempio n. 1
0
def composer(arguments):
    base_dir = os.getcwd()
    os.chdir(get_value('checker-dir'))

    php('composer', arguments)

    os.chdir(base_dir)
Esempio n. 2
0
def execute():
    output_start('phpcpd')

    dirs = get_dirs()
    check_dir = get_value('check-dir')
    exclude_dirs = get_value('exclude-dirs')
    excludes = ''

    for exclude in exclude_dirs:
        excludes = excludes+' --exclude '+exclude

    print('>>> Excludes: '+excludes)

    php('phpcpd', excludes+' --log-pmd '+check_dir+'pmd-cpd.xml '+dirs['scan'])
Esempio n. 3
0
def execute():
    output_start('phpcpd')

    dirs = get_dirs()
    check_dir = get_value('check-dir')
    exclude_dirs = get_value('exclude-dirs')
    excludes = ''

    for exclude in exclude_dirs:
        excludes = excludes + ' --exclude ' + exclude

    print('>>> Excludes: ' + excludes)

    php('phpcpd',
        excludes + ' --log-pmd ' + check_dir + 'pmd-cpd.xml ' + dirs['scan'])
Esempio n. 4
0
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))
Esempio n. 5
0
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.')
Esempio n. 6
0
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.')
Esempio n. 7
0
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')
Esempio n. 9
0
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.')
Esempio n. 10
0
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.')
Esempio n. 11
0
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.')
Esempio n. 12
0
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.')
Esempio n. 13
0
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.')
Esempio n. 14
0
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.')
Esempio n. 15
0
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.')
Esempio n. 16
0
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.')
Esempio n. 17
0
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.')
Esempio n. 18
0
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))
Esempio n. 19
0
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.')
Esempio n. 20
0
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))