localstack/localstack

View on GitHub
localstack-core/localstack/config.py

Summary

Maintainability
F
3 days
Test Coverage

File config.py has 978 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import os
import platform
import socket
import subprocess
Severity: Major
Found in localstack-core/localstack/config.py - About 2 days to fix

    Function in_docker has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def in_docker():
        """
        Returns True if running in a docker container, else False
        Ref. https://docs.docker.com/config/containers/runmetrics/#control-groups
        """
    Severity: Minor
    Found in localstack-core/localstack/config.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      Function append has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def append(self, value: HostAndPort):
              # no exact duplicates
              if value in self:
                  return
      
      
      Severity: Minor
      Found in localstack-core/localstack/config.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(
              cls,
              input: str,
              default_host: str,
              default_port: int,
      Severity: Minor
      Found in localstack-core/localstack/config.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 load_environment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def load_environment(profiles: str = None, env=os.environ) -> List[str]:
          """Loads the environment variables from ~/.localstack/{profile}.env, for each profile listed in the profiles.
          :param env: environment to load profile to. Defaults to `os.environ`
          :param profiles: a comma separated list of profiles to load (defaults to "default")
          :returns str: the list of the actually loaded profiles (might be the fallback)
      Severity: Minor
      Found in localstack-core/localstack/config.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 mkdirs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def mkdirs(self):
              for folder in [
                  self.static_libs,
                  self.var_libs,
                  self.cache,
      Severity: Minor
      Found in localstack-core/localstack/config.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 False
      Severity: Major
      Found in localstack-core/localstack/config.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return True
        Severity: Major
        Found in localstack-core/localstack/config.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return True
          Severity: Major
          Found in localstack-core/localstack/config.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return False
            Severity: Major
            Found in localstack-core/localstack/config.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return False
              Severity: Major
              Found in localstack-core/localstack/config.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return True
                Severity: Major
                Found in localstack-core/localstack/config.py - About 30 mins to fix

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

                  def populate_edge_configuration(
                      environment: Mapping[str, str],
                  ) -> Tuple[HostAndPort, UniqueHostAndPortList]:
                      """Populate the LocalStack edge configuration from environment variables."""
                      localstack_host_raw = environment.get("LOCALSTACK_HOST")
                  Severity: Minor
                  Found in localstack-core/localstack/config.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

                  There are no issues that match your filters.

                  Category
                  Status