DeveloperCAP/MLCAT

View on GitHub
lib/analysis/author/community.py

Summary

Maintainability
D
3 days
Test Coverage

Showing 9 of 9 total issues

Function vertex_clustering has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
Open

def vertex_clustering(json_filename, nodelist_filename, edgelist_filename, foldername, time_limit=None, ignore_lat=False):
"""
This function performs vertex clustering on the dataset passed in the parameters and saves the dendrogram resulting
from the vertex clustering as a PDF along with the visualization of the vertex cluster itself. It is recommended to
limit these graphs to 200 authors as the visualization becomes incompehensible beyond that.
Severity: Minor
Found in lib/analysis/author/community.py - About 1 day to fix

Function vertex_clustering has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def vertex_clustering(json_filename, nodelist_filename, edgelist_filename, foldername, time_limit=None, ignore_lat=False):
"""
This function performs vertex clustering on the dataset passed in the parameters and saves the dendrogram resulting
from the vertex clustering as a PDF along with the visualization of the vertex cluster itself. It is recommended to
limit these graphs to 200 authors as the visualization becomes incompehensible beyond that.
Severity: Minor
Found in lib/analysis/author/community.py - About 1 hr to fix

    Function vertex_clustering has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def vertex_clustering(json_filename, nodelist_filename, edgelist_filename, foldername, time_limit=None, ignore_lat=False):
    Severity: Minor
    Found in lib/analysis/author/community.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

      if author_graph[node['From'], to_addr] == 0:
      author_graph.add_edge(node['From'], to_addr, weight=1)
      else:
      author_graph[node['From'], to_addr] += 1
       
       
      Severity: Major
      Found in lib/analysis/author/community.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

        if to_addr not in author_map:
        author_map[to_addr] = index
        author_graph.add_vertex(name=to_addr, label=to_addr)
        index += 1
        if author_graph[node['From'], to_addr] == 0:
        Severity: Major
        Found in lib/analysis/author/community.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

          if to_addr not in author_map:
          author_map[to_addr] = index
          author_graph.add_vertex(name=to_addr, label=to_addr)
          index += 1
          if author_graph[node['From'], to_addr] == 0:
          Severity: Major
          Found in lib/analysis/author/community.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

            if json_obj['Time'] < time_limit:
            # print("\nFrom", json_obj['From'], "\nTo", json_obj['To'], "\nCc", json_obj['Cc'])
            from_addr = email_re.search(json_obj['From'])
            json_obj['From'] = from_addr.group(0) if from_addr is not None else json_obj['From']
            json_obj['To'] = set(email_re.findall(json_obj['To']))
            Severity: Major
            Found in lib/analysis/author/community.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

              if author_graph[node['From'], to_addr] == 0:
              author_graph.add_edge(node['From'], to_addr, weight=1)
              else:
              author_graph[node['From'], to_addr] += 1
              if node['Cc'] is None:
              Severity: Major
              Found in lib/analysis/author/community.py - About 45 mins to fix

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                for i in range(1, num_vertices+1):
                line = lines_in_file[i].split()
                line[1] = "\"" + line[1] + "\""
                del line[2:]
                line.append("\n")
                Severity: Major
                Found in lib/analysis/author/community.py and 1 other location - About 5 hrs to fix
                lib/analysis/author/graph/generate.py on lines 26..31

                There are no issues that match your filters.

                Category
                Status