Showing 68 of 157 total issues
Function terminate_inactive_nodes
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def terminate_inactive_nodes(cluster, cluster_state, role=None):
if not is_presto_cluster(cluster):
return
nodes = cluster_state['nodes']
for key, node in nodes.iteritems():
- 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_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)
- 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 setConfig
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
setConfig: function(config, params, callback) {
if(typeof params == 'function') {
callback = params;
params = null;
}
Function get_cluster_savings
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_cluster_savings(info, baseline_nodes, zone='us-east-1'):
result = {}
instance_start_times = {}
instance_end_times = {}
instance_types = {}
Function get_outbid_times
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_outbid_times(od_price, spot_history):
curve = get_spot_history_curve(spot_history)
func = interpolate.interp1d(curve['x'], curve['y'])
start_time = curve['x'][-1]
end_time = curve['x'][0]
- 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_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:
- 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_cloudwatch_metrics
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_cloudwatch_metrics(metric, namespace, dimensions, role=None,
Function get_resource
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_resource(section, resource_id, reload=False):
if reload:
if section == SECTION_KINESIS:
themis.monitoring.kinesis_monitoring.reload_resource(resource_id)
if section == SECTION_EMR:
- 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 update_config
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_config(old_config, new_config, section, resource=None):
if section != SECTION_KINESIS:
return
if resource:
old_value = old_config.enable_enhanced_monitoring
- 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
if os and os == attrs['operatingSystem']:
prices = doc['terms']['OnDemand'][key]
if len(prices) > 1:
raise Exception("Multiple price entries found for %s" % key)
price_dim = prices.values()[0]['priceDimensions']
Function loop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def loop():
while True:
LOG.info("Running next loop iteration")
try:
resource_list = resources.get_resources()
- 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
if marker_begin not in key_value:
key_value = ('%s\n' % marker_begin) + key_value
if marker_end not in key_value:
Avoid deeply nested control flow statements. Open
if item_value < map_min[metr]:
map_min[metr] = item_value
map_sum[metr] += item_value
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.
- 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
if marker_end not in key_value:
key_value += ('\n%s' % marker_end)
key_value = key_value.replace('\n\n', '\n')
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):
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]
- 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
if item_value > map_max[metr]:
map_max[metr] = item_value
if item_value < map_min[metr]:
Function get_node_queries
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_node_queries(cluster):
cmd = ('presto-cli --execute \\"SELECT n.http_uri,count(q.node_id) from system.runtime.nodes n ' +
'left join (select * from system.runtime.queries where state = \'RUNNING\' ) as q ' +
'on q.node_id = n.node_id group by n.http_uri\\"')
- 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
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']