edgewall/trac

View on GitHub
trac/ticket/default_workflow.py

Summary

Maintainability
F
4 days
Test Coverage

Function render_ticket_action_control has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

    def render_ticket_action_control(self, req, ticket, action):

        self.log.debug('render_ticket_action_control: action "%s"', action)

        this_action = self.actions[action]
Severity: Minor
Found in trac/ticket/default_workflow.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 default_workflow.py has 566 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2006-2023 Edgewall Software
# Copyright (C) 2006 Alec Thomas
# Copyright (C) 2007 Eli Carter
Severity: Major
Found in trac/ticket/default_workflow.py - About 1 day to fix

    Function get_ticket_changes has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_ticket_changes(self, req, ticket, action):
            this_action = self.actions[action]
    
            # Enforce permissions
            if not self._is_action_allowed(req, this_action, ticket.resource):
    Severity: Minor
    Found in trac/ticket/default_workflow.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

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

        def expand_macro(self, formatter, name, content, args=None):
            if content is not None:
                content = content.strip()
            if not args and not content:
                raw_actions = self.config.options('ticket-workflow')
    Severity: Minor
    Found in trac/ticket/default_workflow.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

    Function parse_workflow_config has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_workflow_config(rawactions):
        """Given a list of options from [ticket-workflow]"""
    
        required_attrs = {
            'oldstates': [],
    Severity: Minor
    Found in trac/ticket/default_workflow.py - About 3 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 _to_users has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def _to_users(self, users_perms_and_groups, ticket):
            """Finds all users contained in the list of `users_perms_and_groups`
            by recursive lookup of users when a `group` is encountered.
            """
            ps = PermissionSystem(self.env)
    Severity: Minor
    Found in trac/ticket/default_workflow.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 get_ticket_actions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_ticket_actions(self, req, ticket):
            """Returns a list of (weight, action) tuples that are valid for this
            request and this ticket."""
            # Get the list of actions that can be performed
    
    
    Severity: Minor
    Found in trac/ticket/default_workflow.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

    Consider simplifying this complex logical expression.
    Open

            if not ticket.exists and 'owner' not in updated:
                updated['owner'] = self._sub_owner_keyword(ticket['owner'], ticket)
            elif ticket['status'] == 'new' and \
                    'component' in ticket.values and \
                    'component' in ticket._old and \
    Severity: Major
    Found in trac/ticket/default_workflow.py - About 1 hr to fix

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

          def _is_action_allowed(self, req, action, resource):
              """Returns `True` if the workflow action is allowed for the `resource`.
              """
              perm_cache = req.perm(resource)
              required_perms = action['permissions']
      Severity: Minor
      Found in trac/ticket/default_workflow.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 _sub_owner_keyword has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _sub_owner_keyword(self, owner, ticket):
              """Substitute keywords from the default_owner field.
      
              < default > -> component owner
              """
      Severity: Minor
      Found in trac/ticket/default_workflow.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_all_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_all_actions(self):
              actions = parse_workflow_config(self.ticket_workflow_section.options())
      
              has_new_state = any('new' in [a['newstate']] + a['oldstates']
                                  for a in actions.values())
      Severity: Minor
      Found in trac/ticket/default_workflow.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