atlassian/themis

View on GitHub

Showing 68 of 157 total issues

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

    def to_json(self, indent=None):
        return json.dumps(self,
            default=lambda o: ((float(o) if o % 1 > 0 else int(o))
                if isinstance(o, decimal.Decimal) else str(o)
                if isinstance(o, datetime) else
Severity: Minor
Found in themis/model/aws_model.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

                        for inst in out2['Instances']:
                            if inst['InstanceGroupId'] == g['Id']:
                                cluster.ip = inst['PrivateDnsName']
                cfg.emr.append(cluster)
Severity: Major
Found in themis/monitoring/emr_monitoring.py - About 45 mins to fix

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

    def run_ssh(cmd, host, user=None, keys=None, via_hosts=[], cache_duration_secs=0):
    Severity: Minor
    Found in themis/util/remote.py - About 45 mins to fix

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

      def get_value(key, config=None, default=None, section=SECTION_GLOBAL, resource=None,
      Severity: Minor
      Found in themis/config.py - About 45 mins to fix

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

        def set_value(key, new_value, section=SECTION_GLOBAL, resource=None, config=None):
        Severity: Minor
        Found in themis/config.py - About 35 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 fillup_with_zeros has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def fillup_with_zeros(datapoints, start_time, time_window, period, statistic='Sum'):
            Severity: Minor
            Found in themis/util/timeseries.py - About 35 mins to fix

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

              def get_db_connection(db_url=None):
                  local = threading.local()
                  try:
                      local.db_connections
                  except AttributeError:
              Severity: Minor
              Found in themis/monitoring/database.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 get_downscale_shards has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_downscale_shards(stream, config=None):
                  if not config:
                      config = themis.config.get_config()
                  expr = config.get(SECTION_KINESIS, stream.id, KEY_STREAM_DOWNSCALE_EXPR)
                  num_downsize = execute_dsl_string(expr, stream.monitoring_data, config=config)
              Severity: Minor
              Found in themis/scaling/kinesis_scaling.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 perform_scaling has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def perform_scaling(kinesis_stream):
                  downscale = get_downscale_shards(kinesis_stream)
                  upscale = get_upscale_shards(kinesis_stream)
                  action = 'NOTHING'
                  role = kinesis_monitoring.get_iam_role_for_stream(kinesis_stream)
              Severity: Minor
              Found in themis/scaling/kinesis_scaling.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 get_presto_node_states has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_presto_node_states(nodes, cluster_ip):
                  def query(host, node_info):
                      node_info['presto_state'] = 'N/A'
                      try:
                          if node_info['state'] == aws_common.INSTANCE_STATE_RUNNING:
              Severity: Minor
              Found in themis/monitoring/emr_monitoring.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 remove_array_with_NaN has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def remove_array_with_NaN(array):
                  i = 0
                  while i < len(array):
                      for item in array[i]:
                          if item == 'NaN' or math.isnan(item):
              Severity: Minor
              Found in themis/monitoring/emr_monitoring.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 run_cached has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def run_cached(func, cache_duration_secs=0, **kwargs):
                  if cache_duration_secs <= 0:
                      return func(**kwargs)
                  hash = md5(func.__name__ + str(kwargs))
                  cache_file = CACHE_FILE_PATTERN.replace('*', '%s') % hash
              Severity: Minor
              Found in themis/util/common.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 float('NaN')
              Severity: Major
              Found in themis/monitoring/emr_monitoring.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return 1.0 - (mem_free / mem_total)
                Severity: Major
                Found in themis/monitoring/emr_monitoring.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return float('NaN')
                  Severity: Major
                  Found in themis/monitoring/emr_monitoring.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return Math.floor(seconds) + " seconds";
                    Severity: Major
                    Found in themis/web/js/app.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return float('NaN')
                      Severity: Major
                      Found in themis/monitoring/emr_monitoring.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return avg_load
                        Severity: Major
                        Found in themis/monitoring/emr_monitoring.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return interval + " minutes";
                          Severity: Major
                          Found in themis/web/js/app.js - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language