almlab/angst

View on GitHub

Showing 94 of 94 total issues

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

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

          def TreeLink(self,other_tree):
              ''' code to link the nodes of two trees whose newick ordering
              of nodes may be different, but whose overall topology is
              identical. '''
      
      
      Severity: Minor
      Found in tree_lib/multitree.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

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

          def GetHeights(self):
              ''' get MEDIAN distance to leaves at all internal nodes on the
              tree '''
      
              # get distances from leaves
      Severity: Minor
      Found in tree_lib/node.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

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

          def MergeNodeLinkDicts(self,other_dict):
              '''merge lists of linked nodes'''
      
              for leaves in other_dict:
                  if leaves in self.link_dict:
      Severity: Minor
      Found in angst_lib/reconcile.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

      Identical blocks of code found in 2 locations. Consider refactoring.
      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: Minor
      Found in angst_lib/reconcile.py and 1 other location - About 30 mins to fix
      angst_lib/reconcile.py on lines 847..850

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                  if sscore < node_link.best_score:
                      res['newick'] = MakeNewick(res,node_link,frac)
                      node_link.best_score = sscore
                      node_link.best_res = res
      Severity: Minor
      Found in angst_lib/reconcile.py and 1 other location - About 30 mins to fix
      angst_lib/reconcile.py on lines 523..526

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 32.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function Find_Subnodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def Find_Subnodes(self):
      
              for kid_nodes in self.kid_nodes.keys():
                  new_dict = kid_nodes.Find_Subnodes()
                  for k in new_dict.keys():
      Severity: Minor
      Found in tree_lib/node.py - About 25 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 ValidTransfer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def ValidTransfer(self,other_node):
              ''' return boolean regarding whether or not the parent
              branches of the queried nodes overlap temporally '''
      
              # no auto-transfer
      Severity: Minor
      Found in tree_lib/node.py - About 25 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 findBranches has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def findBranches(self,all_branches):
      
          all_branches.append(self)
          self.visited = True
      
      
      Severity: Minor
      Found in tree_lib/branch.py - About 25 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 FindDists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def FindDists(self):
              ''' recursively enumerate all pairwise distances on the
              species tree '''
      
              dist_dict = self.tree.dist_dict
      Severity: Minor
      Found in tree_lib/node.py - About 25 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 FindLCA has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def FindLCA(self,node1,node2):
              ''' find the last common ancestor of two nodes.  will descend
              from the subroot (self) looking to see which children possess
              both nodes.  if neither children possess both nodes, return
              current node '''
      Severity: Minor
      Found in tree_lib/node.py - About 25 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 GetOtherNodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def GetOtherNodes(this_node):
      
              # fill out the leaf dictionary
              other_nodes = []
              for branch in this_node.branch_list:
      Severity: Minor
      Found in tree_lib/node.py - About 25 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 PrintAllEvents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def PrintAllEvents(this_node,lca,output_file):
        event_counts = {'hgt':0, 'dup':0, 'los':0, 'spc':0}
        events = this_node.raw_list
        for event in events:
          output_file.write(event + "\n")
      Severity: Minor
      Found in angst_lib/output.py - About 25 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