edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

Consider simplifying this complex logical expression.
Open

            if 'add' in req.args and subject and action:
                req.perm('admin', 'general/perm').require('PERMISSION_GRANT')
                if action not in all_actions:
                    raise TracError(_("Unknown action"))
                req.perm.require(action)
Severity: Critical
Found in trac/admin/web_ui.py - About 1 hr to fix

    Function process_request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def process_request(self, req):
            """The appropriate mode of operation is inferred from the request
            parameters:
    
             * If `new_path` and `old_path` are equal (or `old_path` is omitted)
    Severity: Minor
    Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr to fix

      Function _extend_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _extend_info(self, reponame, info, editable):
              """Extend repository info for rendering."""
              info['name'] = reponame
              info['hidden'] = as_bool(info.get('hidden'))
              info['sync_per_request'] = as_bool(info.get('sync_per_request'))
      Severity: Minor
      Found in trac/versioncontrol/admin.py - About 1 hr to fix

      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 wikisyntax_test_suite has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def wikisyntax_test_suite(data=None, setup=None, file=None, teardown=None,
      Severity: Major
      Found in trac/wiki/test.py - About 1 hr to fix

        Function _load_or_replace has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _load_or_replace(self, paths, replace):
                with self.env.db_transaction:
                    for path in paths:
                        if os.path.isdir(path):
                            for page in sorted(os.listdir(path)):
        Severity: Minor
        Found in trac/wiki/admin.py - About 1 hr to fix

        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 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def parse_args(args, strict=True):
            r"""Utility for parsing macro "content" and splitting them into arguments.
        
            The content is split along commas, unless they are escaped with a
            backquote (see example below).
        Severity: Minor
        Found in trac/wiki/api.py - About 1 hr to fix

        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 _format_datetime_babel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def _format_datetime_babel(t, format, locale, hint):
            if hint in ('datetime', 'date'):
                datepart = babel_format_date(t, format, locale)
                if hint == 'date':
                    return datepart
        Severity: Minor
        Found in trac/util/datefmt.py - About 1 hr to fix

        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 _do_delete has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _do_delete(self, req, page):
                req.perm(page.resource).require('WIKI_DELETE')
        
                if 'cancel' in req.args:
                    req.redirect(get_resource_url(self.env, page.resource, req.href))
        Severity: Minor
        Found in trac/wiki/web_ui.py - About 1 hr to fix

        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 append has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def append(self, arg):
                if arg: # ignore most false values (None, False, [], (), ''), except 0!
                    if isinstance(arg, (Fragment, str, bytes, int, float)):
                        self.children.append(arg)
                    else:
        Severity: Minor
        Found in trac/util/html.py - About 1 hr to fix

        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 __str__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def __str__(self):
                elt = '<' + self.tag
                if self.attrib:
                    # Sorting the attributes makes the unit-tests more robust
                    attrs = []
        Severity: Minor
        Found in trac/util/html.py - About 1 hr to fix

        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_module_metadata has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_module_metadata(module):
            """Get a dictionary containing metadata for a module."""
            info = {}
            for k in ('author', 'author_email', 'maintainer',
                      'maintainer_email', 'home_page', 'url', 'license',
        Severity: Minor
        Found in trac/util/__init__.py - About 1 hr to fix

        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_lines_from_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_lines_from_file(filename, lineno, context=0, globals=None):
            """Return `content` number of lines before and after the specified
            `lineno` from the (source code) file identified by `filename`.
        
            Returns a `(lines_before, line, lines_after)` tuple.
        Severity: Minor
        Found in trac/util/__init__.py - About 1 hr to fix

        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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, default_data=False, enable=None, disable=None,
                         path=None, destroying=False, config=None):
                """Construct a new Environment stub object.
        
                :param default_data: If True, populate the database with some
        Severity: Minor
        Found in trac/test.py - About 1 hr to fix

        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_if_needed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_if_needed(self, force=False):
                if not self.filename or not self.exists:
                    return False
        
                changed = False
        Severity: Minor
        Found in trac/config.py - About 1 hr to fix

        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 _do_add has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _do_add(self, user, *actions):
                permsys = PermissionSystem(self.env)
                if user.isupper():
                    raise AdminCommandError(_("All upper-cased tokens are reserved "
                                              "for permission names"))
        Severity: Minor
        Found in trac/perm.py - About 1 hr to fix

        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 _do_login has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _do_login(self, req):
                """Log the remote user in.
        
                This function expects to be called when the remote user name
                is available. The user name is inserted into the `auth_cookie`
        Severity: Minor
        Found in trac/web/auth.py - About 1 hr to fix

        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 _start_response has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _start_response(self, status, headers, exc_info=None):
                """Callback for starting a HTTP response."""
                if exc_info:
                    try:
                        if self.headers_sent: # Re-raise original exception
        Severity: Minor
        Found in trac/web/wsgi.py - About 1 hr to fix

        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 send_project_index has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def send_project_index(environ, start_response, parent_dir=None,
                               env_paths=None):
            req = Request(environ, start_response)
        
            loadpaths = [pkg_resources.resource_filename('trac', 'templates')]
        Severity: Minor
        Found in trac/web/main.py - About 1 hr to fix

        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 insert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def insert(self, when=None):
                """Add ticket to database.
                """
                assert not self.exists, 'Cannot insert an existing ticket'
        
        
        Severity: Minor
        Found in trac/ticket/model.py - About 1 hr to fix

        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_logo_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_logo_data(self, href, abs_href=None):
                # TODO: Possibly, links to 'common/' could use chrome.htdocs_location
                logo = {}
                logo_src = self.logo_src
                if logo_src:
        Severity: Minor
        Found in trac/web/chrome.py - About 1 hr to fix

        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

        Severity
        Category
        Status
        Source
        Language