Showing 1,050 of 1,372 total issues
Function to_utf8
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_utf8(text, charset='latin1'):
"""Convert input to a UTF-8 `bytes` object.
If the input is not an `str` object, we assume the encoding is
already UTF-8, ISO Latin-1, or as specified by the optional
- 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
while index >= len(messages):
messages.append(None)
messages[index - 1] = message
Function _from_database
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _from_database(self, id, sid, authenticated, class_, realm, target):
Function _do_install
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _do_install(self, req):
"""Install a plugin."""
if 'plugin_file' not in req.args:
raise TracError(_("No file uploaded"))
upload = req.args['plugin_file']
- 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 dt.month < 12:
dt = dt.replace(month=dt.month + 1)
else:
dt = dt.replace(year=dt.year + 1, month=1)
elif start == 'year':
Avoid deeply nested control flow statements. Open
if name not in func_kwargs_map:
continue
index = func_kwargs_map[name]
Avoid deeply nested control flow statements. Open
if dt.month > 1:
dt = dt.replace(month=dt.month - 1)
else:
dt = dt.replace(year=dt.year - 1, month=12)
elif start == 'year':
Function groupattr_filter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def groupattr_filter(_eval_ctx, iterable, num, attr, *args, **kwargs):
Avoid deeply nested control flow statements. Open
if left_space < w:
break
left_space -= w
Avoid deeply nested control flow statements. Open
if info[k] == 'UNKNOWN':
info[k] = ''
else:
# Must be encoded as unicode as otherwise Genshi
# may raise a "UnicodeDecodeError".
Function reset_db
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def reset_db(self, default_data=None):
"""Remove all data from Trac tables, keeping the tables themselves.
:param default_data: after clean-up, initialize with default data
:return: True upon success
- 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 destroy_db
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def destroy_db(self, path, log=None, params={}):
if path != ':memory:':
if not os.path.isabs(path):
path = os.path.join(self.env.path, path)
try:
- 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 col.auto_increment:
db.update_sequence(cursor, new_table.name,
col.name)
self.drop_tables((temp_table_name,))
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, default_data=False, enable=None, disable=None,
Function to_sql
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def to_sql(self, table, max_bytes=None):
if max_bytes is None:
max_bytes = self._max_bytes(None)
sql = ['CREATE TABLE %s (' % _quote(table.name)]
coldefs = []
- 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 _collist
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _collist(self, table, columns, max_bytes):
"""Take a list of columns and impose limits on each so that indexing
works properly.
Some Versions of MySQL limit each index prefix to 3072 bytes total,
- 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 backup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def backup(self, dest_file):
db_url = self.env.config.get('trac', 'database')
scheme, db_prop = parse_connection_uri(db_url)
db_params = db_prop.setdefault('params', {})
db_params.setdefault('schema', 'public')
- 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 copy_tables
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def copy_tables(src_env, dst_env, src_db, dst_db, src_dburi, dst_dburi):
Avoid deeply nested control flow statements. Open
if isinstance(option, Option):
set_option_default(option)
else:
Function find_by_sid_class_realm_and_target
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_by_sid_class_realm_and_target(cls, env, sid, authenticated,