Example #1
0
def cc_report(module: str='') -> list:
    """
    radon CC complexity report for module "module"
    
    @param module: name of module to create report, if empty - all modules
    @return list: radon cyclomatic complexity report
    """
    lst = []
    for filename in iter_filenames(['.'], ignore="test,ui,tmp", exclude="*__init__.py"):
        modu_ = Path(filename).stem
        if (not module) | (module == modu_):
            with open(filename) as fobj:
                source = fobj.read()
                lst.extend(in_cc_report(modu_, source))    
    return lst
Example #2
0
def CodeAnalysis(filepatch='.', methodname=''):
    comp = 0
    for filename in iter_filenames([filepatch]):
        print(str(filename))
        with open(filename) as fobj:
            source = fobj.read()

        blocks = cc_visit(source)
        print("Searching for " + methodname + " in " + filepatch)
        for i in blocks:
            print(i.name + ' - ' + str(i.complexity) + ' - ' + methodname)
            if (i.name == methodname):
                comp = i.complexity
                print('FOUND')
                break

    return comp
def methods_complexity_print(file: str, dictionary: OrderedDict) -> NoReturn:
    print('Methods of filename:', file)
    sorted_dict = sort_dict(dictionary)
    print('N | Score | Filename')
    print('--------------------------')
    for n in range(len(sorted_dict)):
        print(n, '  ', sorted_dict[n][0], '   ', sorted_dict[n][1])
    print()


if __name__ == '__main__':
    mi_dict = OrderedDict()
    param_dict = OrderedDict()
    print('1. METHODS OF PROJECT FILES SORTED BY CYCLOMATIC COMPLEXITY')

    for filename in iter_filenames(['.']):
        file_methods = []
        file_complexities = []
        methods_dictionary = OrderedDict()

        with open(filename) as fobj:
            source = fobj.read()

        # get cc blocks
        blocks = cc_visit(source)

        # get MI score
        mi = mi_visit(source, True)
        mi_dict[mi] = filename

        # get raw metrics
Example #4
0
 def _iter_filenames(self):
     '''A wrapper around :func:`~radon.cli.tools.iter_filenames`.'''
     return iter_filenames(self.paths, self.config.exclude,
                           self.config.ignore)
Example #5
0
 def _iter_filenames(self):
     '''A wrapper around :func:`~radon.cli.tools.iter_filenames`.'''
     return iter_filenames(self.paths, self.config.exclude,
                           self.config.ignore)
 def setUp(self):
     self.iter_files = lambda *a, **kw: list(tools.iter_filenames(*a, **kw))
Example #7
0
def iter_files():
    return lambda *a, **kw: list(tools.iter_filenames(*a, **kw))
Example #8
0
 def setUp(self):
     self.iter_files = lambda *a, **kw: list(tools.iter_filenames(*a, **kw))
Example #9
0
def iter_files():
    return lambda *a, **kw: list(tools.iter_filenames(*a, **kw))