OpenJij/OpenJij

View on GitHub

Showing 55 of 464 total issues

Consider simplifying this complex logical expression.
Open

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

    Consider simplifying this complex logical expression.
    Open

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

      Function bqm_from_numpy_matrix has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def bqm_from_numpy_matrix(
      Severity: Minor
      Found in openjij/model/model.py - About 35 mins to fix

        Function se_upper_tts has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def se_upper_tts(tts, success_prob, computation_time, p_r, se_success_prob):
        Severity: Minor
        Found in openjij/utils/benchmark.py - About 35 mins to fix

          Function _annealing_schedule_setting has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _annealing_schedule_setting(
          Severity: Minor
          Found in openjij/sampler/sqa_sampler.py - About 35 mins to fix

            Function se_lower_tts has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def se_lower_tts(tts, success_prob, computation_time, p_r, se_success_prob):
            Severity: Minor
            Found in openjij/utils/benchmark.py - About 35 mins to fix

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

                  def __init__(
              Severity: Minor
              Found in openjij/sampler/csqa_sampler.py - About 35 mins to fix

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

                def make_BinaryPolynomialModel_from_JSON(obj):
                    if obj["type"] != "BinaryPolynomialModel":
                        raise Exception('Type must be "BinaryPolynomialModel"')
                    mock_polynomial = {}
                    if obj["index_type"] == "IndexType.INT":
                Severity: Minor
                Found in openjij/model/model.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

                Avoid too many return statements within this function.
                Open

                                return _BinaryPolynomialModel_from_list(
                Severity: Major
                Found in openjij/model/model.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return _BinaryPolynomialModel_from_dict(
                  Severity: Major
                  Found in openjij/model/model.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                        return _BinaryPolynomialModel_from_list(
                    Severity: Major
                    Found in openjij/model/model.py - About 30 mins to fix

                      Function geometric_ising_beta_schedule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def geometric_ising_beta_schedule(
                          cxxgraph: Union[openjij.cxxjij.graph.Dense, openjij.cxxjij.graph.CSRSparse],
                          beta_max=None,
                          beta_min=None,
                          num_sweeps=1000,
                      Severity: Minor
                      Found in openjij/sampler/sa_sampler.py - About 25 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 rename_kwargs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def rename_kwargs(func_name, kwargs, aliases):
                          for alias, new in aliases.items():
                              if alias in kwargs:
                                  if new in kwargs:
                                      raise TypeError(f"{func_name} received both {alias} and {new}")
                      Severity: Minor
                      Found in openjij/utils/decorator.py - About 25 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 _set_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _set_params(self, **kwargs):
                              for key, value in kwargs.items():
                                  if key not in self._default_params:
                                      raise ValueError("Unknown parameters detected")
                                  if value is None:
                      Severity: Minor
                      Found in openjij/sampler/sampler.py - About 25 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 sample_hubo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def sample_hubo(
                              self,
                              J: dict[tuple, float],
                              vartype: Optional[str] = None,
                              num_sweeps: int = 1000,
                      Severity: Minor
                      Found in openjij/sampler/sa_sampler.py - About 25 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

                      Severity
                      Category
                      Status
                      Source
                      Language