DeveloperCAP/MLCAT

View on GitHub

Showing 81 of 109 total issues

Avoid deeply nested control flow statements.
Open

                    if edge[0] in msgs_in_range and edge[1] in msgs_in_range:
                        discussion_graph.add_edge(*edge)
            edge_file.close()
Severity: Major
Found in lib/analysis/thread/time_statistics.py - About 45 mins to fix

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

    def generate_hyperedge_distribution(nodelist_filename, edgelist_filename, clean_headers_filename, foldername, time_limit=None, ignore_lat=False):
    Severity: Minor
    Found in lib/analysis/thread/hypergraph.py - About 45 mins to fix

      Function remove_duplicate_headers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_duplicate_headers(self,to_remove=duplicate_uid, json_headers="headers.json", output_file="headers.json"):
              """
      
              This function removes all the duplicate entries of the UIDs specified in the to_remove parameter. By default,
              it removes all the duplicate entries in the JSON file.
      Severity: Minor
      Found in lib/input/check_headers.py - About 45 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

      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/graph/generate.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not console_output:
                                    out_file.write(author_email + "\n")
                                    author_features = list()
                                    for i in indices:
                                        author_features.append(feature_names[i])
        Severity: Major
        Found in lib/input/mbox/keyword_digest.py - About 45 mins 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 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

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

              def test_generate_rt_curve_fits(mock_figure, mock_plot, mock_legend, mock_ylabel, mock_xlabel, mock_savefig):
              Severity: Minor
              Found in test/integration_test/lib/analysis/author/test_curve_fiting.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not jfile['References'] == "":
                                        # The references are stored as a comma separated string. We have to split it at the ',' to get a list.
                                        if ref_toggle:
                                            ref_list = jfile['References'].split(',')
                                        else:
                Severity: Major
                Found in lib/input/data_cleanup.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

                    Function add_to_weighted_graph has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def add_to_weighted_graph(graph_obj, discussion_graph, json_data, nbunch, node_enum=list()):
                    Severity: Minor
                    Found in lib/analysis/author/graph/interaction.py - About 35 mins to fix

                      Function get has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def get(json_filename, output_filename, active_score, passive_score, write_to_file=True):
                      Severity: Minor
                      Found in lib/analysis/author/ranking.py - About 35 mins to fix

                        Function add_to_multigraph has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def add_to_multigraph(graph_obj, discussion_graph, json_data, nbunch, label_prefix=''):
                        Severity: Minor
                        Found in lib/analysis/author/graph/interaction.py - About 35 mins to fix

                          Function generate_kmeans_clustering has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def generate_kmeans_clustering(mbox_filename, output_filename, author_uid_filename, json_filename, top_n = None):
                          Severity: Minor
                          Found in lib/input/mbox/keyword_clustering.py - About 35 mins to fix

                            Function generate_wh_table_authors has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def generate_wh_table_authors(nodelist_filename, edgelist_filename, output_filename, ignore_lat=False, time_limit=None):
                            Severity: Minor
                            Found in lib/analysis/author/wh_table.py - About 35 mins to fix

                              Function author_interaction has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              def author_interaction(clean_data, graph_nodes, graph_edges, pajek_file, ignore_lat=True):
                              Severity: Minor
                              Found in lib/analysis/author/graph/generate.py - About 35 mins to fix

                                Function replace_invalid_headers has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def replace_invalid_headers(self,to_replace=invalid_uid, json_headers="headers.json", output_file="headers.json", unwanted_uid_filename="unwanted_uid.txt", uid_map_filename="thread_uid_map.json"):
                                Severity: Minor
                                Found in lib/input/check_headers.py - About 35 mins to fix

                                  Function generate_wh_table_threads has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  def generate_wh_table_threads(nodelist_filename, edgelist_filename, output_filename, ignore_lat=False, time_limit=None):
                                  Severity: Minor
                                  Found in lib/analysis/thread/wh_table.py - About 35 mins to fix

                                    Function weighted_multigraph has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    def weighted_multigraph(graph_nodes, graph_edges, clean_data, output_dir, ignore_lat = False):
                                    Severity: Minor
                                    Found in lib/analysis/author/graph/interaction.py - About 35 mins to fix

                                      Function write_uid_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def write_uid_map(self,from_index=1, to_index=last_uid_read, uid_map_filename="thread_uid_map.json"):
                                              """
                                          
                                              To ensure that references are correctly recorded in the JSON file such that there are no references to mails that
                                              do not exist and to ease the processing of headers, a map with the string in the Message-Id field of the header to
                                      Severity: Minor
                                      Found in lib/input/check_headers.py - About 35 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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language