edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

Function _render_diff has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def _render_diff(self, req, page):
        if not page.exists:
            raise TracError(_("Version %(num)s of page \"%(name)s\" does not "
                              "exist",
                              num=req.args.get('version'), name=page.name))
Severity: Minor
Found in trac/wiki/web_ui.py - About 3 hrs 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 _reloader_thread has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def _reloader_thread(modification_callback, loop_callback):
    """When this function is run from the main thread, it will force other
    threads to exit when any modules currently loaded change.

    :param modification_callback: a function taking a single argument,
Severity: Minor
Found in trac/util/autoreload.py - About 3 hrs 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_mimetype has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def get_mimetype(filename, content=None, mime_map=MIME_MAP,
                 mime_map_patterns={}):
    """Guess the most probable MIME type of a file with the given name.

    `filename` is either a filename (the lookup will then use the suffix)
Severity: Minor
Found in trac/mimeview/api.py - About 3 hrs 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

File standalone.py has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# Copyright (C) 2003-2005 Jonas Borgström <jonas@edgewall.com>
Severity: Minor
Found in trac/web/standalone.py - About 3 hrs to fix

    WikiModule has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class WikiModule(Component):
    
        implements(IContentConverter, INavigationContributor,
                   IPermissionRequestor, IRequestHandler, ITimelineEventProvider,
                   ISearchSource, ITemplateProvider)
    Severity: Minor
    Found in trac/wiki/web_ui.py - About 3 hrs to fix

      File api.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      #
      # Copyright (C) 2003-2023 Edgewall Software
      # Copyright (C) 2003-2005 Daniel Lundin <daniel@edgewall.com>
      # Copyright (C) 2005-2006 Emmanuel Blot <emmanuel.blot@free.fr>
      Severity: Minor
      Found in trac/notification/api.py - About 3 hrs to fix

        File model.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        #
        # Copyright (C) 2014-2023 Edgewall Software
        # Copyright (C) 2010 Robert Corsaro
        # All rights reserved.
        Severity: Minor
        Found in trac/notification/model.py - About 3 hrs to fix

          Function toggleDir has 87 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            window.toggleDir = function(expander, qargs, autoexpand) {
              var tr = expander.parents("tr:first");
              var folderid = tr.get(0).id;
          
              if (expander.hasClass("expanded")) { // then *fold*
          Severity: Major
          Found in trac/htdocs/js/expand_dir.js - About 3 hrs to fix

            Function get_resource_description has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_resource_description(self, resource, format=None, **kwargs):
                    if resource.realm == self.changeset_realm:
                        parent = resource.parent
                        reponame = parent and parent.id
                        id = resource.id
            Severity: Minor
            Found in trac/versioncontrol/api.py - About 3 hrs 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_link has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def _format_link(self, formatter, ns, pagename, label, ignore_missing,
                                 original_label=None):
                    pagename, query, fragment = formatter.split_link(pagename)
                    version = None
                    if '@' in pagename:
            Severity: Minor
            Found in trac/wiki/api.py - About 3 hrs 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 md5crypt has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            def md5crypt(password, salt, magic='$1$'):
                """Based on FreeBSD src/lib/libcrypt/crypt.c 1.2
            
                :param password: the plain text password to crypt
                :param salt: the raw salt
            Severity: Minor
            Found in trac/util/__init__.py - About 3 hrs 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 __call__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def __call__(self, *args, **kw):
                    href = self.base
                    params = []
            
                    def add_param(name, value):
            Severity: Minor
            Found in trac/web/href.py - About 3 hrs 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 mime_map has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def mime_map(self):
                    # Extend default extension to MIME type mappings with configured ones
                    if not self._mime_map:
                        self._mime_map = MIME_MAP.copy()
                        # augment mime_map from `IHTMLPreviewRenderer`s
            Severity: Minor
            Found in trac/mimeview/api.py - About 3 hrs 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_workflow_config has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            def parse_workflow_config(rawactions):
                """Given a list of options from [ticket-workflow]"""
            
                required_attrs = {
                    'oldstates': [],
            Severity: Minor
            Found in trac/ticket/default_workflow.py - About 3 hrs 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 _change_list has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def _change_list(self, old_list, new_list, new_list2, mode):
                    changed_list = to_list(old_list, self.list_separator_re)
                    new_list = to_list(new_list, self.list_separator_re)
                    new_list2 = to_list(new_list2, self.list_separator_re)
            
            
            Severity: Minor
            Found in trac/ticket/batch.py - About 3 hrs 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 _save_ticket_changes has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def _save_ticket_changes(self, req, selected_tickets, new_values, comment,
                                         action):
                    """Save changes to tickets."""
                    valid = True
                    for manipulator in self.ticket_manipulators:
            Severity: Minor
            Found in trac/ticket/batch.py - About 3 hrs 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 process_request has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_request(self, req):
                    id = req.args.getint('id')
                    req.perm('ticket', id).require('TICKET_ADMIN')
                    ticket = Ticket(self.env, id)
                    action = req.args['action']
            Severity: Minor
            Found in tracopt/ticket/deleter.py - About 3 hrs 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_path_history has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_path_history(self, path, rev=None, limit=None):
                    """Retrieve creation and deletion events that happened on
                    given `path`.
                    """
                    path = self.normalize_path(path)
            Severity: Minor
            Found in tracopt/versioncontrol/svn/svn_fs.py - About 3 hrs 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 remove_jinja_exprs has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            def remove_jinja_exprs(linenum, line, opened_braces):
                """This probably could be a one-liner... ;-)
                """
                idx = 0
                line = line.replace('$', '')
            Severity: Minor
            Found in contrib/jinjachecker.py - About 3 hrs 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

            Repository has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Repository(object, metaclass=ABCMeta):
                """Base class for a repository provided by a version control system."""
            
                has_linear_changesets = False
            
            
            Severity: Minor
            Found in trac/versioncontrol/api.py - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language