edgewall/trac

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

Summary

Maintainability
F
6 days
Test Coverage

File browser.py has 834 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-2007 Christian Boos <cboos@edgewall.org>
Severity: Major
Found in trac/versioncontrol/web_ui/browser.py - About 2 days to fix

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

        def process_request(self, req):
            presel = req.args.get('preselected')
            if presel and (presel + '/').startswith(req.href.browser() + '/'):
                req.redirect(presel)
    
    
    Severity: Minor
    Found in trac/versioncontrol/web_ui/browser.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 _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

    BrowserModule has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BrowserModule(Component):
    
        implements(INavigationContributor, IPermissionRequestor, IRequestHandler,
                   IWikiSyntaxProvider, IHTMLPreviewAnnotator,
                   IWikiMacroProvider)
    Severity: Minor
    Found in trac/versioncontrol/web_ui/browser.py - About 3 hrs to fix

      Function _render_dir has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def _render_dir(self, req, repos, node, rev, order, desc):
              req.perm(node.resource).require('BROWSER_VIEW')
              download_href = self._get_download_href
      
              # Entries metadata
      Severity: Minor
      Found in trac/versioncontrol/web_ui/browser.py - About 2 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_file has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _render_file(self, req, context, repos, node, rev=None):
              req.perm(node.resource).require('FILE_VIEW')
      
              mimeview = Mimeview(self.env)
      
      
      Severity: Minor
      Found in trac/versioncontrol/web_ui/browser.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_property(self, name, mode, context, props):
              """Renders a node property to HTML."""
              if name in self.hidden_properties:
                  return
              candidates = []
      Severity: Minor
      Found in trac/versioncontrol/web_ui/browser.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_custom_colorizer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_custom_colorizer(self):
              """Returns a converter for values from [0.0, 1.0] to a RGB triple."""
      
              def interpolate(old, new, value):
                  # Provides a linearly interpolated color triple for `value`
      Severity: Minor
      Found in trac/versioncontrol/web_ui/browser.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 match_request has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def match_request(self, req):
              match = re.match(r'/(export|browser|file)(/.*)?$', req.path_info)
              if match:
                  mode, path = match.groups()
                  if mode == 'export':
      Severity: Minor
      Found in trac/versioncontrol/web_ui/browser.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 process_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def process_request(self, req):
              presel = req.args.get('preselected')
              if presel and (presel + '/').startswith(req.href.browser() + '/'):
                  req.redirect(presel)
      
      
      Severity: Minor
      Found in trac/versioncontrol/web_ui/browser.py - About 1 hr to fix

        Function expand_macro has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def expand_macro(self, formatter, name, content):
                args, kwargs = parse_args(content)
                format = kwargs.get('format', 'compact')
                glob = kwargs.get('glob', '*')
                order = kwargs.get('order')
        Severity: Minor
        Found in trac/versioncontrol/web_ui/browser.py - About 55 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 annotate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def annotate(self, row, lineno):
                if lineno > len(self.annotations):
                    row.append(tag.th())
                    return
                rev = self.annotations[lineno-1]
        Severity: Minor
        Found in trac/versioncontrol/web_ui/browser.py - About 45 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 annotate_row has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def annotate_row(self, context, row, lineno, line, blame_annotator):
        Severity: Minor
        Found in trac/versioncontrol/web_ui/browser.py - About 45 mins to fix

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

              def _render_dir(self, req, repos, node, rev, order, desc):
          Severity: Minor
          Found in trac/versioncontrol/web_ui/browser.py - About 45 mins to fix

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

                def _render_zip(self, req, context, repos, root_node, rev=None):
            Severity: Minor
            Found in trac/versioncontrol/web_ui/browser.py - About 45 mins to fix

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

                  def _render_file(self, req, context, repos, node, rev=None):
              Severity: Minor
              Found in trac/versioncontrol/web_ui/browser.py - About 45 mins to fix

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

                    def _get_download_href(self, href, repos, node, rev):
                Severity: Minor
                Found in trac/versioncontrol/web_ui/browser.py - About 35 mins to fix

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

                      def render_property(self, name, mode, context, props):
                  Severity: Minor
                  Found in trac/versioncontrol/web_ui/browser.py - About 35 mins to fix

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

                        def _format_browser_link(self, formatter, ns, path, label):
                    Severity: Minor
                    Found in trac/versioncontrol/web_ui/browser.py - About 35 mins to fix

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

                          def _format_export_link(self, formatter, ns, export, label):
                      Severity: Minor
                      Found in trac/versioncontrol/web_ui/browser.py - About 35 mins to fix

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

                            def _get_link_info(self, path, rev, href, perm):
                        Severity: Minor
                        Found in trac/versioncontrol/web_ui/browser.py - About 35 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status