Showing 45 of 64 total issues
Function parse_dir
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def parse_dir(dir_path, sort_by = 'line'):
for dirpath, dirs, files in os.walk(dir_path):
for dir in dirs:
# ignore directories beginning by '.'
if str(dir)[0:1] == '.':
- 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 expand_list
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def expand_list(self, list_value, search_in_expand_dict_at_second = None, search_by_pred_at_third = None, list_as_cmdline = False):
if not isinstance(list_value, list):
raise Exception('list_value is not a list type' + str(type(list_value)))
is_list_to_string_convertible = 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 expand_dict
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def expand_dict(self, dict_value, search_in_expand_dict_at_second = None, search_by_pred_at_third = None, ignore_types = None, list_as_cmdline = False):
if not isinstance(dict_value, dict):
raise Exception('dict_value is not a dictionary type' + str(type(dict_value)))
out_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
File tacklelib.yaml.py
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
# pure python module for commands w/o extension modules usage
import os, re, types, copy
class YamlConfig(dict):
Function sync
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def sync(self):
if platform.system() == 'Windows':
prev_stderr = sys.stderr
devnull = tkl.devnull()
with tkl.OnExit(lambda: [None for sys.stderr in [prev_stderr]]):
- 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 tkl_membercopy
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def tkl_membercopy(x, from_globals, to_globals):
#print('membercopy:', x)
if id(from_globals) != id(to_globals):
if inspect.isfunction(x):
return type(x)(x.__code__, to_globals, x.__name__, x.__defaults__, x.__closure__)
- 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
TmpFileIO
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class TmpFileIO:
def __init__(self, mode = 'r', buffering = -1, encoding = None, errors = None, newline = None, closefd = True, opener = None):
self.fd, self.path = tempfile.mkstemp()
self.file = None
try:
Function __setitem__
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def __setitem__(self, key, value):
if platform.system() == 'Windows':
prev_stderr = sys.stderr
devnull = tkl.devnull()
with tkl.OnExit(lambda: [None for sys.stderr in [prev_stderr]]):
- 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 __getitem__
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def __getitem__(self, key):
if platform.system() == 'Windows':
prev_stderr = sys.stderr
devnull = tkl.devnull()
with tkl.OnExit(lambda: [None for sys.stderr in [prev_stderr]]):
- 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 tkl_get_stack_frame_module_by_name
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def tkl_get_stack_frame_module_by_name(name = '<module>'):
target_module = None
# search for the first module in the stack
stack_frame = inspect.currentframe()
- 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_max
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def print_max(str, max_lines = 9):
if max_lines >= 0:
num_new_lines = str.count('\n')
if num_new_lines > max_lines:
line_index = 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 __init__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, appname, flag='c', mode=0o666, keyencoding='utf-8',
serialize=True, app_cache_dir=None):
"""Initialize a :class:`FileCache` object."""
if not isinstance(flag, str):
raise TypeError("flag must be str not '{}'".format(type(flag)))
- 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 tkl_get_method_class
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def tkl_get_method_class(x, from_module = None):
if inspect.ismethod(x):
for cls in inspect.getmro(x.__self__.__class__):
if cls.__dict__.get(x.__name__) is x:
return cls
- 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 tkl_classcopy
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def tkl_classcopy(x, from_globals, to_globals):
if not inspect.isclass(x):
raise Exception('x must be a class: ' + type(x))
cls_copy = type(x.__name__, x.__bases__, dict(x.__dict__))
- 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 tkl_get_stack_frame_module_by_offset
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def tkl_get_stack_frame_module_by_offset(skip_stack_frames = 0, use_last_frame_on_out_of_stack = False):
skip_frame_index = skip_stack_frames + 1;
# search for the first module in the stack
last_stack_frame = stack_frame = inspect.currentframe()
- 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 tkl_import_module
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tkl_import_module(dir_path, module_file_name, ref_module_name = None, inject_attrs = {}, prefix_exec_module_pred = None, skip_stack_frames = 0, reimport_if_being_imported = False):
if not ref_module_name is None and ref_module_name == '':
raise Exception('ref_module_name should either be None or not empty string')
module_file_path = os.path.normcase(os.path.abspath(os.path.join(dir_path, module_file_name))).replace('\\', '/')
Function rename
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def rename(src, dst):
# Try atomic or pseudo-atomic rename
if _rename(src, dst):
return
# Fall back to "move away and replace"
- 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
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def load(self, yaml_dict):
if not isinstance(yaml_dict, dict):
raise Exception('yaml_dict is not a dictionary object')
if len(self.unexpanded_stack) == 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 __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, appname, flag = 'c', mode = 438, keyencoding = 'utf-8', serialize = True, app_cache_dir = None, no_logger_warnings = True):
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, mode = 'r', buffering = -1, encoding = None, errors = None, newline = None, closefd = True, opener = None):