Showing 5,781 of 10,536 total issues
Avoid deeply nested control flow statements. Open
Open
if parameters['constant'] is None:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_CONSTANT_VALUE')
Avoid deeply nested control flow statements. Open
Open
if meter_dict.get(numerator_meter_uuid) is None and \
virtual_meter_dict.get(numerator_meter_uuid) is None and \
offline_meter_dict.get(numerator_meter_uuid) is None:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_NUMERATOR_METER_UUID')
Avoid deeply nested control flow statements. Open
Open
if numerator_meter is None:
numerator_meter = offline_meter_dict.get(row[5], None)
# find denominator meter by uuid
denominator_meter = meter_dict.get(row[6], None)
Function on_get
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def on_get(req, resp, id_):
if 'API-KEY' not in req.headers or \
not isinstance(req.headers['API-KEY'], str) or \
len(str.strip(req.headers['API-KEY'])) == 0:
access_control(req)
- 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
Open
if denominator_meter is None:
denominator_meter = offline_meter_dict.get(row[6], None)
Avoid deeply nested control flow statements. Open
Open
if parameters['numerator_meter'] is not None and \
isinstance(parameters['numerator_meter']['uuid'], str) and \
len(str.strip(parameters['numerator_meter']['uuid'])) > 0:
numerator_meter_uuid = str.strip(parameters['numerator_meter']['uuid'])
Avoid deeply nested control flow statements. Open
Open
if denominator_meter_uuid not in meter_dict and \
denominator_meter_uuid not in virtual_meter_dict and \
denominator_meter_uuid not in offline_meter_dict:
raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_DENOMINATOR_METER_UUID')
Avoid deeply nested control flow statements. Open
Open
for row in rows_meters:
meter_dict[row[2]] = {"type": 'meter',
"id": row[0],
"name": row[1],
"uuid": row[2]}
Avoid deeply nested control flow statements. Open
Open
if rows_offline_meters is not None and len(rows_offline_meters) > 0:
for row in rows_offline_meters:
offline_meter_dict[row[2]] = {"type": 'offline_meter',
"id": row[0],
"name": row[1],
Avoid deeply nested control flow statements. Open
Open
for row in rows_virtual_meters:
virtual_meter_dict[row[2]] = {"type": 'virtual_meter',
"id": row[0],
"name": row[1],
"uuid": row[2]}
Avoid deeply nested control flow statements. Open
Open
if rows_virtual_meters is not None and len(rows_virtual_meters) > 0:
for row in rows_virtual_meters:
virtual_meter_dict[row[2]] = {"type": 'virtual_meter',
"id": row[0],
"name": row[1],
Consider simplifying this complex logical expression. Open
Open
if (r == -2 || r == 2 || c == -2 || c == 2
|| (r == 0 && c == 0) ) {
_modules[row + r][col + c] = true;
} else {
_modules[row + r][col + c] = false;
Consider simplifying this complex logical expression. Open
Open
"pluralCat": function(n, opt_precision) { var vf = getVF(n, opt_precision); if (n % 10 == 0 || n % 100 >= 11 && n % 100 <= 19 || vf.v == 2 && vf.f % 100 >= 11 && vf.f % 100 <= 19) { return PLURAL_CATEGORY.ZERO; } if (n % 10 == 1 && n % 100 != 11 || vf.v == 2 && vf.f % 10 == 1 && vf.f % 100 != 11 || vf.v != 2 && vf.f % 10 == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
Consider simplifying this complex logical expression. Open
Open
"pluralCat": function(n, opt_precision) { var vf = getVF(n, opt_precision); if (n % 10 == 0 || n % 100 >= 11 && n % 100 <= 19 || vf.v == 2 && vf.f % 100 >= 11 && vf.f % 100 <= 19) { return PLURAL_CATEGORY.ZERO; } if (n % 10 == 1 && n % 100 != 11 || vf.v == 2 && vf.f % 10 == 1 && vf.f % 100 != 11 || vf.v != 2 && vf.f % 10 == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
Consider simplifying this complex logical expression. Open
Open
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
if (!("classList" in document.createElement("a"))) {
capableBrowser = false;
} else {
// The browser supports the API, but may be blacklisted.
Consider simplifying this complex logical expression. Open
Open
if (ignoreTimezone || !m[13]) {
var check = new Date(m[1], 0, 1, 9, 0);
if (m[3]) {
date.setMonth(m[3] - 1);
check.setMonth(m[3] - 1);
Consider simplifying this complex logical expression. Open
Open
if (s.bars.show || (s.lines.show && s.lines.fill)) {
var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
if (s.bars.horizontal) {
delete format[format.length - 1].y;
Consider simplifying this complex logical expression. Open
Open
if ("footable_row_expanded" == a.type && (u = a.row, u && (p = t(e.table).data("expanded_rows"), c = [], p && (c = p.split(",")), c.push(u.rowIndex), t(e.table).data("expanded_rows", c.join(",")))), "footable_row_collapsed" == a.type && (u = a.row)) {
p = t(e.table).data("expanded_rows"), c = [], p && (c = p.split(","));
var g = [];
for (var b in c)
if (c[b] == u.rowIndex) {
Consider simplifying this complex logical expression. Open
Open
if (
b.options.enabled &&
a &&
((a = U.getData()),
a.source || (a.source = b.getDnDSource(d)),
Consider simplifying this complex logical expression. Open
Open
if (
d &&
a &&
c &&
(d =