OpenJij/OpenJij

View on GitHub

Showing 464 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

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

                        if "anneal_time_per_run" in response.info:
                            o_res.info["execution_time"] = response.info["anneal_time_per_run"]
                Severity: Minor
                Found in openjij/utils/res_convertor.py and 1 other location - About 35 mins to fix
                openjij/utils/res_convertor.py on lines 44..45

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

                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

                        if "qpu_sampling_time" in response.info:
                            o_res.info["sampling_time"] = response.info["qpu_sampling_time"]
                Severity: Minor
                Found in openjij/utils/res_convertor.py and 1 other location - About 35 mins to fix
                openjij/utils/res_convertor.py on lines 46..47

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

                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

                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

                      Line length
                      Open

                      | **Sunburst**                                                                                                                                                         | **Grid**                                                                                                                                                         | **Icicle**                                                                                                                                                         |
                      Severity: Info
                      Found in README.md by markdownlint

                      MD013 - Line length

                      Tags: line_length

                      Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

                      This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

                      This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

                      You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

                      Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

                      Line length
                      Open

                      It has a Python interface, therefore it can be easily written in Python, although the core part of the optimization is implemented with C++.
                      Severity: Info
                      Found in docs/index.md by markdownlint

                      MD013 - Line length

                      Tags: line_length

                      Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

                      This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

                      This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

                      You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

                      Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

                      Multiple consecutive blank lines
                      Open

                      
                      

                      MD012 - Multiple consecutive blank lines

                      Tags: whitespace, blank_lines

                      Aliases: no-multiple-blanks

                      This rule is triggered when there are multiple consecutive blank lines in the document:

                      Some text here
                      
                      
                      Some more text here

                      To fix this, delete the offending lines:

                      Some text here
                      
                      Some more text here

                      Note: this rule will not be triggered if there are multiple consecutive blank lines inside code blocks.

                      Severity
                      Category
                      Status
                      Source
                      Language