edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

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

    def _render_diff(self, req, ticket, data, text_fields):
        """Show differences between two versions of a ticket description.

        `text_fields` is optionally a list of fields of interest, that are
        considered for jumping to the next change.
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 sync has a Cognitive Complexity of 54 (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 tracopt/versioncontrol/git/git_fs.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 dist.py has 516 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2023 Edgewall Software
# All rights reserved.
#
Severity: Major
Found in trac/dist.py - About 1 day to fix

    Function initializeFilters has 205 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      window.initializeFilters = function() {
        // Remove an existing row from the filters table
        function removeRow(button, propertyName) {
          var m = propertyName.match(/^(\d+)_(.*)$/);
          var clauseNum = m[1], field = m[2];
    Severity: Major
    Found in trac/htdocs/js/query.js - About 1 day to fix

      Function process_request has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_request(self, req):
              req.perm('timeline').require('TIMELINE_VIEW')
      
              format = req.args.get('format')
              maxrows = req.args.getint('max', 50 if format == 'rss' else 0)
      Severity: Minor
      Found in trac/timeline/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 diff_blocks has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
      Open

      def diff_blocks(fromlines, tolines, context=None, tabwidth=8,
                      ignore_blank_lines=0, ignore_case=0, ignore_space_changes=0):
          """Return an array that is adequate for adding to the data dictionary
      
          See `get_filtered_hunks` for the parameter descriptions.
      Severity: Minor
      Found in trac/versioncontrol/diff.py - About 7 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_timeline_events has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_timeline_events(self, req, start, stop, filters):
              all_repos = 'changeset' in filters
              repo_filters = {f for f in filters if f.startswith('repo-')}
              if all_repos or repo_filters:
                  show_files = self.timeline_show_files
      Severity: Minor
      Found in trac/versioncontrol/web_ui/changeset.py - About 7 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 has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
      Open

          def render(self, context, mimetype, content, filename=None, url=None,
                     annotations=None, force_source=False):
              """Render an XHTML preview of the given `content`.
      
              `content` is the same as an `IHTMLPreviewRenderer.render`'s
      Severity: Minor
      Found in trac/mimeview/api.py - About 7 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 50 (exceeds 5 allowed). Consider refactoring.
      Open

          def _render_admin_panel(self, req, cat, page, path_info):
              label = [gettext(each) for each in self._label]
              data = {'label_singular': label[0], 'label_plural': label[1],
                      'type': self._type}
      
      
      Severity: Minor
      Found in trac/ticket/admin.py - About 7 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 test.py has 487 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/test.py - About 7 hrs to fix

        Function _render_view has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
        Open

            def _render_view(self, req, page):
                version = page.resource.version
        
                # Add registered converters
                if page.exists:
        Severity: Minor
        Found in trac/wiki/web_ui.py - About 7 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 distribute has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
        Open

            def distribute(self, transport, recipients, event):
                if transport != 'email':
                    return
                if not self.config.getbool('notification', 'smtp_enabled'):
                    self.log.debug("%s skipped because smtp_enabled set to false",
        Severity: Minor
        Found in trac/notification/mail.py - About 7 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_props has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
        Open

            def _format_props(self, ticket):
                fields = [f for f in ticket.fields
                          if f['name'] not in ('summary', 'cc', 'time', 'changetime')]
                width = [0, 0, 0, 0]
                i = 0
        Severity: Minor
        Found in trac/ticket/notification.py - About 7 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 dispatch_request has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
        Open

        def dispatch_request(environ, start_response):
            """Main entry point for the Trac web interface.
        
            :param environ: the WSGI environment dict
            :param start_response: the WSGI callback for starting the response
        Severity: Minor
        Found in trac/web/main.py - About 7 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 web_ui.py has 471 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        #
        # Copyright (C) 2005-2023 Edgewall Software
        # Copyright (C) 2005 Jonas Borgström <jonas@edgewall.com>
        # All rights reserved.
        Severity: Minor
        Found in trac/admin/web_ui.py - About 7 hrs to fix

          Function babel has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
          Open

          var babel = new function() {
          
            var defaultPluralExpr = function(n) { return n == 1 ? 0 : 1; };
            var formatRegex = /%(?:(?:\(([^\)]+)\))?([disr])|%)/g;
            var translations = {};
          Severity: Minor
          Found in trac/htdocs/js/babel.js - About 7 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 initializeBatch has 178 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            window.initializeBatch = function() {
              // Create the appropriate input for the property.
              function createBatchInput(propertyName, property) {
                var td = $('<td class="batchmod_property">');
                var inputName = getBatchInputName(propertyName);
          Severity: Major
          Found in trac/htdocs/js/query.js - About 7 hrs to fix

            Function dispatch has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
            Open

                def dispatch(self, req):
                    """Find a registered handler that matches the request and let
                    it process it.
            
                    In addition, this method initializes the data dictionary
            Severity: Minor
            Found in trac/web/main.py - About 7 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_navigation_items has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_navigation_items(self, req, handler):
            
                    def get_item_attributes(category, name, text):
                        section = self.config[category]
                        href = section.get(name + '.href')
            Severity: Minor
            Found in trac/web/chrome.py - About 7 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 session.py has 460 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            #
            # Copyright (C) 2004-2023 Edgewall Software
            # Copyright (C) 2004 Daniel Lundin <daniel@edgewall.com>
            # Copyright (C) 2004-2006 Christopher Lenz <cmlenz@gmx.de>
            Severity: Minor
            Found in trac/web/session.py - About 7 hrs to fix
              Severity
              Category
              Status
              Source
              Language