atlassian/localstack

View on GitHub
localstack/services/infra.py

Summary

Maintainability
C
1 day
Test Coverage

Function load_plugins has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def load_plugins():
    loaded_files = []
    for module in pkgutil.iter_modules():
        if six.PY3 and not isinstance(module, tuple):
            file_path = '%s/%s/plugins.py' % (module.module_finder.path, module.name)
Severity: Minor
Found in localstack/services/infra.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 start_infra has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def start_infra(async=False, apis=None):
    try:
        # load plugins
        load_plugins()

Severity: Minor
Found in localstack/services/infra.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 check_infra has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def check_infra(retries=8, expect_shutdown=False, apis=None, additional_checks=[]):
    try:
        print_error = retries <= 0

        # loop through plugins and check service status
Severity: Minor
Found in localstack/services/infra.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 start_moto_server has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def start_moto_server(key, port, name=None, backend_port=None, async=False, update_listener=None):
Severity: Minor
Found in localstack/services/infra.py - About 45 mins to fix

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

    def start_proxy(port, backend_port, update_listener, quiet=False,
    Severity: Minor
    Found in localstack/services/infra.py - About 45 mins to fix

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

      def do_run(cmd, async, print_output=False):
          sys.stdout.flush()
          if async:
              if is_debug():
                  print_output = True
      Severity: Minor
      Found in localstack/services/infra.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

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

      def start_cloudformation(port=PORT_CLOUDFORMATION, async=False, update_listener=None):
          return start_moto_server('cloudformation', port, name='CloudFormation', async=async,
      Severity: Major
      Found in localstack/services/infra.py and 3 other locations - About 35 mins to fix
      localstack/services/infra.py on lines 109..110
      localstack/services/infra.py on lines 114..115
      localstack/services/infra.py on lines 119..120

      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 4 locations. Consider refactoring.
      Open

      def start_s3(port=PORT_S3, async=False, update_listener=None):
          return start_moto_server('s3', port, name='S3', async=async,
      Severity: Major
      Found in localstack/services/infra.py and 3 other locations - About 35 mins to fix
      localstack/services/infra.py on lines 109..110
      localstack/services/infra.py on lines 119..120
      localstack/services/infra.py on lines 124..125

      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 4 locations. Consider refactoring.
      Open

      def start_sns(port=PORT_SNS, async=False, update_listener=None):
          return start_moto_server('sns', port, name='SNS', async=async,
      Severity: Major
      Found in localstack/services/infra.py and 3 other locations - About 35 mins to fix
      localstack/services/infra.py on lines 109..110
      localstack/services/infra.py on lines 114..115
      localstack/services/infra.py on lines 124..125

      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 4 locations. Consider refactoring.
      Open

      def start_apigateway(port=PORT_APIGATEWAY, async=False, update_listener=None):
          return start_moto_server('apigateway', port, name='API Gateway', async=async,
      Severity: Major
      Found in localstack/services/infra.py and 3 other locations - About 35 mins to fix
      localstack/services/infra.py on lines 114..115
      localstack/services/infra.py on lines 119..120
      localstack/services/infra.py on lines 124..125

      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

      There are no issues that match your filters.

      Category
      Status