edgewall/trac

View on GitHub

Showing 1,370 of 1,370 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                          for i in range(len(f)):
                              line = expandtabs(f[i], tabwidth, '\0\1')
                              line = escape(line, quotes=False)
                              line = '<del>'.join(space_re.sub(htmlify, seg)
                                                  for seg in line.split('\0'))
      Severity: Major
      Found in trac/mimeview/patch.py and 1 other location - About 1 day to fix
      trac/mimeview/patch.py on lines 288..296

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 157.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                          for i in range(len(t)):
                              line = expandtabs(t[i], tabwidth, '\0\1')
                              line = escape(line, quotes=False)
                              line = '<ins>'.join(space_re.sub(htmlify, seg)
                                                  for seg in line.split('\0'))
      Severity: Major
      Found in trac/mimeview/patch.py and 1 other location - About 1 day to fix
      trac/mimeview/patch.py on lines 279..287

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 157.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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 _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 _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 _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

              Severity
              Category
              Status
              Source
              Language