# Path: SmellDetector/FileOperations.py
# def countPuppetFiles(folder):
# 
# Path: SmellDetector/Utilities.py
# def myPrint(msg):
# def reportSmell(outputFile, fileName, smellName, reason):
# def intersection(list1, list2):
# def summation(list1, list2):


import os
import Graph.GR_Constants as GRCONSTS
import Graph.Graph
import Graph.GraphNode
import Graph.Resource
import SmellDetector.Constants as CONSTS
import SourceModel.SM_File
from SmellDetector import FileOperations, Utilities
        if aClass.getLocWithoutComments() > CONSTS.MAX_CLASS_LOC_THRESHOLD:
            Utilities.reportSmell(outputFile, fileObj.fileName, CONSTS.SMELL_INS_MOD_2, CONSTS.CLASS_RES)

    for aDefine in fileObj.getOuterDefineList():
        if aDefine.getLocWithoutComments() > CONSTS.MAX_DEFINE_LOC_THRESHOLD:
            Utilities.reportSmell(outputFile, fileObj.fileName, CONSTS.SMELL_INS_MOD_2, CONSTS.DEFINE_RES)

    if fileObj.getLinesOfCodeWithoutComments() > CONSTS.MAX_MODULE_LOC_THRESHOLD:
            Utilities.reportSmell(outputFile, fileObj.fileName, CONSTS.SMELL_INS_MOD_2, CONSTS.FILE_RES)

#Form 3 - When the complexity (max nesting depth) of a module is greater than a threshold
def detectInsufficientModForm3(folder, outputFile):
    for root, dirs, files in os.walk(folder):
        for file in files:
            if file.endswith(".pp") and not os.path.islink(os.path.join(root, file)):
                fileObj = SourceModel.SM_File.SM_File(os.path.join(root, file))
                detectInsModForm3(fileObj, outputFile)

def detectInsModForm3(fileobj, outputFile):
    if fileobj.getMaxNestingDepth() > CONSTS.MAX_NESTING_DEPTH:
        Utilities.reportSmell(outputFile, fileobj.fileName, CONSTS.SMELL_INS_MOD_3, CONSTS.FILE_RES)

#Form 1 - size of the upper-level manifests folder when modules folder is absent, or both modules and manifests folder not present
def detectUnstructuredModForm1(folder, outputFile):
    if isModulesExists(folder):
        return
    manifestsFolder = getManifestsFolder(folder) #repo-level manifests folder
    if manifestsFolder == "":
        Utilities.reportSmell(outputFile, manifestsFolder, CONSTS.SMELL_UNS_MOD_1, CONSTS.REPO_MANIFEST)
        return

# Path: SmellDetector/FileOperations.py
# def countPuppetFiles(folder):
# 
# Path: SmellDetector/Utilities.py
# def myPrint(msg):
# def reportSmell(outputFile, fileName, smellName, reason):
# def intersection(list1, list2):
# def summation(list1, list2):


# Path: SmellDetector/ModSmellDectector.py
import os
import Graph.GR_Constants as GRCONSTS
import Graph.Graph
import Graph.GraphNode
import Graph.Resource
import SmellDetector.Constants as CONSTS
import SourceModel.SM_File
from SmellDetector import FileOperations, Utilities

        if aClass.getLocWithoutComments() > CONSTS.MAX_CLASS_LOC_THRESHOLD:
            Utilities.reportSmell(outputFile, fileObj.fileName, CONSTS.SMELL_INS_MOD_2, CONSTS.CLASS_RES)

    for aDefine in fileObj.getOuterDefineList():
        if aDefine.getLocWithoutComments() > CONSTS.MAX_DEFINE_LOC_THRESHOLD:
            Utilities.reportSmell(outputFile, fileObj.fileName, CONSTS.SMELL_INS_MOD_2, CONSTS.DEFINE_RES)

    if fileObj.getLinesOfCodeWithoutComments() > CONSTS.MAX_MODULE_LOC_THRESHOLD:
            Utilities.reportSmell(outputFile, fileObj.fileName, CONSTS.SMELL_INS_MOD_2, CONSTS.FILE_RES)

#Form 3 - When the complexity (max nesting depth) of a module is greater than a threshold
def detectInsufficientModForm3(folder, outputFile):
    for root, dirs, files in os.walk(folder):
        for file in files:
            if file.endswith(".pp") and not os.path.islink(os.path.join(root, file)):
                fileObj = SourceModel.SM_File.SM_File(os.path.join(root, file))
                detectInsModForm3(fileObj, outputFile)

def detectInsModForm3(fileobj, outputFile):
    if fileobj.getMaxNestingDepth() > CONSTS.MAX_NESTING_DEPTH:
        Utilities.reportSmell(outputFile, fileobj.fileName, CONSTS.SMELL_INS_MOD_3, CONSTS.FILE_RES)

#Form 1 - size of the upper-level manifests folder when modules folder is absent, or both modules and manifests folder not present
def detectUnstructuredModForm1(folder, outputFile):
    if isModulesExists(folder):
        return
    manifestsFolder = getManifestsFolder(folder) #repo-level manifests folder
    if manifestsFolder == "":
        Utilities.reportSmell(outputFile, manifestsFolder, CONSTS.SMELL_UNS_MOD_1, CONSTS.REPO_MANIFEST)
        return

    if FileOperations.countPuppetFiles(manifestsFolder) > CONSTS.MAX_MANIFESTS_PUPPET_FILES: