atlassian/themis

View on GitHub
themis/scaling/emr_scaling.py

Summary

Maintainability
C
1 day
Test Coverage

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

def perform_scaling(cluster):
    app_config = config.get_config()
    monitoring_interval_secs = int(app_config.general.monitoring_time_window)
    info = cluster.monitoring_data
    LOG.debug('info={}'.format(json.dumps(info, indent=2)))
Severity: Minor
Found in themis/scaling/emr_scaling.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 get_termination_candidates_for_market_or_group has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def get_termination_candidates_for_market_or_group(info, preferred, instance_group_type=INSTANCE_GROUP_TYPE_TASK):
    candidates = []
    cluster_id = info['cluster_id']
    LOG.debug('cluster_id={}'.format(json.dumps(cluster_id)))
    role = emr_monitoring.get_iam_role_for_cluster(cluster_id)
Severity: Minor
Found in themis/scaling/emr_scaling.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 get_nodes_to_terminate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_nodes_to_terminate(info, config=None):
    cluster_id = info['cluster_id']
    if not config:
        config = themis.config.get_config()
    expr = config.get(SECTION_EMR, cluster_id, KEY_DOWNSCALE_EXPR)
Severity: Minor
Found in themis/scaling/emr_scaling.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 remove_duplicates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def remove_duplicates(nodes):
    result = []
    for n in nodes:
        contained = False
        for n1 in result:
Severity: Minor
Found in themis/scaling/emr_scaling.py - About 55 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 get_minimum_nodes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_minimum_nodes(date, cluster_id):
    now_str = date.strftime("%a %Y-%m-%d %H:%M:%S")

    # This is only used for testing, to overwrite the config. If TEST_CONFIG is
    # None (which is the default), then the actual configuration will be used.
Severity: Minor
Found in themis/scaling/emr_scaling.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 select_tasknode_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def select_tasknode_group(tasknodes_groups, cluster_id, info=None):
    if len(tasknodes_groups) <= 0:
        raise Exception("Empty list of task node instance groups for scaling: %s" % tasknodes_groups)
    if len(tasknodes_groups) == 1:
        return tasknodes_groups[0]
Severity: Minor
Found in themis/scaling/emr_scaling.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

Avoid deeply nested control flow statements.
Open

                        if is_task_nodes(info):
                            nodes_groups = aws_common.get_instance_groups_tasknodes(cluster.id, role=role)
                        else:
                            nodes_groups = aws_common.get_instance_groups_nodes(cluster.id, role=role)
                        nodes_group = select_tasknode_group(nodes_groups, cluster.id, info=info)['id']
Severity: Major
Found in themis/scaling/emr_scaling.py - About 45 mins to fix

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

    def spawn_nodes(cluster_ip, tasknodes_group, current_num_nodes, nodes_to_add=1, role=None):
    Severity: Minor
    Found in themis/scaling/emr_scaling.py - About 35 mins to fix

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

      def get_node_groups_or_preferred_markets(cluster_id, info=None, config=None):
          if not config:
              config = themis.config.get_config()
          cluster_config = config.get(SECTION_EMR, cluster_id)
          preferred = cluster_config.group_or_preferred_market
      Severity: Minor
      Found in themis/scaling/emr_scaling.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

      Error: invalid syntax (<unknown>, line 39)</unknown>
      Open

          except Exception, e:
      Severity: Minor
      Found in themis/scaling/emr_scaling.py by radon

      We encountered an error attempting to analyze this line.

      TODO found
      Open

      # TODO: merge with execute_dsl_string in util/expr.py !
      Severity: Minor
      Found in themis/scaling/emr_scaling.py by fixme

      TODO found
      Open

              return ['TODO' for i in range(0, num_upsize)]
      Severity: Minor
      Found in themis/scaling/emr_scaling.py by fixme

      TODO found
      Open

                  # TODO add more relevant data to persist
      Severity: Minor
      Found in themis/scaling/emr_scaling.py by fixme

      There are no issues that match your filters.

      Category
      Status