OpenJij/OpenJij

View on GitHub
openjij/model/king_graph.py

Summary

Maintainability
C
1 day
Test Coverage
F
12%

Function make_KingGraph has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

def make_KingGraph(linear=None, quadratic=None, king_graph=None):
    """KingGraph factory

    Returns:
        generated KingGraph class
Severity: Minor
Found in openjij/model/king_graph.py - About 1 day 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 KingGraph has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def KingGraph(
Severity: Minor
Found in openjij/model/king_graph.py - About 45 mins to fix

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

            def __init__(
    Severity: Minor
    Found in openjij/model/king_graph.py - About 45 mins to fix

      Refactor this function to reduce its Cognitive Complexity from 53 to the 15 allowed.
      Open

      def make_KingGraph(linear=None, quadratic=None, king_graph=None):
      Severity: Critical
      Found in openjij/model/king_graph.py by sonar-python

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Line too long (86 > 79 characters)
      Open

      KingGraph.from_qubo = lambda Q, offset=0.0, **kwargs: make_KingGraph({}, Q).from_qubo(
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (97 > 79 characters)
      Open

                  yrange (list(int)): represents hardware (CMOS) restricts for coordinate. [ymin, ymax]
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (84 > 79 characters)
      Open

                      linear, quadratic = self._convert_to_BQM_format(king_graph, vartype)
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (85 > 79 characters)
      Open

                  >>> king_graph = oj.KingGraph(machine_type="ASIC", linear=h, quadratic=J)
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (88 > 79 characters)
      Open

                      if not (xi in [xj, xj - 1, xj + 1]) or not (yi in [yj, yj - 1, yj + 1]):
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (97 > 79 characters)
      Open

                  xrange (list(int)): represents hardware (CMOS) restricts for coordinate. [xmin, xmax]
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (86 > 79 characters)
      Open

      KingGraph.from_ising = lambda linear, quadratic, offset=0.0, **kwargs: make_KingGraph(
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (90 > 79 characters)
      Open

                              "Graph is incomplete xi: {}, yi: {}, xj: {}, yj: {}, p:{}".format(
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (91 > 79 characters)
      Open

                  >>> king_graph = oj.KingGraph(machine_type="ASIC", king_graph=king_interaction)
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (90 > 79 characters)
      Open

                              "Graph is incomplete xi: {}, yi: {}, xj: {}, yj: {}, p:{}".format(
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (91 > 79 characters)
      Open

                              "Graph is incomplete xi: {}, yi: {}, xj: {}, yj: {}, p: {}".format(
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (119 > 79 characters)
      Open

                  prange (list(int)): represents hardware (CMOS) restricts for the strength of interactions 'p'. [pmin, pmax]
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (89 > 79 characters)
      Open

                      Annealing cloud Web API format representation of interaction coefficients
      Severity: Minor
      Found in openjij/model/king_graph.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Rename function "KingGraph" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
      Open

      def KingGraph(
      Severity: Major
      Found in openjij/model/king_graph.py by sonar-python

      Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

      Noncompliant Code Example

      With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

      def MyFunction(a,b):
          ...
      

      Compliant Solution

      def my_function(a,b):
          ...
      

      Rename function "make_KingGraph_from_JSON" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
      Open

      def make_KingGraph_from_JSON(obj):
      Severity: Major
      Found in openjij/model/king_graph.py by sonar-python

      Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

      Noncompliant Code Example

      With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

      def MyFunction(a,b):
          ...
      

      Compliant Solution

      def my_function(a,b):
          ...
      

      Rename function "make_KingGraph" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
      Open

      def make_KingGraph(linear=None, quadratic=None, king_graph=None):
      Severity: Major
      Found in openjij/model/king_graph.py by sonar-python

      Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

      Noncompliant Code Example

      With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

      def MyFunction(a,b):
          ...
      

      Compliant Solution

      def my_function(a,b):
          ...
      

      There are no issues that match your filters.

      Category
      Status