OpenJij/OpenJij

View on GitHub

Showing 55 of 464 total issues

Function make_ChimeraModel has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

def make_ChimeraModel(linear, quadratic):
    """ChimeraModel factory.

    Returns:
        generated ChimeraModel class
Severity: Minor
Found in openjij/model/chimera_model.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 sample has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    def sample(
        self,
        bqm: Union[
            "openj.model.model.BinaryQuadraticModel", dimod.BinaryQuadraticModel
        ],
Severity: Minor
Found in openjij/sampler/sa_sampler.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 BinaryPolynomialModel has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

def BinaryPolynomialModel(*args, **kwargs):
    if kwargs == {}:
        if len(args) <= 1:
            raise TypeError("Invalid argument for this function")
        elif len(args) == 2:
Severity: Minor
Found in openjij/model/model.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 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

File sa_sampler.py has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2023 Jij Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

Severity: Major
Found in openjij/sampler/sa_sampler.py - About 1 day to fix

    File model.py has 485 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Copyright 2023 Jij Inc.
    
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    Severity: Minor
    Found in openjij/model/model.py - About 7 hrs to fix

      Function make_BinaryPolynomialModel_from_hising has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

      def make_BinaryPolynomialModel_from_hising(*args, **kwargs):
          if kwargs == {}:
              if len(args) == 0:
                  raise TypeError("Invalid argument for this function")
              elif len(args) == 1:
      Severity: Minor
      Found in openjij/model/model.py - About 6 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 make_BinaryPolynomialModel_from_hubo has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
      Open

      def make_BinaryPolynomialModel_from_hubo(*args, **kwargs):
          if kwargs == {}:
              if len(args) == 0:
                  raise TypeError("Invalid argument for this function")
              elif len(args) == 1:
      Severity: Minor
      Found in openjij/model/model.py - About 6 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 _sample_hubo_old has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          def _sample_hubo_old(
              self,
              J: Union[
                  dict, "openj.model.model.BinaryPolynomialModel", cimod.BinaryPolynomialModel
              ],
      Severity: Minor
      Found in openjij/sampler/sa_sampler.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

      Function BinaryQuadraticModel has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def BinaryQuadraticModel(linear, quadratic, *args, **kwargs):
          """Generate BinaryQuadraticModel object.
      
          Attributes:
              vartype (dimod.Vartype): variable type SPIN or BINARY
      Severity: Minor
      Found in openjij/model/model.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 sample has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def sample(
              self,
              bqm: Union[
                  "openjij.model.model.BinaryQuadraticModel", dimod.BinaryQuadraticModel
              ],
      Severity: Minor
      Found in openjij/sampler/sqa_sampler.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

      File chimera_model.py has 285 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright 2023 Jij Inc.
      
      # Licensed under the Apache License, Version 2.0 (the "License");
      # you may not use this file except in compliance with the License.
      # You may obtain a copy of the License at
      Severity: Minor
      Found in openjij/model/chimera_model.py - About 2 hrs to fix

        File sqa_sampler.py has 267 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from __future__ import annotations
        try:
            from typing import Optional, Union
        except ImportError:
            from typing_extensions import Optional, Union
        Severity: Minor
        Found in openjij/sampler/sqa_sampler.py - About 2 hrs to fix

          Function convert_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def convert_response(response):
              if isinstance(response, oj.sampler.response.Response):
                  return response
          
              try:
          Severity: Minor
          Found in openjij/utils/res_convertor.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

          Consider simplifying this complex logical expression.
          Open

                  if "keys" in kwargs and "values" in kwargs and "vartype" in kwargs:
                      key_condition = isinstance(kwargs["keys"], list) or isinstance(
                          kwargs["keys"], tuple
                      )
                      val_condition = isinstance(kwargs["values"], list) or isinstance(
          Severity: Critical
          Found in openjij/model/model.py - About 1 hr to fix

            Function sample has 12 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def sample(
            Severity: Major
            Found in openjij/sampler/sqa_sampler.py - About 1 hr to fix

              Function sample_ising has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def sample_ising(
              Severity: Major
              Found in openjij/sampler/csqa_sampler.py - About 1 hr to fix

                Function _sample_hubo_old has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _sample_hubo_old(
                Severity: Major
                Found in openjij/sampler/sa_sampler.py - About 1 hr to fix

                  Function base_sample_hubo has 11 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def base_sample_hubo(
                  Severity: Major
                  Found in openjij/sampler/base_sa_sample_hubo.py - About 1 hr to fix

                    Function sample_hubo has 11 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def sample_hubo(
                    Severity: Major
                    Found in openjij/sampler/sa_sampler.py - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language