Shoobx/python-graph

View on GitHub

Showing 66 of 66 total issues

Function maximum_flow has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

def maximum_flow(graph, source, sink, caps = None):
    """
    Find a maximum flow and minimum cut of a directed graph by the Edmonds-Karp algorithm.

    @type graph: digraph
Severity: Minor
Found in core/pygraph/algorithms/minmax.py - About 5 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 minmax.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (c) 2007-2009 Pedro Matiello <pmatiello@gmail.com>
#                         Peter Sagerson <peter.sagerson@gmail.com>
#                         Johannes Reinhardt <jreinhardt@ist-dein-freund.de>
#                         Rhys Ulerich <rhys.ulerich@gmail.com>
#                         Roy Smith <roy@panix.com>
Severity: Minor
Found in core/pygraph/algorithms/minmax.py - About 4 hrs to fix

    Function find_cycle has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_cycle(graph):
        """
        Find a cycle in the given graph.
        
        This function will return a list of nodes which form a cycle in the graph or an empty list if
    Severity: Minor
    Found in core/pygraph/algorithms/cycles.py - About 4 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 __eq__ has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            """
            Return whether this graph is equal to another one.
            
            @type other: graph, digraph
    Severity: Minor
    Found in core/pygraph/mixins/labeling.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 cut_nodes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def cut_nodes(graph):
        """
        Return the cut-nodes of the given graph.
        
        A cut node, or articulation point, is a node of a graph whose removal increases the number of
    Severity: Minor
    Found in core/pygraph/algorithms/accessibility.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 read has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def read(string):
        """
        Read a graph from a string in Dot language and return it. Nodes and edges specified in the
        input will be added to the current graph.
        
    Severity: Minor
    Found in dot/pygraph/readwrite/dot.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

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

    def _cut_hyperedges(hypergraph):
        """
        Return the cut-hyperedges of the given hypergraph.
        
        @type  hypergraph: hypergraph
    Severity: Major
    Found in core/pygraph/algorithms/accessibility.py and 1 other location - About 3 hrs to fix
    core/pygraph/algorithms/accessibility.py on lines 291..308

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

    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 2 locations. Consider refactoring.
    Open

    def _cut_hypernodes(hypergraph):
        """
        Return the cut-nodes of the given hypergraph.
        
        @type  hypergraph: hypergraph
    Severity: Major
    Found in core/pygraph/algorithms/accessibility.py and 1 other location - About 3 hrs to fix
    core/pygraph/algorithms/accessibility.py on lines 217..234

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

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

    def write(G, weighted=False):
        """
        Return a string specifying the given graph in Dot language.
        
        @type  G: graph
    Severity: Minor
    Found in dot/pygraph/readwrite/dot.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 __eq__ has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            """
            Return whether this graph is equal to another one.
            
            @type other: graph, digraph
    Severity: Minor
    Found in core/pygraph/mixins/common.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

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

        def set_edge_label(self, edge, label):
            """
            Set the label of an edge.
    
            @type  edge: edge
    Severity: Major
    Found in core/pygraph/mixins/labeling.py and 1 other location - About 3 hrs to fix
    core/pygraph/mixins/labeling.py on lines 79..91

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

    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 2 locations. Consider refactoring.
    Open

        def set_edge_weight(self, edge, wt):
            """
            Set the weight of an edge.
    
            @type  edge: edge
    Severity: Major
    Found in core/pygraph/mixins/labeling.py and 1 other location - About 3 hrs to fix
    core/pygraph/mixins/labeling.py on lines 106..118

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

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

    def cut_tree(igraph, caps = None):
        """
        Construct a Gomory-Hu cut tree by applying the algorithm of Gusfield.
    
        @type igraph: graph
    Severity: Minor
    Found in core/pygraph/algorithms/minmax.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 optimize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def optimize(self, graph):
            """
            Build a dictionary mapping each pair of nodes to a number (the distance between them).
            
            @type  graph: graph
    Severity: Minor
    Found in core/pygraph/algorithms/heuristics/euclidean.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 __eq__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __eq__(self, other):
            """
            Return whether this hypergraph is equal to another one.
            
            @type other: hypergraph
    Severity: Minor
    Found in core/pygraph/classes/hypergraph.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 breadth_first_search has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def breadth_first_search(graph, root=None, filter=null()):
        """
        Breadth-first search.
    
        @type  graph: graph, digraph
    Severity: Minor
    Found in core/pygraph/algorithms/searching.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 heuristic_search has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def heuristic_search(graph, start, goal, heuristic):
        """
        A* search algorithm.
        
        A set of heuristics is available under C{graph.algorithms.heuristics}. User-created heuristics
    Severity: Minor
    Found in core/pygraph/algorithms/minmax.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

    hypergraph has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class hypergraph (basegraph, common, labeling):
        """
        Hypergraph class.
        
        Hypergraphs are a generalization of graphs where an edge (called hyperedge) can connect more
    Severity: Minor
    Found in core/pygraph/classes/hypergraph.py - About 2 hrs to fix

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

              if src in distance and \
                 dst in distance and \
                 distance[src] + graph.edge_weight((src,dst)) < distance[dst]:
      Severity: Major
      Found in core/pygraph/algorithms/minmax.py and 1 other location - About 2 hrs to fix
      core/pygraph/algorithms/minmax.py on lines 273..274

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

      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

                  elif (src  in distance) and (dst in distance) and \
                  distance[src] + graph.edge_weight((src,dst)) < distance[dst]:
      Severity: Major
      Found in core/pygraph/algorithms/minmax.py and 1 other location - About 2 hrs to fix
      core/pygraph/algorithms/minmax.py on lines 280..282

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

      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

      Severity
      Category
      Status
      Source
      Language