Showing 18 of 30 total issues
Function parse_file
has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring. Open
def parse_file(self, config_file):
LOGGER.debug('Loading the config file "%s"', config_file)
config_parser = configparser.ConfigParser()
- Read upRead up
- Create a ticketCreate a ticket
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 filter.py
has 528 lines of code (exceeds 250 allowed). Consider refactoring. Open
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
- Create a ticketCreate a ticket
Function run
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def run(self):
stdin_fd = sys.stdin.fileno()
stdout_fd = sys.stdout.fileno()
stderr_fd = sys.stderr.fileno()
- Read upRead up
- Create a ticketCreate a ticket
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
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run(self):
for path in self.paths:
if path and os.path.isdir(path):
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)):
- Read upRead up
- Create a ticketCreate a ticket
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 locate_config_file
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def locate_config_file(self, config, working_directory=None):
LOGGER.debug('Trying to find config "%s"', config)
config_file = self.locate_config_file_in_directory(os.getcwd(), config)
- Read upRead up
- Create a ticketCreate a ticket
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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def main(args=None):
logger_console_handler = logging.StreamHandler(sys.stderr)
try:
logger_console_handler.setFormatter(Formatter("%(levelname)s %(message)s"))
logging.addLevelName(logging.CRITICAL, 'rainbow error:')
- Read upRead up
- Create a ticketCreate a ticket
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 lines[-1]:
os.write(write_fd, self.encode(transformer.transform(lines[-1])))
buffers[read_fd] = lines[-1]
else:
buffers[read_fd] = ''
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if not value:
self.error_handler('Empty imports section in config "%s"' % config_file)
else:
for config_import in [v.strip() for v in value.split(',')]:
if not config_import:
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
for line in lines[:-1]:
os.write(write_fd, self.encode(transformer.transform(line) + '\n'))
if lines[-1]:
- Create a ticketCreate a ticket
Function run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run(self):
clean.run(self)
if self.all:
for path in [path.strip() for path in self.paths.split(',')]:
if os.path.isdir(path):
- Read upRead up
- Create a ticketCreate a ticket
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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, name, help, short_option=None, long_option=None, before=None, after=None):
- Create a ticketCreate a ticket
Function __init__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self,
paths=None,
stdout_builder=None,
stderr_builder=None,
error_handler=lambda error: None):
- Read upRead up
- Create a ticketCreate a ticket
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 enable_stderr_filtering:
self.stderr_builder.add_mapping(pattern, resolved_filter)
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
for read_fd in buffers:
buffers[read_fd] = ''
else:
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if lines[0] and buffers[read_fd]:
os.write(write_fd, self.encode('\r'))
for line in lines[:-1]:
- Create a ticketCreate a ticket
Function find_config_name_from_command_line
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_config_name_from_command_line(command_line_args):
for arg in command_line_args:
if arg[0] != '-':
basename = os.path.basename(arg)
if basename not in PRECOMMANDS:
- Read upRead up
- Create a ticketCreate a ticket
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 parse_args
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_args(self, args=None, values=None):
try:
(values, remaining_args) = OptionParser.parse_args(self, args=args)
except SystemExit:
- Read upRead up
- Create a ticketCreate a ticket
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 makeparentdirs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def makeparentdirs(path):
directory = os.path.dirname(path)
if not os.path.exists(directory): # no cover
try:
os.makedirs(directory)
- Read upRead up
- Create a ticketCreate a ticket
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"