File ynl-gen-c.py
has 2319 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
import argparse
import collections
Function main
has a Cognitive Complexity of 234 (exceeds 5 allowed). Consider refactoring. Open
def main():
parser = argparse.ArgumentParser(description='Netlink simple parsing generator')
parser.add_argument('--mode', dest='mode', type=str, required=True)
parser.add_argument('--spec', dest='spec', type=str, required=True)
parser.add_argument('--header', dest='header', action='store_true', default=None)
- 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 print_kernel_op_table
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
def print_kernel_op_table(family, cw):
print_kernel_op_table_fwd(family, cw, terminate=False)
if family.kernel_policy == 'global' or family.kernel_policy == 'per-op':
for op_name, op in family.ops.items():
if op.is_async:
- 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 render_uapi
has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring. Open
def render_uapi(family, cw):
hdr_prot = f"_UAPI_LINUX_{c_upper(family.uapi_header_name)}_H"
cw.p('#ifndef ' + hdr_prot)
cw.p('#define ' + hdr_prot)
cw.nl()
- 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 _load_nested_sets
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def _load_nested_sets(self):
attr_set_queue = list(self.root_sets.keys())
attr_set_seen = set(self.root_sets.keys())
while len(attr_set_queue):
- 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 print_kernel_op_table_fwd
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def print_kernel_op_table_fwd(family, cw, terminate):
exported = not kernel_can_gen_family_struct(family)
if not terminate or exported:
cw.p(f"/* Ops table for {family.name} */")
- 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 _multi_parse
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def _multi_parse(ri, struct, init_lines, local_vars):
if struct.nested:
iter_line = "ynl_attr_for_each_nested(attr, nested)"
else:
if ri.fixed_hdr:
- 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 print_kernel_policy_ranges
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def print_kernel_policy_ranges(family, cw):
first = True
for _, attr_set in family.attr_sets.items():
if attr_set.subset_of:
continue
- 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 __init__
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
self.family = family
self.nl = cw.nlib
self.ku_space = ku_space
self.op_mode = op_mode
- 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 _load_global_policy
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def _load_global_policy(self):
global_set = set()
attr_set_name = None
for op_name, op in self.ops.items():
if not op:
- 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
Type
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Type(SpecAttr):
def __init__(self, family, attr_set, attr, value):
super().__init__(family, attr_set, attr, value)
self.attr = attr
Function _load_attr_use
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _load_attr_use(self):
for _, struct in self.pure_nested_structs.items():
if struct.request:
for _, arg in struct.member_list():
arg.request = True
- 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 _sort_pure_types
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def _sort_pure_types(self):
# Try to reorder according to dependencies
pns_key_list = list(self.pure_nested_structs.keys())
pns_key_seen = set()
rounds = len(pns_key_list) ** 2 # it's basically bubble sort
- 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 op_prefix
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def op_prefix(ri, direction, deref=False):
suffix = f"_{ri.type_name}"
if not ri.op_mode or ri.op_mode == 'do':
suffix += f"{direction_to_suffix[direction]}"
- 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 render_user_family
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def render_user_family(family, cw, prototype):
symbol = f'const struct ynl_family ynl_{family.c_name}_family'
if prototype:
cw.p(f'extern {symbol};')
return
- 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 __init__
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, family, attr_set, attr, value):
super().__init__(family, attr_set, attr, value)
self.byte_order_comment = ''
if 'byte-order' in attr:
- 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 _load_hooks
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _load_hooks(self):
for op in self.ops.values():
for op_mode in ['do', 'dump']:
if op_mode not in op:
continue
- 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 _load_root_sets
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def _load_root_sets(self):
for op_name, op in self.msgs.items():
if 'attribute-set' not in op:
continue
- 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 _print_type
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def _print_type(ri, direction, struct):
suffix = f'_{ri.type_name}{direction_to_suffix[direction]}'
if not direction and ri.type_name_conflict:
suffix += '_'
- 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 __init__
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, family, space_name, type_list=None, inherited=None):
self.family = family
self.space_name = space_name
self.attr_set = family.attr_sets[space_name]
# Use list to catch comparisons with empty sets
- 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 new_attr
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def new_attr(self, elem, value):
if elem['type'] in scalars:
t = TypeScalar(self.family, self, elem, value)
elif elem['type'] == 'unused':
t = TypeUnused(self.family, self, elem, value)
- 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 attr_get
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def attr_get(self, ri, var, first):
lines, init_lines, local_vars = self._attr_get(ri, var)
if type(lines) is str:
lines = [lines]
if type(init_lines) is str:
- 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 write_func_prot
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def write_func_prot(self, qual_ret, name, args=None, doc=None, suffix=''):
if not args:
args = ['void']
if doc:
- 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 print_req_policy_fwd
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def print_req_policy_fwd(cw, struct, ri=None, terminate=True):
if terminate and ri and policy_should_be_static(struct.family):
return
if terminate:
- 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 print_req
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def print_req(ri):
ret_ok = '0'
ret_err = '-1'
direction = "request"
local_vars = ['struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };',
- 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 main
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main():
parser = argparse.ArgumentParser(description='Netlink simple parsing generator')
parser.add_argument('--mode', dest='mode', type=str, required=True)
parser.add_argument('--spec', dest='spec', type=str, required=True)
parser.add_argument('--header', dest='header', action='store_true', default=None)
Function _multi_parse
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _multi_parse(ri, struct, init_lines, local_vars):
if struct.nested:
iter_line = "ynl_attr_for_each_nested(attr, nested)"
else:
if ri.fixed_hdr:
Function render_uapi
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render_uapi(family, cw):
hdr_prot = f"_UAPI_LINUX_{c_upper(family.uapi_header_name)}_H"
cw.p('#ifndef ' + hdr_prot)
cw.p('#define ' + hdr_prot)
cw.nl()
Function p
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def p(self, line, add_ind=0):
if self._block_end:
self._block_end = False
if line.startswith('else'):
line = '} ' + line
- 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 put_op_name
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def put_op_name(family, cw):
map_name = f'{family.c_name}_op_strmap'
cw.block_start(line=f"static const char * const {map_name}[] =")
for op_name, op in family.msgs.items():
if op.rsp_value:
- 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 print_dump
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def print_dump(ri):
direction = "request"
print_prototype(ri, direction, terminate=False)
ri.cw.block_start()
local_vars = ['struct ynl_dump_state yds = {};',
Function resolve
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def resolve(self):
self.resolve_up(super())
if self.yaml.get('protocol', 'genetlink') not in {'genetlink', 'genetlink-c', 'genetlink-legacy'}:
raise Exception("Codegen only supported for genetlink")
- 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 _attr_policy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _attr_policy(self, policy):
if 'flags-mask' in self.checks or self.is_bitfield:
if self.is_bitfield:
enum = self.family.consts[self.attr['enum']]
mask = enum.get_mask(as_flags=True)
- 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 __init__
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, family, attr_set, attr, value):
super().__init__(family, attr_set, attr, value)
self.attr = attr
self.attr_set = attr_set
- 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 not child.recursive:
struct.child_nests.update(child.child_nests)
child.request |= struct.request
Avoid deeply nested control flow statements. Open
if not ri.type_consistent:
parse_rsp_msg(ri, deref=True)
print_req_free(ri)
Avoid deeply nested control flow statements. Open
if struct.request:
put_req_nested_prototype(ri, struct)
if struct.reply:
Avoid deeply nested control flow statements. Open
for op_mode in ['do', 'dump']:
if op_mode in op and 'request' in op[op_mode]:
cw.p(f"/* {op.enum_name} - {op_mode} */")
ri = RenderInfo(cw, parsed, args.mode, op, op_mode)
print_req_policy(cw, ri.struct['request'], ri=ri)
Avoid deeply nested control flow statements. Open
if not ri.type_consistent:
raise Exception(f'Only notifications with consistent types supported ({op.name})')
print_ntf_type_free(ri)
Avoid deeply nested control flow statements. Open
if dont_validate:
members.append(('validate',
' | '.join([c_upper('genl-dont-validate-' + x)
for x in dont_validate])), )
name = c_lower(f"{family.name}-nl-{op_name}-{op_mode}it")
Avoid deeply nested control flow statements. Open
if entry.has_doc():
doc = '@' + entry.c_name + ': ' + entry['doc']
cw.write_doc_line(doc)
cw.p(' */')
Function family_contains_bitfield32
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def family_contains_bitfield32(family):
for _, attr_set in family.attr_sets.items():
if attr_set.subset_of:
continue
for _, attr in attr_set.items():
- 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 not ri.type_consistent:
print_rsp_type(ri)
print_wrapped_type(ri)
Avoid deeply nested control flow statements. Open
if not ri.type_consistent:
raise Exception(f'Only notifications with consistent types supported ({op.name})')
print_wrapped_type(ri)
Avoid deeply nested control flow statements. Open
if struct.reply:
parse_rsp_nested_prototype(ri, struct)
cw.nl()
Avoid deeply nested control flow statements. Open
for x in op['dont-validate']:
if op_mode == 'do' and x in ['dump', 'dump-strict']:
continue
if op_mode == "dump" and x == 'strict':
continue
Avoid deeply nested control flow statements. Open
if op.dual_policy:
name = c_lower(f"{family.name}-{op_name}-{op_mode}-nl-policy")
else:
name = c_lower(f"{family.name}-{op_name}-nl-policy")
members.append(('policy', name))
Avoid deeply nested control flow statements. Open
if 'do' in op and 'event' not in op:
ri = RenderInfo(cw, parsed, args.mode, op, "do")
print_req_policy_fwd(cw, ri.struct['request'], ri=ri)
cw.nl()
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
Function setter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setter(self, ri, space, direction, deref=False, ref=None):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, family, attr_set, attr, value, base_type):
Function setter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setter(self, ri, space, direction, deref=False, ref=None):
Function uapi_enum_start
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def uapi_enum_start(family, cw, obj, ckey='', enum_name='enum-name'):
Function _put_enum_to_str_helper
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _put_enum_to_str_helper(cw, render_name, map_name, arg_name, enum=None):
Function write_func_prot
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def write_func_prot(self, qual_ret, name, args=None, doc=None, suffix=''):
Function setter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setter(self, ri, space, direction, deref=False, ref=None):
Function setter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def setter(self, ri, space, direction, deref=False, ref=None):
Function write_func
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def write_func(self, qual_ret, name, body, args=None, local_vars=None):
Function resolve
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def resolve(self):
self.resolve_up(super())
if 'enum-as-flags' in self.attr and self.attr['enum-as-flags']:
self.is_bitfield = True
- 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 print_dump
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def print_dump(ri):
direction = "request"
print_prototype(ri, direction, terminate=False)
ri.cw.block_start()
local_vars = ['struct ynl_dump_state yds = {};',
- 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 struct_member
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def struct_member(self, ri):
if self.is_multi_val():
ri.cw.p(f"unsigned int n_{self.c_name};")
member = self._complex_member_type(ri)
if member:
- 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 presence_member
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def presence_member(self, space, type_filter):
if self.presence_type() != type_filter:
return
if self.presence_type() == 'bit':
- 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 writes_defines
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def writes_defines(self, defines):
longest = 0
for define in defines:
if len(define[0]) > longest:
longest = len(define[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 _attr_policy
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _attr_policy(self, policy):
if 'exact-len' in self.checks:
mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')'
else:
mem = '{ '
- 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 __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, family, yaml):
self.render_name = c_lower(family.name + '-' + yaml['name'])
if 'enum-name' in yaml:
if yaml['enum-name']:
- 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 f"NLA_POLICY_MAX({policy}, {self.get_limit('max')})"
Avoid too many return
statements within this function. Open
return super()._attr_policy(policy)
Function setter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setter(self, ri, space, direction, deref=False, ref=None):
ref = (ref if ref else []) + [self.c_name]
var = "req"
member = f"{var}->{'.'.join(ref)}"
- 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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, family, yaml):
super().__init__(family, yaml)
if self.subset_of is None:
if 'name-prefix' in yaml:
- 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 _complex_member_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _complex_member_type(self, ri):
if 'type' not in self.attr or self.attr['type'] == 'nest':
return self.nested_struct_type
elif self.attr['type'] in scalars:
scalar_pfx = '__' if ri.ku_space == 'user' 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
Function write_doc_line
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def write_doc_line(self, doc, indent=True):
words = doc.split()
line = ' *'
for word in words:
if len(line) + len(word) >= 79:
- 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 _complex_member_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _complex_member_type(self, ri):
if 'sub-type' not in self.attr or self.attr['sub-type'] == 'nest':
return self.nested_struct_type
elif self.attr['sub-type'] in scalars:
scalar_pfx = '__' if ri.ku_space == 'user' 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"