edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

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

        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

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

                        while 1:
                            try:
                                return path, os.fdopen(os.open(path, flags, 0o666), 'wb')
                            except OSError as e:
                                if e.errno != errno.EEXIST:
                    Severity: Major
                    Found in trac/util/__init__.py and 1 other location - About 6 hrs to fix
                    trac/attachment.py on lines 964..973

                    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 102.

                    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

                                try:
                                    return filename, os.fdopen(os.open(path, flags, 0o666), 'wb')
                                except OSError as e:
                                    if e.errno != errno.EEXIST:
                                        raise
                    Severity: Major
                    Found in trac/attachment.py and 1 other location - About 6 hrs to fix
                    trac/util/__init__.py on lines 310..320

                    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 102.

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

                    Severity
                    Category
                    Status
                    Source
                    Language