edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

Function get_pkginfo has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

def get_pkginfo(dist):
    """Get a dictionary containing package information for a package

    `dist` can be either a Distribution instance or, as a shortcut,
    directly the module instance, if one can safely infer a Distribution
Severity: Minor
Found in trac/util/__init__.py - About 6 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_ics has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def _render_ics(self, req, milestones):
        req.send_response(200)
        req.send_header('Content-Type', 'text/calendar;charset=utf-8')
        buf = io.StringIO()

Severity: Minor
Found in trac/ticket/roadmap.py - About 6 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 has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def render_property(self, name, mode, context, props):
        """Parse svn:mergeinfo and svnmerge-* properties, converting branch
        names to links and providing links to the revision log for merged
        and eligible revisions.
        """
Severity: Minor
Found in tracopt/versioncontrol/svn/svn_prop.py - About 6 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 console.py has 450 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# All rights reserved.
Severity: Minor
Found in trac/admin/console.py - About 6 hrs to fix

    Function _parse_relative_time has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_relative_time(text, tzinfo, now=None):
        if now is None:     # now argument for unit tests
            now = datetime_now(tzinfo)
        if text == 'now':
            return now
    Severity: Minor
    Found in trac/util/datefmt.py - About 6 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 mysql_backend.py has 445 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    #
    # Copyright (C) 2005-2023 Edgewall Software
    # Copyright (C) 2005-2006 Christopher Lenz <cmlenz@gmx.de>
    # Copyright (C) 2005 Jeff Weiss <trac@jeffweiss.org>
    Severity: Minor
    Found in trac/db/mysql_backend.py - About 6 hrs to fix

      TicketModule has 47 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class TicketModule(Component):
      
          implements(IContentConverter, INavigationContributor, IRequestHandler,
                     ISearchSource, ITemplateProvider, ITimelineEventProvider)
      
      
      Severity: Minor
      Found in trac/ticket/web_ui.py - About 6 hrs to fix

        Storage has 47 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Storage(object):
            """High-level wrapper around GitCore with in-memory caching"""
        
            __SREV_MIN = 4 # minimum short-rev length
        
        
        Severity: Minor
        Found in tracopt/versioncontrol/git/PyGIT.py - About 6 hrs to fix

          File query.js has 433 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Create and modify custom queries (incl. support for batch modification)
          
          (function($){
          
            // Create a <label>
          Severity: Minor
          Found in trac/htdocs/js/query.js - About 6 hrs to fix

            File log.py has 431 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>
            # Copyright (C) 2005-2006 Christian Boos <cboos@edgewall.org>
            Severity: Minor
            Found in trac/versioncontrol/web_ui/log.py - About 6 hrs to fix

              Function post_process_request has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  def post_process_request(self, req, template, data, metadata):
                      if data:
                          def pretty_dateinfo(date, format=None, dateonly=False):
                              if not date:
                                  return ''
              Severity: Minor
              Found in trac/timeline/web_ui.py - About 6 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 execute_paginated_report has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  def execute_paginated_report(self, req, id, sql, args, limit=0, offset=0):
                      """
                      :param req: `Request` object.
                      :param id: Integer id of the report.
                      :param sql: SQL query that generates the report.
              Severity: Minor
              Found in trac/ticket/report.py - About 6 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_externals has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _render_externals(self, prop):
                      if not self._externals_map:
                          for dummykey, value in self.svn_externals_section.options():
                              value = value.split()
                              if len(value) != 2:
              Severity: Minor
              Found in tracopt/versioncontrol/svn/svn_prop.py - About 6 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 expand_macro has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
              Open

                  def expand_macro(self, formatter, name, content):
                      content = content.strip() if content else ''
                      name_filter = content.strip('*')
              
                      def get_macro_descr():
              Severity: Minor
              Found in trac/wiki/macros.py - About 6 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_form_data has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_form_data(environ):
                      if environ['REQUEST_METHOD'] != 'POST':
                          query_string = environ.get('QUERY_STRING', '')
                          for name, value in parse_arg_list(query_string):
                              _raise_if_null_bytes(name)
              Severity: Minor
              Found in trac/web/api.py - About 6 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

              Environment has 44 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Environment(Component, ComponentManager):
                  """Trac environment manager.
              
                  Trac stores project information in a Trac environment. It consists
                  of a directory structure containing among other things:
              Severity: Minor
              Found in trac/env.py - About 6 hrs to fix

                Function _render_repository_index has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _render_repository_index(self, context, all_repositories, order, desc):
                        # Color scale for the age column
                        timerange = custom_colorizer = None
                        if self.color_scale:
                            custom_colorizer = self.get_custom_colorizer()
                Severity: Minor
                Found in trac/versioncontrol/web_ui/browser.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_editor has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _render_editor(self, req, page, action='edit', has_collision=False):
                        if has_collision:
                            if action == 'merge':
                                page = WikiPage(self.env, page.name)
                                req.perm(page.resource).require('WIKI_VIEW')
                Severity: Minor
                Found in trac/wiki/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 parse_connection_uri has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                def parse_connection_uri(db_str):
                    """Parse the database connection string.
                
                    The database connection string for an environment is specified through
                    the `database` option in the `[trac]` section of trac.ini.
                Severity: Minor
                Found in trac/db/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 process_request has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                    def process_request(self, req):
                        req.perm(self.realm).require('TICKET_VIEW')
                        report_id = req.args.as_int('report')
                        if report_id:
                            req.perm('report', report_id).require('REPORT_VIEW')
                Severity: Minor
                Found in trac/ticket/query.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

                Severity
                Category
                Status
                Source
                Language