edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

Function _process_ticket_request has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

    def _process_ticket_request(self, req):
        id = req.args.getint('id')
        version = req.args.getint('version', None)

        if req.is_xhr and 'preview_comment' in req.args:
Severity: Minor
Found in trac/ticket/web_ui.py - About 1 day 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 text.py has 652 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# Copyright (C) 2003-2004 Jonas Borgström <jonas@edgewall.com>
# Copyright (C) 2006 Matthew Good <trac@matt-good.net>
Severity: Major
Found in trac/util/text.py - About 1 day to fix

    Function expand_macro has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
    Open

        def expand_macro(self, formatter, name, content):
            args, kw = parse_args(content)
            prefix = args[0].strip() if args else None
            hideprefix = args and len(args) > 1 and args[1].strip() == 'hideprefix'
            minsize = _arg_as_int(kw.get('min', 1), 'min', min=1)
    Severity: Minor
    Found in trac/wiki/macros.py - About 1 day 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 notification.py has 628 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: Major
    Found in trac/ticket/notification.py - About 1 day to fix

      Function check_permission has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_permission(self, action, username, resource, perm):
              realm = resource.realm if resource else None
              if (realm, action) in self._handled_perms:
                  authz, users = self._get_authz_info()
                  if authz is None:
      Severity: Minor
      Found in trac/versioncontrol/svn_authz.py - About 1 day 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_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'}
      Severity: Minor
      Found in trac/ticket/query.py - About 1 day 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

      Formatter has 72 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Formatter(object):
          """Base Wiki formatter.
      
          Parses and formats wiki text, in a given `RenderingContext`.
          """
      Severity: Major
      Found in trac/wiki/formatter.py - About 1 day to fix

        Function _prepare_fields has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
        Open

            def _prepare_fields(self, req, ticket, field_changes=None):
                context = web_context(req, ticket.resource)
                fields = TicketFieldList()
                for field in ticket.fields:
                    name = field['name']
        Severity: Minor
        Found in trac/ticket/web_ui.py - About 1 day 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 api.py has 605 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>
        # All rights reserved.
        Severity: Major
        Found in trac/ticket/api.py - About 1 day to fix

          Function render_ticket_action_control has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
          Open

              def render_ticket_action_control(self, req, ticket, action):
          
                  self.log.debug('render_ticket_action_control: action "%s"', action)
          
                  this_action = self.actions[action]
          Severity: Minor
          Found in trac/ticket/default_workflow.py - About 1 day 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 api.py has 586 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          #
          # Copyright (C) 2005-2023 Edgewall Software
          # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
          # All rights reserved.
          Severity: Major
          Found in trac/db/api.py - About 1 day to fix

            Function process_request has a Cognitive Complexity of 63 (exceeds 5 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 day 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 default_workflow.py has 566 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            #
            # Copyright (C) 2006-2023 Edgewall Software
            # Copyright (C) 2006 Alec Thomas
            # Copyright (C) 2007 Eli Carter
            Severity: Major
            Found in trac/ticket/default_workflow.py - About 1 day to fix

              Function check_jinja has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
              Open

              def check_jinja(filename, line_statements, quiet):
                  """Verifies proper nesting of Jinja2 control structures.
                  """
                  print("\n# -- Jinja2 check for '%s'" % filename)
                  kw_stack = []
              Severity: Minor
              Found in contrib/jinjachecker.py - About 1 day 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_ticket_data has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _insert_ticket_data(self, req, ticket, data, author_id, field_changes):
                      """Insert ticket data into the template `data`"""
                      replyto = req.args.get('replyto')
                      data['replyto'] = replyto
                      data['version'] = ticket.resource.version
              Severity: Minor
              Found in trac/ticket/web_ui.py - About 1 day 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 _render_admin_panel has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _render_admin_panel(self, req, cat, page, milestone_name):
                      perm_cache = req.perm('admin', 'ticket/' + self._type)
              
                      # Detail view
                      if milestone_name:
              Severity: Minor
              Found in trac/ticket/admin.py - About 1 day 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_plaintext has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _format_plaintext(self, event):
                      """Format ticket change notification e-mail (untranslated)"""
                      ticket = event.target
                      newticket = event.category == 'created'
                      with translation_deactivated(ticket):
              Severity: Minor
              Found in trac/ticket/notification.py - About 1 day 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 check_html has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
              Open

              def check_html(filename, html_lines, html_hints, quiet, show_ignored):
                  """Validates the given HTML (as XHTML actually)
                  """
                  global etree
                  print("\n# -- HTML check for '%s'" % filename)
              Severity: Minor
              Found in contrib/jinjachecker.py - About 1 day 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 render_admin_panel has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
              Open

                  def render_admin_panel(self, req, cat, page, path_info):
                      perm = PermissionSystem(self.env)
                      all_actions = perm.get_actions()
              
                      if req.method == 'POST':
              Severity: Minor
              Found in trac/admin/web_ui.py - About 1 day 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 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 = {}
              Severity: Minor
              Found in trac/ticket/query.py - About 1 day 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