edgewall/trac

View on GitHub
trac/ticket/admin.py

Summary

Maintainability
F
5 days
Test Coverage

File admin.py has 682 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function _render_admin_panel has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        def _render_admin_panel(self, req, cat, page, milestone_name):
            perm_cache = req.perm('admin', 'ticket/' + self._type)
    
            # Detail view
            if milestone_name:
    Severity: Minor
    Found in trac/ticket/admin.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_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

    Function _render_admin_panel has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def _render_admin_panel(self, req, cat, page, component):
            # Detail view?
            if component:
                comp = model.Component(self.env, component)
                if req.method == 'POST':
    Severity: Minor
    Found in trac/ticket/admin.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

    Function _render_admin_panel has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def _render_admin_panel(self, req, cat, page, version):
            # Detail view?
            if version:
                ver = model.Version(self.env, version)
                if req.method == 'POST':
    Severity: Minor
    Found in trac/ticket/admin.py - About 4 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

    Avoid deeply nested control flow statements.
    Open

                            for name in sel:
                                milestone = model.Milestone(self.env, name)
                                milestone.move_tickets(None, req.authname,
                                                       "Milestone deleted")
                                milestone.delete()
    Severity: Major
    Found in trac/ticket/admin.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for name in sel:
                                  model.Component(self.env, name).delete()
                                  if name == default:
                                      self.config.set('ticket',
                                                      'default_component', '')
      Severity: Major
      Found in trac/ticket/admin.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for enum in self._enum_cls.select(self.env):
                                    new_value = order[enum.value]
                                    if new_value != enum.value:
                                        enum.value = new_value
                                        enum.update()
        Severity: Major
        Found in trac/ticket/admin.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for name in sel:
                                      self._enum_cls(self.env, name).delete()
                                      if name == default:
                                          self.config.set('ticket',
                                                          'default_%s' % self._type, '')
          Severity: Major
          Found in trac/ticket/admin.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for name in sel:
                                        model.Version(self.env, name).delete()
                                        if name == default:
                                            self.config.set('ticket',
                                                            'default_version', '')
            Severity: Major
            Found in trac/ticket/admin.py - About 45 mins to fix

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

                  def _do_order(self, name, up_down):
                      if up_down not in ('up', 'down'):
                          raise AdminCommandError(_("Invalid up/down value: %(value)s",
                                                    value=up_down))
                      direction = -1 if up_down == 'up' else 1
              Severity: Minor
              Found in trac/ticket/admin.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