DeveloperCAP/MLCAT

View on GitHub

Showing 81 of 109 total issues

Function check_validity has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def check_validity(self, check_unavailable_uid='False', json_headers='headers.json'):
        """

        This function checks for and prints duplicate, missing, and invalid objects in the "headers.json" file.
        This function can be run first to generate a list of duplicate, missing, or invalid objects' UIDs which
Severity: Minor
Found in lib/input/check_headers.py - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function generate_kmeans_clustering has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def generate_kmeans_clustering(mbox_filename, output_filename, author_uid_filename, json_filename, top_n = None):
    """
    From the .MBOX file, this function extracts the email content is extracted using two predefined classes
    available in the Python Standard Library: Mailbox and Message. Feature vectors are created for all the authors
    by obtaining meaningful words from the mail content, after removing the stop words, using NLTK libraries.
Severity: Minor
Found in lib/input/mbox/keyword_clustering.py - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function get_datetime_object has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def get_datetime_object(orig_time):
    """A function to convert a formatted string containing date and time from a local timezone to UTC, by taking into consideration multiple formats of the input parameter and then return the corresponding datetime object.

    :param orig_time: Formatted string containing a date and time from a local timezone
    :return: A datetime object corresponding to the input string in UTC
Severity: Minor
Found in lib/util/read.py - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function get_utc_time has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def get_utc_time(orig_time):
    """
    A function to convert a formatted string containing date and time from a local timezone to UTC, by taking into
    consideration multiple formats of the input parameter
Severity: Minor
Found in lib/util/read.py - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File hypergraph.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
This module is used to model each discussion thread as one hypergraph. All the email header information can be
represented as one hyperedge of a hypergraph. This concise format for representing a discussion thread as a
hypergraph is then stored as a table to a CSV file, with the author column headers containing the ids of the authors.
All the author columns are sorted left to right in the descending order of out degree, followed by in degree. The
Severity: Minor
Found in lib/analysis/thread/hypergraph.py - About 2 hrs to fix

    Function add_to_weighted_graph has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def add_to_weighted_graph(graph_obj, discussion_graph, json_data, nbunch, node_enum=list()):
        """
        Add weighted edges to the DiGraph object recursively.
    
        :param graph_obj: Object for a directed graph with mulitple edges.
    Severity: Minor
    Found in lib/analysis/author/graph/interaction.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function generate_edge_list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_edge_list(nodelist_filename='graph_nodes.csv', edgelist_filename='graph_edges.csv', json_filename='clean_data.json'):
        """
        This function generates a list of nodes and edges in the graphs from the JSON file and saves it as a CSV file.
    
        :param nodelist_filename: csv file to store the graph nodes.
    Severity: Minor
    Found in lib/analysis/thread/graph/edge_list.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function get_lone_author_threads has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_lone_author_threads(save_file=None, nodelist_filename='graph_nodes.csv', edgelist_filename='graph_edges.csv'):
        """
        This function returns the UID of all the nodes that belong to a thread that has only one author
    
        :param save_file: If True, the list of UIDs of nodes are saved to a text file
    Severity: Minor
    Found in lib/util/read.py - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Consider simplifying this complex logical expression.
    Open

            if len(trunc_date) > 30 and trunc_date[14] == ':':
                datetime_obj = datetime.datetime.strptime(trunc_date, "%a, %b %d %H:%M:%S %Y %z")
            elif len(trunc_date) == 25 or len(trunc_date) == 26:
                datetime_obj = datetime.datetime.strptime(trunc_date, "%d %b %Y %H:%M:%S %z")
            elif trunc_date[3] == ',' and (len(trunc_date) == 28 or len(trunc_date) == 29) and '+' not in trunc_date and '-' not in trunc_date:
    Severity: Critical
    Found in lib/util/read.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if len(trunc_date) > 30 and trunc_date[14] == ':':
                  datetime_obj = datetime.datetime.strptime(trunc_date, "%a, %b %d %H:%M:%S %Y %z")
              elif len(trunc_date) == 25 or len(trunc_date) == 26:
                  datetime_obj = datetime.datetime.strptime(trunc_date, "%d %b %Y %H:%M:%S %z")
              elif trunc_date[3] == ',' and (len(trunc_date) == 28 or len(trunc_date) == 29) and '+' not in trunc_date and '-' not in trunc_date:
      Severity: Critical
      Found in lib/util/read.py - About 1 hr to fix

        Function generate_node_labels has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def generate_node_labels(nodelist_filename='graph_nodes.txt', edgelist_filename='graph_edges.txt', json_filename='clean_data.json'):
            """
        
            This function generates a list of nodes and edges in the graphs from the JSON file and saves it as a TXT file.
        
        
        Severity: Minor
        Found in lib/analysis/thread/graph/edge_list.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        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 conversation_refresh_times has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def conversation_refresh_times(headers_filename, nodelist_filename, edgelist_filename, foldername, time_ubound = None, time_lbound = None, plot=False, ignore_lat = False):
          Severity: Major
          Found in lib/analysis/author/time_statistics.py - About 1 hr to fix

            Function add_to_multigraph has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def add_to_multigraph(graph_obj, discussion_graph, json_data, nbunch, label_prefix=''):
                """
                Add multiple edges to the MultiDiGraph object recursively.
            
                :param graph_obj: Object for a directed graph with mulitple edges.
            Severity: Minor
            Found in lib/analysis/author/graph/interaction.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function add_thread_nodes has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def add_thread_nodes(thread_authors, nbunch, parent_id, curr_height, json_data, thread_nodes, conn_subgraph):
            Severity: Major
            Found in lib/analysis/thread/hypergraph.py - About 50 mins to fix

              Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, msg_id=0, height=-1, parent_id=0, time=None, from_addr=None, to_addr=None, cc_addr=None):
              Severity: Major
              Found in lib/analysis/thread/hypergraph.py - About 50 mins to fix

                Function generate_edge_list has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def generate_edge_list(author_nodes, author_edges, graph_nodes,
                Severity: Major
                Found in lib/analysis/author/edge_list.py - About 50 mins to fix

                  Function generate_time_stats_threads has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def generate_time_stats_threads(nodelist_filename, edgelist_filename, clean_headers_filename, foldername, time_lbound=None, time_ubound=None, plot=False):
                  Severity: Major
                  Found in lib/analysis/thread/time_statistics.py - About 50 mins to fix

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

                    def generate_keyword_digest(mbox_filename, output_filename, author_uid_filename, json_filename, top_n = None, console_output=True):
                    Severity: Minor
                    Found in lib/input/mbox/keyword_digest.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if console_output:
                                                  print("\n-----\n")
                                              else:
                                                  out_file.write("\n-----\n")
                              else:
                      Severity: Major
                      Found in lib/input/mbox/keyword_digest.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language