Function get_sql
has a Cognitive Complexity of 191 (exceeds 5 allowed). Consider refactoring. Open
def get_sql(self, req=None, cached_ids=None, authname=None):
"""Return a (sql, params) tuple for the query.
"""
if req is not None:
authname = req.authname
- 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 query.py
has 1284 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
#
# Copyright (C) 2004-2023 Edgewall Software
# Copyright (C) 2004-2005 Christopher Lenz <cmlenz@gmx.de>
# Copyright (C) 2005-2007 Christian Boos <cboos@edgewall.org>
Function _get_constraints
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
def _get_constraints(self, req=None, arg_list=[]):
fields = TicketSystem(self.env).get_ticket_fields()
synonyms = TicketSystem(self.env).get_field_synonyms()
fields = {f['name']: f for f in fields}
fields['id'] = {'type': 'id'}
- 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 template_data
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
def template_data(self, context, tickets, orig_list=None, orig_time=None,
req=None):
clauses = []
for clause in self.constraints:
constraints = {}
- 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 process_request
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def process_request(self, req):
req.perm(self.realm).require('TICKET_VIEW')
report_id = req.args.as_int('report')
if report_id:
req.perm('report', report_id).require('REPORT_VIEW')
- 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_macro
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def expand_macro(self, formatter, name, content):
req = formatter.req
query_string, kwargs, format = self.parse_args(content)
if query_string:
query_string += '&'
- 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 _export_csv
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def _export_csv(self, req, query, sep=',', mimetype='text/plain'):
def iterate():
out = io.BytesIO()
writer = csv.writer(io.TextIOWrapper(out, encoding='utf-8',
newline='\n',
- 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 execute
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def execute(self, req=None, cached_ids=None, authname=None, href=None):
"""Retrieve the list of matching tickets.
"""
if req is not None:
href = req.href
- 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 26 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, env, report=None, constraints=None, cols=None,
order=None, desc=0, group=None, groupdesc=0, verbose=0,
rows=None, page=None, max=None, format=None):
self.env = env
self.id = report # if not None, it's the corresponding saved query
- 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 get_default_columns
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def get_default_columns(self):
cols = self.get_all_columns()
# Semi-intelligently remove columns that are restricted to a single
# value by a query constraint.
- 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 from_string
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def from_string(cls, env, string, **kw):
kw_strs = ['order', 'group', 'page', 'max', 'format']
kw_arys = ['rows']
kw_bools = ['desc', 'groupdesc', 'verbose']
kw_synonyms = {'row': 'rows'}
- 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 parse_args
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def parse_args(content):
"""Parse macro arguments and translate them to a query string."""
clauses = [{}]
argv = []
kwargs = {}
- 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 get_href
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_href(self, href, id=None, order=None, desc=None, format=None,
max=None, page=None):
"""Create a link corresponding to this query.
:param href: the `Href` object used to build the URL
- 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 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, env, report=None, constraints=None, cols=None,
Function display_html
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def display_html(self, req, query):
# The most recent query is stored in the user session;
orig_list = None
orig_time = datetime_now(utc)
query_time = req.session.as_int('query_time', 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 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, env, report=None, constraints=None, cols=None,
order=None, desc=0, group=None, groupdesc=0, verbose=0,
rows=None, page=None, max=None, format=None):
self.env = env
self.id = report # if not None, it's the corresponding saved query
Function display_html
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def display_html(self, req, query):
# The most recent query is stored in the user session;
orig_list = None
orig_time = datetime_now(utc)
query_time = req.session.as_int('query_time', 0)
Function get_all_columns
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_all_columns(self):
# Prepare the default list of columns
cols = ['id']
cols += [f['name'] for f in self.fields if f['type'] != 'textarea']
for col in ('reporter', 'keywords', 'cc'):
- 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 get_href
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_href(self, href, id=None, order=None, desc=None, format=None,
Avoid deeply nested control flow statements. Open
if 0 <= idx < len(vals):
del vals[idx]
if not vals:
continue
else:
Avoid deeply nested control flow statements. Open
if ends:
vals = [start + '..' + end
for (start, end) in zip(vals, ends)]
if k in remove_constraints:
Avoid deeply nested control flow statements. Open
if not word:
continue
clauses.append("COALESCE(%s,'') %s%s" % (col, cneg,
Avoid deeply nested control flow statements. Open
if user:
vals[i] = val.replace('$USER', user)
elif val.endswith('$USER'):
del clause[field]
break
Avoid deeply nested control flow statements. Open
if a == b:
ids.append(str(a))
else:
id_clauses.append('t.id BETWEEN %s AND %s')
args.append(a)
Avoid deeply nested control flow statements. Open
if href is not None:
result['href'] = href.ticket(val)
elif name in self.time_fields:
Function template_data
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def template_data(self, context, tickets, orig_list=None, orig_time=None,
Avoid too many return
statements within this function. Open
return tag.span(_("No results"), class_='query_no_results')
Avoid too many return
statements within this function. Open
return (('NOT ' if neg else '')
Avoid too many return
statements within this function. Open
return tag.span(alist[0], *[(', ', a) for a in alist[1:]])
Avoid too many return
statements within this function. Open
return tag.div(tag.dl([(tag.dt(ticket_anchor(ticket)),
Avoid too many return
statements within this function. Open
return ("COALESCE(%s,'') %s%s" % (col, 'NOT ' if neg else '',
Avoid too many return
statements within this function. Open
return tag.div(
Avoid too many return
statements within this function. Open
return tag(groups[0], [(', ', g) for g in groups[1:]])
Avoid too many return
statements within this function. Open
return ("COALESCE(%s,'')%s=%%s"
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return tag.div(