localstack/localstack

View on GitHub
localstack-core/localstack/utils/run.py

Summary

Maintainability
F
3 days
Test Coverage

Function do_run_cmd has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    def do_run_cmd(self):
        def convert_line(line):
            line = to_str(line or "")
            if self.strip_color:
                # strip color codes
Severity: Minor
Found in localstack-core/localstack/utils/run.py - About 7 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 run.py has 397 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import io
import logging
import os
import re
import select
Severity: Minor
Found in localstack-core/localstack/utils/run.py - About 5 hrs to fix

    Function run has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(
        cmd: Union[str, List[str]],
        print_error=True,
        asynchronous=False,
        stdin=False,
    Severity: Minor
    Found in localstack-core/localstack/utils/run.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 __init__ has 14 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in localstack-core/localstack/utils/run.py - About 1 hr to fix

      Function run_for_max_seconds has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def run_for_max_seconds(max_secs, _function, *args, **kwargs):
          """Run the given function for a maximum of `max_secs` seconds - continue running
          in a background thread if the function does not finish in time."""
      
          def _worker(*_args):
      Severity: Minor
      Found in localstack-core/localstack/utils/run.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

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

      def run(
      Severity: Major
      Found in localstack-core/localstack/utils/run.py - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                    if self.log_listener:
                                        self.log_listener(line, stream=instream)
                                    if self.outfile not in [None, os.devnull]:
        Severity: Major
        Found in localstack-core/localstack/utils/run.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if not (line and line.strip()) and self.is_killed():
                                          break
                                      line = convert_line(line)
          Severity: Major
          Found in localstack-core/localstack/utils/run.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if self.outfile not in [None, os.devnull]:
                                            outstream.write(line)
                                            outstream.flush()
                            if self.process:
            Severity: Major
            Found in localstack-core/localstack/utils/run.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if line in [None, "", b""]:
                                              break
                                          if not (line and line.strip()) and self.is_killed():
              Severity: Major
              Found in localstack-core/localstack/utils/run.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if filter_line(line):
                                                continue
                                            if self.log_listener:
                Severity: Major
                Found in localstack-core/localstack/utils/run.py - About 45 mins to fix

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

                      def stop(self, quiet=False):
                          if self.stopped:
                              return
                          if not self.process:
                              LOG.warning("No process found for command '%s'", self.cmd)
                  Severity: Minor
                  Found in localstack-core/localstack/utils/run.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 _set has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _set(self, out, err, __out, __err):
                  Severity: Minor
                  Found in localstack-core/localstack/utils/run.py - About 35 mins to fix

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

                        def run_cmd(self, params):
                            while True:
                                self.do_run_cmd()
                                from localstack.runtime import events
                    
                    
                    Severity: Minor
                    Found in localstack-core/localstack/utils/run.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

                    There are no issues that match your filters.

                    Category
                    Status