edgewall/trac

View on GitHub
trac/versioncontrol/web_ui/changeset.py

Summary

Maintainability
F
2 wks
Test Coverage

Function _render_html has a Cognitive Complexity of 183 (exceeds 5 allowed). Consider refactoring.
Open

    def _render_html(self, req, repos, chgset, restricted, data):
        """HTML version"""
        data['restricted'] = restricted
        display_rev = repos.display_rev
        data['display_rev'] = display_rev
Severity: Minor
Found in trac/versioncontrol/web_ui/changeset.py - About 3 days 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 changeset.py has 1030 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) 2004-2006 Christopher Lenz <cmlenz@gmx.de>
Severity: Major
Found in trac/versioncontrol/web_ui/changeset.py - About 2 days to fix

    Function render_timeline_event has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
    Open

        def render_timeline_event(self, context, field, event):
            changesets, show_location, show_files = event[3]
            cset, cset_resource, repos_for_uid = changesets[0]
            older_cset = changesets[-1][0]
            message = cset.message or ''
    Severity: Minor
    Found in trac/versioncontrol/web_ui/changeset.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 process_request has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_request(self, req):
            """The appropriate mode of operation is inferred from the request
            parameters:
    
             * If `new_path` and `old_path` are equal (or `old_path` is omitted)
    Severity: Minor
    Found in trac/versioncontrol/web_ui/changeset.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 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 _iter_diff_lines has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def _iter_diff_lines(self, req, repos, data):
            mimeview = Mimeview(self.env)
    
            for old_node, new_node, kind, change in repos.get_changes(
                    new_path=data['new_path'], new_rev=data['new_rev'],
    Severity: Minor
    Found in trac/versioncontrol/web_ui/changeset.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

    ChangesetModule has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ChangesetModule(Component):
        """Renderer providing flexible functionality for showing sets of
        differences.
    
        If the differences shown are coming from a specific changeset,
    Severity: Minor
    Found in trac/versioncontrol/web_ui/changeset.py - About 2 hrs to fix

      Function _format_changeset_link has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _format_changeset_link(self, formatter, ns, chgset, label,
                                     fullmatch=None):
              intertrac = formatter.shorthand_intertrac_helper(ns, chgset, label,
                                                               fullmatch)
              if intertrac:
      Severity: Minor
      Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr 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

      Consider simplifying this complex logical expression.
      Open

                      if show_location:
                          filestats = self._prepare_filestats()
                          for c, r, repos_for_c in changesets:
                              for chg in c.get_changes():
                                  resource = c.resource.parent.child('source',
      Severity: Critical
      Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr to fix

        Function _format_diff_link has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def _format_diff_link(self, formatter, ns, target, label):
                params, query, fragment = formatter.split_link(target)
                def pathrev(path):
                    if '@' in path:
                        return path.split('@', 1)
        Severity: Minor
        Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr 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

        Consider simplifying this complex logical expression.
        Open

                if data['new_path'] == data['old_path']:
                    # ''diff between 2 revisions'' mode
                    return _('Diff [%(old_rev)s:%(new_rev)s] for %(path)s',
                             old_rev=data['old_rev'] or latest,
                             new_rev=data['new_rev'] or latest,
        Severity: Critical
        Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr to fix

          Function process_request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def process_request(self, req):
                  """The appropriate mode of operation is inferred from the request
                  parameters:
          
                   * If `new_path` and `old_path` are equal (or `old_path` is omitted)
          Severity: Minor
          Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr to fix

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

                def process_request(self, req):
                    rm = RepositoryManager(self.env)
            
                    if req.is_xhr:
                        dirname, prefix = posixpath.split(req.args.get('term'))
            Severity: Minor
            Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr 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_search_results has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_search_results(self, req, terms, filters):
                    if 'changeset' not in filters:
                        return
                    rm = RepositoryManager(self.env)
                    repositories = {repos.params['id']: repos
            Severity: Minor
            Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr 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 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def render_property_diff(self, name, old_node, old_props,
            Severity: Minor
            Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

              Function render_property_diff has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def render_property_diff(self, name, old_context, old_props,
              Severity: Minor
              Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if diffs:
                                            has_diffs = True
                                        # elif None (means: manually compare to (previous))
                                        show_entry = True
                Severity: Major
                Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for chg in c.get_changes():
                                              resource = c.resource.parent.child('source',
                                                                                 chg[0] or '/',
                                                                                 r.id)
                                              if 'FILE_VIEW' not in context.perm(resource):
                  Severity: Major
                  Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if uid:
                                                    # uid can be seen in multiple repositories
                                                    if uid in uids_seen:
                                                        uids_seen[uid].append(repos.reponame)
                                                        continue  # already viewable, just append
                    Severity: Major
                    Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for chg in c.get_changes():
                                                  resource = c.resource.parent.child('source',
                                                                                     chg[0] or '/',
                                                                                     r.id)
                                                  if 'FILE_VIEW' not in context.perm(resource):
                      Severity: Major
                      Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if repos.has_node(path, next_rev):
                                                    next_href = req.href.changeset(next_rev, reponame,
                                                                                   path)
                                                else:  # must be 'D'elete or 'R'ename, show full cset
                                                    next_href = req.href.changeset(next_rev, reponame)
                        Severity: Major
                        Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if prev_rev:
                                                      prev_href = req.href.changeset(prev_rev, reponame,
                                                                                     prev_path)
                                              else:
                          Severity: Major
                          Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                        if (show_old or show_new) and (show_entry or not show_diff):
                                            info = {'change': change,
                                                    'old': old_node and node_info(old_node, annotated),
                                                    'new': new_node and node_info(new_node, annotated),
                                                    'props': props,
                            Severity: Major
                            Found in trac/versioncontrol/web_ui/changeset.py - About 40 mins to fix

                              Function _render_html has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def _render_html(self, req, repos, chgset, restricted, data):
                              Severity: Minor
                              Found in trac/versioncontrol/web_ui/changeset.py - About 35 mins to fix

                                Function render_property_diff has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def render_property_diff(name, old_context, old_props,
                                Severity: Minor
                                Found in trac/versioncontrol/web_ui/changeset.py - About 35 mins to fix

                                  Function _format_changeset_link has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def _format_changeset_link(self, formatter, ns, chgset, label,
                                  Severity: Minor
                                  Found in trac/versioncontrol/web_ui/changeset.py - About 35 mins to fix

                                    Function render_property_diff has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def render_property_diff(self, name, old_node, old_props,
                                                                 new_node, new_props, options):
                                            """Renders diffs of a node property to HTML."""
                                            if name in BrowserModule(self.env).hidden_properties:
                                                return
                                    Severity: Minor
                                    Found in trac/versioncontrol/web_ui/changeset.py - About 35 mins 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_filters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def get_timeline_filters(self, req):
                                            if 'CHANGESET_VIEW' in req.perm:
                                                # Non-'hidden' repositories will be listed as additional
                                                # repository filters, unless there is only a single repository.
                                                filters = []
                                    Severity: Minor
                                    Found in trac/versioncontrol/web_ui/changeset.py - About 35 mins 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

                                    Avoid too many return statements within this function.
                                    Open

                                                    return diff_blocks(old_content.splitlines(),
                                    Severity: Major
                                    Found in trac/versioncontrol/web_ui/changeset.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return tag_("%(title)s: %(message)s",
                                      Severity: Major
                                      Found in trac/versioncontrol/web_ui/changeset.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                        return []
                                        Severity: Major
                                        Found in trac/versioncontrol/web_ui/changeset.py - About 30 mins to fix

                                          Function _get_parent_location has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def _get_parent_location(self, files):
                                                  """Only get a location when there are different files,
                                                     otherwise return the empty string."""
                                                  if files:
                                                      files.sort()
                                          Severity: Minor
                                          Found in trac/versioncontrol/web_ui/changeset.py - About 25 mins 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

                                          There are no issues that match your filters.

                                          Category
                                          Status