edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

Function render_admin_panel has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    def render_admin_panel(self, req, cat, page, path_info):
        perm = PermissionSystem(self.env)
        all_actions = perm.get_actions()

        if req.method == 'POST':
Severity: Minor
Found in trac/admin/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 template_data has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    def template_data(self, context, tickets, orig_list=None, orig_time=None,
                      req=None):
        clauses = []
        for clause in self.constraints:
            constraints = {}
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

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

                if tag in ('replace', 'insert'):
                    for line in tolines[j1:j2]:
                        line = expandtabs(line, tabwidth, '\0\1')
                        line = escape(line, quotes=False)
                        line = '<ins>'.join(space_re.sub(htmlify, seg)
Severity: Major
Found in trac/versioncontrol/diff.py and 1 other location - About 1 day to fix
trac/versioncontrol/diff.py on lines 243..251

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

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

                if tag in ('replace', 'delete'):
                    for line in fromlines[i1:i2]:
                        line = expandtabs(line, tabwidth, '\0\1')
                        line = escape(line, quotes=False)
                        line = '<del>'.join(space_re.sub(htmlify, seg)
Severity: Major
Found in trac/versioncontrol/diff.py and 1 other location - About 1 day to fix
trac/versioncontrol/diff.py on lines 252..260

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

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

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

      class HtmlFormatter(object):
          """Format parsed wiki text to HTML"""
      
          flavor = 'default'
      
      
      Severity: Major
      Found in trac/wiki/formatter.py and 1 other location - About 7 hrs to fix
      trac/wiki/formatter.py on lines 1584..1609

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

      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

      class InlineHtmlFormatter(object):
          """Format parsed wiki text to inline elements HTML.
      
          Block level content will be discarded or compacted.
          """
      Severity: Major
      Found in trac/wiki/formatter.py and 1 other location - About 7 hrs to fix
      trac/wiki/formatter.py on lines 1560..1581

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

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

        Severity
        Category
        Status
        Source
        Language