Beispiel #1
0
def createSubpage(f):
    text = md.h2("Overview")
    text += createWizardDonut(f["name"] + " - Overview", f["success"],
                              f["fail"])
    for testName in f["tests"]:
        text += md.h2("Test Result - " + testName)
        text += "\n"
        text += "~~~~~{.txt}\n"
        text += f["tests"][testName]
        text += "~~~~~\n\n"
    md.createPage(f["title"], f["title"], text)
Beispiel #2
0
def createSubpage(f, subpage):
    log, error, warning, success = parseResults(f)
    text = md.h2(subpage)

    text += createDetailDonut(subpage, error, warning, success)

    text += md.h2("Complete Log")
    text += "\n"
    text += "~~~~~{.txt}"
    text += log
    text += "~~~~~"

    md.createPage(subpage, subpage, text)
    return error, warning, success
Beispiel #3
0
def ooSummary(data):
    text = md.h2("Object Oriented Design Summary")
    tableData = [["module", "WMC", "DIT", "NOC", "CBD"]]
    for module in data:
        tableData.append([module[value] for value in ooFeatures])
    text += md.table(tableData)
    return text
Beispiel #4
0
def proceduralSummary(data):
    text = md.h2("Procedural Summary")
    tableData = [["module", "LOC", "COM", "MVG", "LC", "MC"]]
    for module in data:
        tableData.append([module[value] for value in proceduralFeatures])
    text += md.table(tableData)
    return text
Beispiel #5
0
def createCCCCSubpage(xml):
    projectSummaryData = parseProjectSummary(xml)
    proceduralSummaryData = parseProceduralSummary(xml)
    ooSummaryData = parseOOSummary(xml)
    structuralSummaryData = parseStructuralSummary(xml)

    text = md.h2("Explanations")
    text += """
> The following code metrics are reported:
>
> * NOM **number of modules** - the number of non-trivial modules identified by the analyzer
> * LOC **lines of code** - the number of non-blank, non-comment lines of code
> * COM **lines of comments** - the number of lines of comment
> * MVG **McCabe's cyclomatic complexibility number** [wikipedia](https://de.wikipedia.org/wiki/McCabe-Metrik)
> * LC **lines of code per lines of comment**
> * MC **McCabe's cyclomatic complexibility per lines of comment**
> * REJ **rejected lines of code** which the analyzer refused to process
> * WMC **weighted methods per class** weight=1, represents the number of methods per class
> * DIT **depth of inheritance tree** length of longest path of inheritance ending in this module
> * NOC **number of children** number of children which inherit directly from this module
> * CBD **coupling between objects** number of modules which are coupled directly to this module (either client or supplier)
> * FI **fan-in** number of modules passing information into this module
> * FO **fan-out** number of modules into which this module passes information
>
> For more details, please refer to the CCCC documentation (and output HTML files)
"""
    text += projectSummary(projectSummaryData, False)

    text += proceduralSummary(proceduralSummaryData)
    text += ooSummary(ooSummaryData)
    text += structuralSummary(structuralSummaryData)

    md.createPage("Code Metrics", "ccccreport", text)
    return projectSummaryData
Beispiel #6
0
def structuralSummary(data):
    text = md.h2("Structural Summary")
    tableData = [["module", "FI", "FO"]]
    for module in data:
        tableData.append([module[value] for value in structuralFeatures])
    text += md.table(tableData)
    return text
Beispiel #7
0
def main(coverage):
    text = ""
    subpages = []
    lhit_global, ltot_global = 0, 0

    overallData = [["project", "lines", "functions", "branches"]]
    for project in coverage:
        title = "Test Results - Coverage - " + project
        subsubpages, subresult = createSubpage(project, title)
        lhit, ltot, fhit, ftot, bhit, btot = getCoverage(subresult)
        lhit_global += lhit
        ltot_global += ltot
        overallData += [[
            md.ilink(project, title),
            formatPercent(lhit, ltot),
            formatPercent(fhit, ftot),
            formatPercent(bhit, btot)
        ]]
        subpages += [md.slink(title)]
        subpages += subsubpages

    text += md.h2("Test Report - Coverage Analysis")
    text += createCoverageDonut(project + " - lines", lhit_global, ltot_global)
    text += md.table(overallData)
    return text, subpages
