optiver/ruruki

View on GitHub
ruruki/graphs.py

Summary

Maintainability
F
3 days
Test Coverage

File graphs.py has 651 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Graph implementations
"""
from collections import defaultdict
import json
Severity: Major
Found in ruruki/graphs.py - About 1 day to fix

    Graph has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Graph(interfaces.IGraph):
        """
        In-memory graph database.
    
        See :class:`~.IGraph` for doco.
    Severity: Minor
    Found in ruruki/graphs.py - About 2 hrs to fix

      Function _vertex_constraint_violated has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def _vertex_constraint_violated(self, vertex, **kwargs):
              """
              Check if the given vertex violates any of the constraints.
      
              :param vertex: vertex that you are checking for constraint violations.
      Severity: Minor
      Found in ruruki/graphs.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 get_or_create_vertex has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_or_create_vertex(self, label=None, **kwargs):
              if not label and not kwargs:
                  return None
      
              # first check constraints.
      Severity: Minor
      Found in ruruki/graphs.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 _search_for_edge_ids has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def _search_for_edge_ids(path):
          """
          Internal helper function to search for edges identity numbers
          based in the directories and the head and tail vertices identity
          numbers.
      Severity: Minor
      Found in ruruki/graphs.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 get_edges has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_edges(self, head=None, label=None, tail=None, **kwargs):
              if head is None and tail is None:
                  return self.edges.filter(label, **kwargs)
      
              container = EntitySet()
      Severity: Minor
      Found in ruruki/graphs.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 _search_for_vertex_id has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def _search_for_vertex_id(path):
          """
          Internal helper function to search for vertices identity numbers
          based in the directories.
      
      
      Severity: Minor
      Found in ruruki/graphs.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 append_vertex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def append_vertex(self, vertex):
              if vertex.graph is not None and vertex.graph is not self:
                  raise interfaces.DatabaseException(
                      "Can not append vertex {} which is already bound to "
                      "anther graph instance.".format(vertex)
      Severity: Minor
      Found in ruruki/graphs.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

      Avoid deeply nested control flow statements.
      Open

                              if indexed_entity.properties[key] == value:
                                  raise interfaces.ConstraintViolation(
                                      "{!r} violated constraint {!r}".format(
                                          vertex, key
                                      )
      Severity: Major
      Found in ruruki/graphs.py - About 45 mins to fix

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

            def remove_vertex(self, vertex):
                count = len(vertex.get_both_edges())
                if count > 0:
                    raise interfaces.VertexBoundByEdges(
                        "Vertex {0!r} is still bound to another vertex "
        Severity: Minor
        Found in ruruki/graphs.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

        There are no issues that match your filters.

        Category
        Status