示例#1
0
import pmd
import cpd
import out

import itertools
import os.path

if __name__ == '__main__':
    import sys

    bugFound, styleChecked, pmdRan, dupChecked = findbugs.runTarget(), checkstyle.runTarget(), \
                                                 pmd.runTarget(), cpd.runTarget()
    out.printlns('', '')

    if not bugFound:
        print(out.banner(out.red('FIND BUGS TARGET FAILED')))

    if not styleChecked:
        print(out.banner(out.red('CHECK STYLE TARGET FAILED')))

    if not pmdRan:
        print(out.banner(out.red('PMD TARGET FAILED')))

    if not dupChecked:
        print(out.banner(out.red('CODE DUPLICATION TARGET FAILED')))

    if not any([bugFound, styleChecked, pmdRan, dupChecked]):
        sys.exit()

    problems = itertools.chain(findbugs.bugsFound() if bugFound else [],
                               checkstyle.checkstyleProblems() if styleChecked else [],
示例#2
0
文件: cpd.py 项目: skermes/mvnscripts
        yield fileone.getAttribute('path'), int(fileone.getAttribute('line')), dupmsg(duplication, fileone, filetwo)

def runTarget(cpdFile='target/site/cpd.xml'):
    if os.path.exists(cpdFile):
        os.remove(cpdFile)
    os.system('mvn pmd:cpd')
    return os.path.exists(cpdFile)

if __name__ == '__main__':
    import sys

    if not runTarget():
        sys.exit()

    print()
    print()

    lastFile = ''
    noDups = True
    for srcFile, line, message in duplications():
        if (srcFile != lastFile):
            out.printlns('', os.path.relpath(srcFile), '-' * 79)
            lastFile = srcFile

        line = str(line)
        print(out.red(line), '-', message)
        noDups = False

    if noDups:
        print(out.banner(out.green('NO DUPLICATE CODE')))
示例#3
0
    if os.path.exists(reportDirectory):
        shutil.rmtree(reportDirectory)
    os.system(target)
    if not os.path.exists(reportDirectory):
        sys.exit()

    print()
    print()

    lastFixture = ''
    noFailures = True
    putNewlineBefore = False
    for test, fixture, problem, cause in failedTests(reportDirectory):
        if fixture != lastFixture:
            out.printlns('', fixture, '-' * 79)
            lastFixture = fixture
            putNewlineBefore = False

        if problem == FAILED:
            if putNewlineBefore:
                print()
            out.printlns(out.red(test), cause, '')
            noFailures = False;
            putNewlineBefore = False
        elif problem == SKIPPED:
            print(out.yellow(test))
            putNewlineBefore = True

    if noFailures:
        out.printlns('', out.banner(out.green('ALL TESTS SUCCESSFUL')))
示例#4
0
        yield os.path.join(srcdir, fileName(bug)), int(lineNumber(bug)), message(bug)

def runTarget(findbugsFile='target/findbugsXml.xml'):
    if os.path.exists(findbugsFile):
        os.remove(findbugsFile)
    os.system('mvn findbugs:findbugs')
    return os.path.exists(findbugsFile)

if __name__ == '__main__':
    import sys

    if not runTarget():
        sys.exit()

    print()
    print()

    lastFile = ''
    noFailures = True
    for srcFile, line, msg in bugsFound():
        if srcFile != lastFile:
            out.printlns('', os.path.relpath(srcFile), '-' * 79)
            lastFile = srcFile

        line = str(line)
        print(out.red(line), '-', msg)
        noFailures = False

    if noFailures:
        print(out.banner(out.green('FIND BUGS PASSED')))