Beispiel #8
0
def main(wizardFiles):
    title = "Test Report - Wizard"
    overviewData = [["flag", "feature", "success", "failures"]]
    subpages = []
    success = 0
    fail = 0
    for filename in wizardFiles:
        with open(filename, "r") as f:
            featureStates = parseFeatures(
                f
            )  # [ { name, success, fail, tests : { testname: testtext, ... } }, ... ]
            for f in featureStates:
                f["title"] = "{} - {}".format(title, f["name"])
                createSubpage(f)
                success += f["success"]
                fail += f["fail"]
                overviewData += [[
                    md.gr(f["fail"]),
                    md.ilink(f["name"], f["title"]), f["success"], f["fail"]
                ]]
                subpages += [md.slink(f["title"])]

    text = md.h2(title)
    text += createWizardDonut(title + " - Overview", success, fail)
    text += md.table(overviewData)
    return text, subpages
Beispiel #9
0
def createSubpage(project, title):
    text = ""
    subpages = []

    results, total = importCoverage(project)
    lhit, ltot, fhit, ftot, bhit, btot = getCoverage(total)

    projectData = [["folder", "lines", "functions", "branches"]]
    projectData += [[
        folder,
        folderSum(results[folder], "L"),
        folderSum(results[folder], "FN"),
        folderSum(results[folder], "BR")
    ] for folder in results]

    text += md.h2("Overview")
    text += createCoverageDonut("lines", lhit, ltot)
    text += createCoverageDonut("functions", fhit, ftot)
    text += createCoverageDonut("branches", bhit, btot)
    text += md.table(projectData)

    for folder in results:
        resultFolder = results[folder]
        sourceData = [["file", "lines", "functions", "branches"]]
        for f in resultFolder:
            lhit, ltot, fhit, ftot, bhit, btot = getCoverage(resultFolder[f])
            sourceData += [[
                md.ilink(f, "Coverage of " + f),
                formatPercent(lhit, ltot),
                formatPercent(fhit, ftot),
                formatPercent(bhit, btot)
            ]]
        text += md.h2(folder)
        text += md.table(sourceData)

        for f in resultFolder:
            createCoverageSourceFile_pureMD("Coverage of " + f,
                                            resultFolder[f])
            subpages.append(md.slink("Coverage of " + f))

    md.createPage(title, title, text)
    return subpages, total
Beispiel #10
0
def projectSummary(data, explanation=True):
    text = md.h2("Code Metrics - CCCC - Project Summary")
    text += "> code counters / metrics calculated using CCCC\n"
    if explanation:
        text += "> for explanations, please refer to the detailed report on the "
        text += md.ilink("CCCC report", "ccccreport")
        text += " subpage\n\n"
    tableData = [["metric", "value"]]
    for feature in projectSummaryFeatures:
        tableData.append([feature.replace("_", " "), data[feature]])
    text += md.table(tableData)
    return text
Beispiel #11
0
def runModule( module, moduleArgs, text, subpages ):
    if moduleArgs:
        try:
          moduleText, moduleSubPages = module.main( moduleArgs )
          text += moduleText
          subpages += moduleSubPages
        except Exception as e:
          text += md.h2( "{} - Exception Occoured".format( module.__name__ ))
          text += "\n\n~~~~~\n"
          text += traceback.format_exc()
          text += "\n~~~~~\n"
          traceback.print_exc()
    return text, subpages
Beispiel #12
0
def main(filenames):
    data = [["flag", "component", "success", "warning", "errors"]]
    subpages = []

    errors = 0
    total = 0
    for f in filenames:
        with open(f, "r") as securityFile:
            f = f.replace(".", "_")
            subpage = "Security Result - {}".format(f)
            error, warning, success = createSubpage(securityFile, subpage)
            errors += 1 if error + warning > 0 else 0
            total += 1

            data.append([
                md.gr(error),
                md.ilink(subpage, subpage), success, warning, error
            ])
            subpages.append(slink(subpage))

    result = md.h2("Security Checks")
    result += createOverviewDonut("Modules", errors, total)
    result += md.table(data)
    return result, subpages