File browser.py
has 834 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# Copyright (C) 2003-2005 Jonas Borgström <jonas@edgewall.com>
# Copyright (C) 2005-2007 Christian Boos <cboos@edgewall.org>
Function process_request
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
def process_request(self, req):
presel = req.args.get('preselected')
if presel and (presel + '/').startswith(req.href.browser() + '/'):
req.redirect(presel)
- 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_repository_index
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def _render_repository_index(self, context, all_repositories, order, desc):
# Color scale for the age column
timerange = custom_colorizer = None
if self.color_scale:
custom_colorizer = self.get_custom_colorizer()
- 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
BrowserModule
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class BrowserModule(Component):
implements(INavigationContributor, IPermissionRequestor, IRequestHandler,
IWikiSyntaxProvider, IHTMLPreviewAnnotator,
IWikiMacroProvider)
Function _render_dir
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _render_dir(self, req, repos, node, rev, order, desc):
req.perm(node.resource).require('BROWSER_VIEW')
download_href = self._get_download_href
# Entries metadata
- 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_file
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _render_file(self, req, context, repos, node, rev=None):
req.perm(node.resource).require('FILE_VIEW')
mimeview = Mimeview(self.env)
- 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_property
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def render_property(self, name, mode, context, props):
"""Renders a node property to HTML."""
if name in self.hidden_properties:
return
candidates = []
- 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_custom_colorizer
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_custom_colorizer(self):
"""Returns a converter for values from [0.0, 1.0] to a RGB triple."""
def interpolate(old, new, value):
# Provides a linearly interpolated color triple for `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 match_request
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def match_request(self, req):
match = re.match(r'/(export|browser|file)(/.*)?$', req.path_info)
if match:
mode, path = match.groups()
if mode == 'export':
- 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 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_request(self, req):
presel = req.args.get('preselected')
if presel and (presel + '/').startswith(req.href.browser() + '/'):
req.redirect(presel)
Function expand_macro
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def expand_macro(self, formatter, name, content):
args, kwargs = parse_args(content)
format = kwargs.get('format', 'compact')
glob = kwargs.get('glob', '*')
order = kwargs.get('order')
- 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 annotate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def annotate(self, row, lineno):
if lineno > len(self.annotations):
row.append(tag.th())
return
rev = self.annotations[lineno-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 annotate_row
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def annotate_row(self, context, row, lineno, line, blame_annotator):
Function _render_dir
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _render_dir(self, req, repos, node, rev, order, desc):
Function _render_zip
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _render_zip(self, req, context, repos, root_node, rev=None):
Function _render_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _render_file(self, req, context, repos, node, rev=None):
Function _get_download_href
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_download_href(self, href, repos, node, rev):
Function render_property
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render_property(self, name, mode, context, props):
Function _format_browser_link
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _format_browser_link(self, formatter, ns, path, label):
Function _format_export_link
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _format_export_link(self, formatter, ns, export, label):
Function _get_link_info
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_link_info(self, path, rev, href, perm):