atlassian/themis

View on GitHub
themis/util/common.py

Summary

Maintainability
C
1 day
Test Coverage

Function remove_NaN has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def remove_NaN(obj, delete_values=True, replacement='NaN', expect_only_numbers=False):
    if isinstance(obj, list):
        i = 0
        while i < len(obj):
            if is_composite(obj[i]):
Severity: Minor
Found in themis/util/common.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

File common.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import threading
import subprocess32 as subprocess
import os
import re
import time
Severity: Minor
Found in themis/util/common.py - About 2 hrs to fix

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

    def run(cmd, cache_duration_secs=0, log_error=False, retries=0, sleep=2, backoff=1.4):
        def do_run(cmd):
            try:
                mutex_popen.acquire()
                # process = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
    Severity: Minor
    Found in themis/util/common.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 parallelize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def parallelize(array_or_dict, func):
        class MyThread (threading.Thread):
            def __init__(self, item, key=None):
                threading.Thread.__init__(self)
                self.item = item
    Severity: Minor
    Found in themis/util/common.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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def run(cmd, cache_duration_secs=0, log_error=False, retries=0, sleep=2, backoff=1.4):
    Severity: Minor
    Found in themis/util/common.py - About 45 mins to fix

      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

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

      def array_reverse(array):
          result = []
          for i, item1 in enumerate(array):
              for j, item2 in enumerate(item1):
                  if len(result) <= j:
      Severity: Minor
      Found in themis/util/common.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 54)</unknown>
      Open

              except Exception, e:
      Severity: Minor
      Found in themis/util/common.py by radon

      We encountered an error attempting to analyze this line.

      There are no issues that match your filters.

      Category
      Status