TrishGillett/pysdpt3glue

View on GitHub

Showing 17 of 17 total issues

Function extract_X has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

def extract_X(msg):
    '''
    Given the output message from running SDPT3solve.m, reconstruct the X
    matrix from the printed output and return it.
    '''
Severity: Minor
Found in sdpt3glue/result.py - About 4 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 simplify_sedumi_model has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def simplify_sedumi_model(A, b, c, K, allow_nonzero_b=False):
    '''
    Tries to eliminate variables using a few simple strategies:

    1. If a constraint is expressing :math:`A_{ki}x_i = b_k` where variable
Severity: Minor
Found in sdpt3glue/sedumi_writer.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 check_eliminatibility has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def check_eliminatibility(g, h, n_elig=None, allow_nonzero_b=False):
    '''
    Tests if constraint :math:`gx = h` fits either pattern :math:`ax_i = d`
    or pattern :math:`ax_i + bx_j = d`, with the requirement that the
    :math:`x_i` variable be one of the first n_elig variables.
Severity: Minor
Found in sdpt3glue/sedumi_writer.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

Avoid deeply nested control flow statements.
Open

                    for k, item in enumerate(re.split(r'\s+', line)):
                        Xlist[i][row, col_start + k] = float(item)
            print "Imported X[{0}] as a matrix with shape {1}.".format(i, Xlist[i].shape)
Severity: Major
Found in sdpt3glue/result.py - About 45 mins to fix

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

    def sdpt3_solve_problem(
    Severity: Minor
    Found in sdpt3glue/solve.py - About 45 mins to fix

      Function track_and_return has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def track_and_return(self, jobid, pwd):
              '''
              Takes a jobid and password for a solve already in progress,
              waits for its status to change to 'Done', and returns the message,
              jobid, and password.
      Severity: Minor
      Found in sdpt3glue/solve_neos.py - About 45 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 write_sedumi_to_mat has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def write_sedumi_to_mat(A, b, c, K, target):
      Severity: Minor
      Found in sdpt3glue/sedumi_writer.py - About 35 mins to fix

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

        def simplify_sedumi_model(A, b, c, K, allow_nonzero_b=False):
        Severity: Minor
        Found in sdpt3glue/sedumi_writer.py - About 35 mins to fix

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

          def neos_solve(
          Severity: Minor
          Found in sdpt3glue/solve_neos.py - About 35 mins to fix

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

            def sdpt3_solve_mat(
            Severity: Minor
            Found in sdpt3glue/solve.py - About 35 mins to fix

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

              def clean_K_dims(K):
                  '''
                  Matlab requires the dimensions to be given in floating point numbers,
                  this checker ensures that they are.
                  '''
              Severity: Minor
              Found in sdpt3glue/sedumi_writer.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

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

              def handle_msg_item(x):
                  '''
                  A function that takes a string x and returns it's interpretation as an int,
                  float, or string in that order of preference.  If x is None, None is
                  returned.
              Severity: Minor
              Found in sdpt3glue/result.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 None, None
              Severity: Major
              Found in sdpt3glue/sedumi_writer.py - About 30 mins to fix

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

                            except ProtocolError as err:
                                _print_protocol_error(err)
                                print "  Error checking status: {0}  (will try again)".format(
                                    sys.exc_info()[0])
                Severity: Minor
                Found in sdpt3glue/solve_neos.py and 1 other location - About 30 mins to fix
                sdpt3glue/solve_neos.py on lines 284..287

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

                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

                            except Fault as err:
                                _print_fault(err)
                                print "  Error checking status: {0}  (will try again)".format(
                                    sys.exc_info()[0])
                Severity: Minor
                Found in sdpt3glue/solve_neos.py and 1 other location - About 30 mins to fix
                sdpt3glue/solve_neos.py on lines 289..292

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

                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

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

                def symmetrize_sedumi_model(A, b, c, K):
                    '''
                    Symmetrize sedumi model.
                    '''
                    colstart = K['f'] + K['l'] + sum(K['q'])
                Severity: Minor
                Found in sdpt3glue/sedumi_writer.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 handle_submission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def handle_submission(matfile_target, no_prompt=False):
                    '''
                    Submits the Sedumi format .mat file to be solved on NEOS with SDPT3.
                
                    Args:
                Severity: Minor
                Found in sdpt3glue/solve_neos.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