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
- Read upRead up
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)
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):
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,
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):
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):
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'):
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:
- Read upRead up
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)
- Read upRead up
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)
- Read upRead up
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:
- Read upRead up
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):
- Read upRead up
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
- Read upRead up
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')
Avoid too many return
statements within this function. Open
return 1.0 - (mem_free / mem_total)
Avoid too many return
statements within this function. Open
return float('NaN')
Avoid too many return
statements within this function. Open
return Math.floor(seconds) + " seconds";
Avoid too many return
statements within this function. Open
return float('NaN')
Avoid too many return
statements within this function. Open
return avg_load
Avoid too many return
statements within this function. Open
return interval + " minutes";