edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

Function match_plugins_to_frames has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

def match_plugins_to_frames(plugins, frames):
    """Add a `frame_idx` element to plugin information as returned by
    `get_plugin_info()`, containing the index of the highest frame in the
    list that was located in the plugin.
    """
Severity: Minor
Found in trac/loader.py - About 5 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 handler has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def handler(self, req):
        """Special handler for WSGI."""
        if req.role != FCGI_RESPONDER:
            return FCGI_UNKNOWN_ROLE, 0

Severity: Minor
Found in trac/web/_fcgi.py - About 5 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 validate_ticket has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_ticket(self, req, ticket):
        # Validate select fields for known values.
        for field in ticket.fields:
            if 'options' not in field:
                continue
Severity: Minor
Found in trac/ticket/api.py - About 5 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 _validate_ticket has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def _validate_ticket(self, req, ticket, force_collision_check=False):
        valid = True
        resource = ticket.resource

        # If the ticket has been changed, check the proper permissions
Severity: Minor
Found in trac/ticket/web_ui.py - About 5 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 render_property_diff has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def render_property_diff(self, name, old_context, old_props,
                             new_context, new_props, options):
        # Build 5 columns table showing modifications on merge sources
        # || source || added || removed || added (ni) || removed (ni) ||
        # || source || removed                                        ||
Severity: Minor
Found in tracopt/versioncontrol/svn/svn_prop.py - About 5 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 auth.py has 376 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: Minor
Found in trac/web/auth.py - About 5 hrs to fix

    Request has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Request(object):
        """Represents a HTTP request/response pair.
    
        This class provides a convenience API over WSGI.
        """
    Severity: Minor
    Found in trac/web/api.py - About 5 hrs to fix

      Function sync has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def sync(self, feedback=None, clean=False):
              if clean:
                  self.remove_cache()
      
              metadata = self.metadata
      Severity: Minor
      Found in trac/versioncontrol/cache.py - About 4 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 _set_quote_depth has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def _set_quote_depth(self, depth, citation=False):
              def open_quote(depth):
                  self.close_table()
                  self.close_paragraph()
                  self.close_list()
      Severity: Minor
      Found in trac/wiki/formatter.py - About 4 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 _wrap_chunks has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def _wrap_chunks(self, chunks):
              lines = []
              chunks.reverse()
              text_width = self._text_width
      
      
      Severity: Minor
      Found in trac/util/text.py - About 4 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 _render_admin_panel has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def _render_admin_panel(self, req, cat, page, version):
              # Detail view?
              if version:
                  ver = model.Version(self.env, version)
                  if req.method == 'POST':
      Severity: Minor
      Found in trac/ticket/admin.py - About 4 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_historian has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_historian(self, sha, base_path):
              p = []
              change = {}
              next_path = []
              base_path = self._fs_from_unicode(base_path) or '.'
      Severity: Minor
      Found in tracopt/versioncontrol/git/PyGIT.py - About 4 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_changes has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_changes(self):
              """Retrieve file changes for a given revision.
      
              (wraps ``repos.svn_repos_replay``)
              """
      Severity: Minor
      Found in tracopt/versioncontrol/svn/svn_fs.py - About 4 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 jinjachecker.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python3
      # -*- coding: utf-8 -*-
      #
      # Copyright (C) 2016-2023 Edgewall Software
      # All rights reserved.
      Severity: Minor
      Found in contrib/jinjachecker.py - About 4 hrs to fix

        Function unified_diff has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        def unified_diff(fromlines, tolines, context=None, ignore_blank_lines=0,
                         ignore_case=0, ignore_space_changes=0):
            """Generator producing lines corresponding to a textual diff.
        
            See `get_filtered_hunks` for the parameter descriptions.
        Severity: Minor
        Found in trac/versioncontrol/diff.py - About 4 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 handle_code_block has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_code_block(self, line, startmatch=None):
                if startmatch:
                    self.in_code_block += 1
                    if self.in_code_block == 1:
                        name = startmatch.group(2)
        Severity: Minor
        Found in trac/wiki/formatter.py - About 4 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 decorate_message has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            def decorate_message(self, event, message, charset):
                if event.realm != 'ticket':
                    return
                from_email = self._get_from_email(event)
                if event.category == 'batchmodify':
        Severity: Minor
        Found in trac/ticket/notification.py - About 4 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 presentation.py has 364 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        #
        # Copyright (C) 2006-2023 Edgewall Software
        # Copyright (C) 2006 Christopher Lenz <cmlenz@gmx.de>
        # All rights reserved.
        Severity: Minor
        Found in trac/util/presentation.py - About 4 hrs to fix

          File db_default.py has 364 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>
          # All rights reserved.
          Severity: Minor
          Found in trac/db_default.py - About 4 hrs to fix

            Function babel has 117 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var babel = new function() {
            
              var defaultPluralExpr = function(n) { return n == 1 ? 0 : 1; };
              var formatRegex = /%(?:(?:\(([^\)]+)\))?([disr])|%)/g;
              var translations = {};
            Severity: Major
            Found in trac/htdocs/js/babel.js - About 4 hrs to fix
              Severity
              Category
              Status
              Source
              Language