almlab/angst

View on GitHub

Showing 70 of 94 total issues

Avoid deeply nested control flow statements.
Open

                    for event in event0:
                        if 'los' in event:
                            los_parts = event.split(': ')
                            los_node = los_parts[1].replace('*','')
                            los_list.append(los_node)
Severity: Major
Found in angst_lib/reconcile.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for hgt in hgt_list:
                            raw_hgt = hgt.split('-')
                            for hgt_part in raw_hgt:
                                if hgt_part in raw_los_list:
                                    raw_los_list.remove(hgt_part)
    Severity: Major
    Found in angst_lib/reconcile.py - About 45 mins to fix

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

          def subtreeMap(self,species_node):
      
          # do the children of the current species node possess the
          # relevant genes?  if so, follow that child.  if not, return
          # the current node
      Severity: Minor
      Found in tree_lib/node.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 sscore < node_link.max_float:
                              # since python is insane, i can't directly
                              # remove things from this list.  instead, i'll
                              # just add them to a new list
                              orig_los_count = 0
      Severity: Major
      Found in angst_lib/reconcile.py - About 45 mins to fix

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

        def GetPaths(root_node,this_node,root_lca,this_lca,path_dict,output_f):
        Severity: Minor
        Found in angst_lib/output.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if found is True:
                                      was_found = found
                                      found_dist = new_dist
          
          
          Severity: Major
          Found in tree_lib/node.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if num_dups < 1 and num_loss < 1:
                                    event0.extend(["[spc]: " + str(lcas_lca.species)])
                                # solicit input from event guide
                                if event_guide is not None:
            Severity: Major
            Found in angst_lib/reconcile.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if node_link.best_score > sscore:
                                      res['newick'] = MakeNewick(res,node_link,frac)
                                      node_link.best_score = sscore
                                      node_link.best_res = res
              
              
              Severity: Major
              Found in angst_lib/reconcile.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if num_dups > 0:
                                        dist_ratios.append('yes dup')
                                    else:
                                        dist_ratios.append('yes spc')
                
                
                Severity: Major
                Found in angst_lib/reconcile.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for los in los_list:
                                          raw_los_list.extend(los.split('-'))
                                      for hgt in hgt_list:
                  Severity: Major
                  Found in angst_lib/reconcile.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if event_guide is not None:
                                            sscore -= EventGuideAdjust(event0,event_guide,model)
                    
                    
                    Severity: Major
                    Found in angst_lib/reconcile.py - About 45 mins to fix

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

                      def TryDL(parent1,parent2,node1,node2,node_link,lca_tables):
                      Severity: Minor
                      Found in angst_lib/reconcile.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if event_guide is not None:
                                                print "can't do both HR and event guiding!"
                                                sys.exit(1)
                        
                                            # are there any losses proposed?
                        Severity: Major
                        Found in angst_lib/reconcile.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for los in hgt_list:
                                                  matched = False
                                                  for ind in range(len(los_list)):
                                                      this_los = "-" + los + "-"
                                                      if this_los in los_list[ind]:
                          Severity: Major
                          Found in angst_lib/reconcile.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if sscore > node_link.best_score:
                                                    break
                                            else:
                            Severity: Major
                            Found in angst_lib/reconcile.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  for ind in range(len(los_list)):
                                                      los_list[ind] = "-" + los_list[ind] + "-"
                                                  los_list.sort(lambda a,b:len(a)-len(b))
                              Severity: Major
                              Found in angst_lib/reconcile.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if parent is None:
                                                        upper_height = lower_height + 1.0
                                                    else:
                                                        upper_height = ultra_tree.height_dict[tree_link[parent]]
                                                    #endif
                                Severity: Major
                                Found in angst_lib/reconcile.py - About 45 mins to fix

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

                                  def SaveResults(output_args):
                                    ''' write the results of AnGSTs analysis to file '''
                                  
                                    model = output_args["model"]
                                    results_dirs = output_args["results"]
                                  Severity: Minor
                                  Found in angst_lib/output.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 child_branch is not kid_branch:
                                                  node.child_branches.append(child_branch)
                                                  node.imposeHierarchy()
                                  
                                      # recursively label the roots of subtrees w/ the leaves contained
                                  Severity: Major
                                  Found in tree_lib/node.py - About 45 mins to fix

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

                                    def GetBranchDists(this_node,this_lca,parent_lca,path_dict,output_f):
                                    Severity: Minor
                                    Found in angst_lib/output.py - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language