コード例 #1
0
ファイル: static.py プロジェクト: skermes/mvnscripts
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
ファイル: test.py プロジェクト: skermes/mvnscripts
    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')))
コード例 #3
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')))
コード例 #4
0
ファイル: pmd.py プロジェクト: skermes/mvnscripts
            yield srcFile.getAttribute('name'), int(violation.getAttribute('beginline')), text(violation).strip()

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

if __name__ == '__main__':
    import sys

    if not runTarget():
        sys.exit()

    print()
    print()

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

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

    if noFailures:
        print(out.banner(out.green('PMD PASSED')))
コード例 #5
0
ファイル: checkstyle.py プロジェクト: skermes/mvnscripts
                yield srcFile.getAttribute('name'), int(err.getAttribute('line')), err.getAttribute('message')

def runTarget(checkstyleFile='target/checkstyle-result.xml'):
    if os.path.exists(checkstyleFile):
        os.remove(checkstyleFile)
    os.system('mvn checkstyle:checkstyle')
    return os.path.exists(checkstyleFile)

if __name__ == '__main__':
    import sys

    if not runTarget():
        sys.exit()

    print()
    print()

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

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

    if noFailures:
        print(out.banner(out.green('CHECKSTYLE PASSED')))
コード例 #6
0
ファイル: findbugs.py プロジェクト: skermes/mvnscripts
        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')))