almlab/angst

View on GitHub

Showing 94 of 94 total issues

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

                if parent is None:
                    upper_height = lower_height + 1.0
                else:
                    upper_height = ultra_tree.height_dict[tree_link[parent]]
Severity: Major
Found in angst_lib/reconcile.py and 1 other location - About 1 hr to fix
angst_lib/reconcile.py on lines 477..480

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 41.

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 __init__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self,raw_name,arbre):
        # remove any leading angled brackets
        raw_name = raw_name.lstrip(">")

        # handle mixed underscore and dot environment
Severity: Minor
Found in tree_lib/node.py - About 1 hr to fix

    Function GetSibDists has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def GetSibDists(self,species_tree):
            '''get distances between all siblings on the tree'''
            parent_dict = {}
            dist_list = []
            for leaf in self.leaf_dict.values():
    Severity: Minor
    Found in tree_lib/multitree.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 EventGuideAdjust has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def EventGuideAdjust(event_list,event_guide,model):
        ''' provide score adjustment based on event guide '''
        score_adjust = 0.0
        for event in event_list:
            if event in event_guide:
    Severity: Minor
    Found in angst_lib/reconcile.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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

                first_leaf = newick[regex[0]+1:regex[1]-1]
    Severity: Major
    Found in tree_lib/multitree.py and 3 other locations - About 55 mins to fix
    tree_lib/multitree.py on lines 106..106
    tree_lib/multitree.py on lines 148..148
    tree_lib/multitree.py on lines 179..179

    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 37.

    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 GetChildLeaves has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def GetChildLeaves(this_node,parent_node,other_nodes):
    
            merge_list = []
            for kid_node in other_nodes:
                if parent_node in this_node.leaf_dict:
    Severity: Minor
    Found in tree_lib/node.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 GetNodeLinkDict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def GetNodeLinkDict(this_node,node_link_dict):
    
            this_node.link_dict_visited = True
            leaf_dict = this_node.leaf_dict
    
    
    Severity: Minor
    Found in tree_lib/node.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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

                clade = newick[regex[0]+1:regex[1]-2]
    Severity: Major
    Found in tree_lib/multitree.py and 3 other locations - About 55 mins to fix
    tree_lib/multitree.py on lines 106..106
    tree_lib/multitree.py on lines 137..137
    tree_lib/multitree.py on lines 179..179

    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 37.

    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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

            clade = newick[regex[0]+1:regex[1]-2]
    Severity: Major
    Found in tree_lib/multitree.py and 3 other locations - About 55 mins to fix
    tree_lib/multitree.py on lines 106..106
    tree_lib/multitree.py on lines 137..137
    tree_lib/multitree.py on lines 148..148

    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 37.

    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 UnrootedLeaving has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def UnrootedLeaving(this_node):
    
            other_nodes = this_node.GetOtherNodes()
            for parent_node in other_nodes:
                child_nodes = list(set(other_nodes).difference(set([parent_node])))
    Severity: Minor
    Found in tree_lib/node.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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

            clade = newick[regex[0]+1:regex[1]-1]
    Severity: Major
    Found in tree_lib/multitree.py and 3 other locations - About 55 mins to fix
    tree_lib/multitree.py on lines 137..137
    tree_lib/multitree.py on lines 148..148
    tree_lib/multitree.py on lines 179..179

    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 37.

    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

    Avoid deeply nested control flow statements.
    Open

                        if model.luca == "Root" or model.special == "hr":
                            if ancestor is not species_tree.root:
                                sscore = self.max_float
    
    
    Severity: Major
    Found in angst_lib/reconcile.py - About 45 mins to fix

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

          def treePrint(self,newickString):
      
          count = 0
              # implement sorting so that you can compare trees in a quick
              # and dirty way
      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 node_pair[0].name == model.outgroup:
                              node_link.TryRoot(node_pair)
                          if node_pair[1].name == model.outgroup:
      Severity: Major
      Found in angst_lib/AnGSTHelper.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if len(raw_los_list) > 0:
                                sscore = node_link.max_float
        
                            # make sure losses only percolated down, not up
                            for ind in range(len(los_list)):
        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:
                                  continue
                          else:
          Severity: Major
          Found in angst_lib/reconcile.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if num_dups > 0:
                                    # need to deal w/ situation where dups erase
                                    # information about ranges, which leads to
                                    # problems when you're trying to prevent time
                                    # paradoxes.  see notes from 05.25.10.
            Severity: Major
            Found in angst_lib/reconcile.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if node_relation == 1:
                                      this_paradox.append([hgt_str,accep_list])
                      else:
              Severity: Major
              Found in angst_lib/reconcile.py - About 45 mins to fix

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

                def TryTransfer(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 ancestor in cur_lca_scores:
                                          if sscore > cur_lca_scores[ancestor]:
                                              continue
                  
                                  # results datastructure
                  Severity: Major
                  Found in angst_lib/reconcile.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language