Пример #1
0
    def test_detectComplexExpr(self):
        fileName = "/Users/Tushar/Documents/Research/PuppetQuality/Repos/cmits/cmits-example/modules-unclass/user/manifests/valid.pp"
        #fileName = "/Users/Tushar/Documents/Research/PuppetQuality/Repos/percona-xtradb-cluster-tutorial/manifests/master_slave.pp"
        outFileName = "test1/DefEncTest.txt"

        outFile = open(outFileName, 'w')
        Analyzer.detectComplexExpr(fileName, outFile)
        outFile.close()
        outFileRead = open(outFileName, 'r')
        self.assertGreater(len(outFileRead.read()), 0)
Пример #2
0
    def test_detectComplexExpr(self):
        fileName = "/Users/Tushar/Documents/Research/PuppetQuality/Repos/cmits/cmits-example/modules-unclass/user/manifests/valid.pp"
        #fileName = "/Users/Tushar/Documents/Research/PuppetQuality/Repos/percona-xtradb-cluster-tutorial/manifests/master_slave.pp"
        outFileName = "test1/DefEncTest.txt"

        outFile = open(outFileName, 'w')
        Analyzer.detectComplexExpr(fileName, outFile)
        outFile.close()
        outFileRead = open(outFileName, 'r')
        self.assertGreater(len(outFileRead.read()), 0)
Пример #3
0
import os

import Aggregator
from SmellDetector import Constants as CONSTS, Analyzer

root = CONSTS.REPO_ROOT
print("Initiating Analyzer...")
totalRepos = len(os.listdir(root))
currentItem = 0
for item in os.listdir(root):
    currentFolder = os.path.join(root, item)
    #print("Anlyzing: " + currentFolder)
    if not os.path.isfile(currentFolder):
        Analyzer.analyze(currentFolder, item)
    currentItem += 1
    print (str("{:.2f}".format(float(currentItem * 100)/float(totalRepos))) + "% analysis done.")
print("Analyzer - Done.")

print("Initiating metrics and smells aggregator...")
aggregatedFile = open(root + "/" + CONSTS.AGGREGATOR_FILE, 'wt')
aggregatedFile.write(CONSTS.CSV_HEADER)
for item in os.listdir(root):
    currentFolder = os.path.join(root, item)
    if not os.path.isfile(currentFolder):
        Aggregator.aggregate(currentFolder, item, aggregatedFile)
aggregatedFile.close()
print("Metrics and smells aggregator - Done.")
Пример #4
0
"""

import os
from SmellDetector import Analyzer, Utilities
currentItem = 0
folderOfPuppetRepos = "/Users/akond/Documents/AkondOneDrive/OneDrive/Fall16-ThesisTopic/puppet_repos/"
headerStr1 = "Filename, max_nest_depth, class_dec, def_dec, pack_dec, file_dec, serv_dec, exec_dec, cohe_meth, body_txt_size,"
headerStr2 = "lines_w_comm, lines_wo_comm, outerelems, file_reso, service_reso, package_reso, hard_coded_stmt, node_decl, parent_class,"
headerStr = headerStr1 + headerStr2

print "Started at: ", Utilities.giveTimeStamp()
totalRepos = len(os.listdir(folderOfPuppetRepos))
for item in os.listdir(folderOfPuppetRepos):
    currentFolder = os.path.join(folderOfPuppetRepos, item)
    print "---------------------------------------"
    print "Analyzing: ", currentFolder
    if not os.path.isfile(currentFolder):
        fileToSave = currentFolder + "/all.file.metrics.csv"
        file_level_output = Analyzer.hackFileLevelDetails(currentFolder, item)
        # append contetn with header
        fullStr = headerStr + "\n" + file_level_output
        #print file_level_output
        dump_status = Utilities.dumpStrToFile(fileToSave, fullStr)
        print "Dumped a file of {} bytes ...".format(dump_status)
    currentItem += 1
    stausStr = str("{:.2f}".format(
        float(currentItem * 100) / float(totalRepos))) + "% analysis completed"
    print stausStr
    print "---------------------------------------"
print "Done with metric extraction!"
print "Ended at: ", Utilities.giveTimeStamp()
Пример #5
0
import os

import Aggregator
from SmellDetector import Constants as CONSTS, Analyzer

root = CONSTS.REPO_ROOT
print("Initiating Analyzer...")
totalRepos = len(os.listdir(root))
currentItem = 0
for item in os.listdir(root):
    currentFolder = os.path.join(root, item)
    #print("Anlyzing: " + currentFolder)
    if not os.path.isfile(currentFolder):
        Analyzer.analyze(currentFolder, item)
    currentItem += 1
    print(
        str("{:.2f}".format(float(currentItem * 100) / float(totalRepos))) +
        "% analysis done.")
print("Analyzer - Done.")

print("Initiating metrics and smells aggregator...")
aggregatedFile = open(root + "/" + CONSTS.AGGREGATOR_FILE, 'wt')
aggregatedFile.write(CONSTS.CSV_HEADER)
for item in os.listdir(root):
    currentFolder = os.path.join(root, item)
    if not os.path.isfile(currentFolder):
        Aggregator.aggregate(currentFolder, item, aggregatedFile)
aggregatedFile.close()
print("Metrics and smells aggregator - Done.")
Пример #6
0
            ]
            writer = csv.DictWriter(outputfile, fieldnames=csv_columns)
            writer.writeheader()

            for subdirs in os.listdir(projectFolder):
                #print(">>> subdirs: ", subdirs)
                if (subdirs != ".DS_Store") and (
                        subdirs != "AggregatedOutput.csv") and (
                            subdirs != "Puppeteer_output.txt"):
                    files = os.path.join(projectFolder, subdirs)

                    for item in os.listdir(files):
                        currentFile = os.path.join(files, item)
                        print("Analyzing: " + currentFile)
                        if os.path.isfile(currentFile):
                            resultsMetrics, CONSTS.smellsResults = Analyzer.analyze(
                                projectFolder, currentFile)

                            results = {}
                            results["ecosystem"] = ecosystem
                            results["project"] = project_name
                            results["file"] = item
                            results["commit"] = subdirs
                            results["puppetFileCount"] = resultsMetrics[
                                currentFile][0]
                            results["totalClasses"] = resultsMetrics[
                                currentFile][1]
                            results["totalDefines"] = resultsMetrics[
                                currentFile][2]
                            results["totalFiles"] = resultsMetrics[
                                currentFile][3]
                            results["totalPackages"] = resultsMetrics[