edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

Function _process_ticket_request has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def _process_ticket_request(self, req):
        id = req.args.getint('id')
        version = req.args.getint('version', None)

        if req.is_xhr and 'preview_comment' in req.args:
Severity: Minor
Found in trac/ticket/web_ui.py - About 1 hr to fix

    Function _render_comment_diff has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def _render_comment_diff(self, req, ticket, data, cnum):
            """Show differences between two versions of a ticket comment."""
            req.perm(ticket.resource).require('TICKET_VIEW')
            new_version = req.args.getint('version', 1)
            old_version = req.args.getint('old_version', new_version)
    Severity: Minor
    Found in trac/ticket/web_ui.py - About 1 hr to fix

      Function upgrade has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def upgrade(self, backup=False, backup_dest=None):
              """Upgrade database.
      
              :param backup: whether or not to backup before upgrading
              :param backup_dest: name of the backup file
      Severity: Minor
      Found in trac/env.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_repositories_by_dir has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_repositories_by_dir(self, directory):
              """Retrieve the repositories based on the given directory.
      
                 :param directory: the key for identifying the repositories.
                 :return: list of `Repository` instances.
      Severity: Minor
      Found in trac/versioncontrol/api.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 resource_exists has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def resource_exists(self, resource):
              if resource.realm == self.repository_realm:
                  reponame = resource.id
              else:
                  reponame = resource.parent.id
      Severity: Minor
      Found in trac/versioncontrol/api.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 logger_handler_factory has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def logger_handler_factory(logtype='syslog', logfile=None, level='WARNING',
                                 logid='Trac', format=None):
          logger = logging.getLogger(logid)
          logtype = logtype.lower()
          if logtype == 'file':
      Severity: Minor
      Found in trac/log.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 handle_match has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_match(self, fullmatch):
              for itype, match in fullmatch.groupdict().items():
                  if match and itype not in self.wikiparser.helper_patterns:
                      # Check for preceding escape character '!'
                      if match[0] == '!':
      Severity: Minor
      Found in trac/wiki/formatter.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 normalize_rev has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def normalize_rev(self, rev):
              if rev is None or isinstance(rev, str) and \
                     rev.lower() in ('', 'head', 'latest', 'youngest'):
                  return self.rev_db(self.youngest_rev or 0)
              else:
      Severity: Minor
      Found in trac/versioncontrol/cache.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 import_page has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def import_page(self, filename, title, create_only=[], replace=False):
              if filename:
                  if not os.path.isfile(filename):
                      raise AdminCommandError(_("'%(name)s' is not a file",
                                                name=path_to_unicode(filename)))
      Severity: Minor
      Found in trac/wiki/admin.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 _create_unique_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _create_unique_file(self, dir, filename):
              parts = os.path.splitext(filename)
              flags = os.O_CREAT + os.O_WRONLY + os.O_EXCL
              if hasattr(os, 'O_BINARY'):
                  flags += os.O_BINARY
      Severity: Minor
      Found in trac/attachment.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 __contains__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def __contains__(self, x):
              """
              >>> 55 in Ranges()
              False
              """
      Severity: Minor
      Found in trac/util/__init__.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 rename has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def rename(src, dst):
              # Try atomic or pseudo-atomic rename
              if _rename(src, dst):
                  return
              # Fall back to "move away and replace"
      Severity: Minor
      Found in trac/util/__init__.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 create_unique_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_unique_file(path):
          """Create a new file. An index is added if the path exists"""
          parts = os.path.splitext(path)
          flags = os.O_CREAT + os.O_WRONLY + os.O_EXCL
          if hasattr(os, 'O_BINARY'):
      Severity: Minor
      Found in trac/util/__init__.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 htmlattr_filter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def htmlattr_filter(_eval_ctx, d, autospace=True):
          """Create an SGML/XML attribute string based on the items in a dict.
      
          If the dict itself is `none` or `undefined`, it returns the empty
          string. ``d`` can also be an iterable or a mapping, in which case
      Severity: Minor
      Found in trac/util/presentation.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_users_with_permission has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_users_with_permission(self, permission):
              """Return all users that have the specified permission.
      
              Users are returned as a list of user names.
              """
      Severity: Minor
      Found in trac/perm.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_view has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _render_view(self, req, attachment):
              req.perm(attachment.resource).require('ATTACHMENT_VIEW')
              can_delete = 'ATTACHMENT_DELETE' in req.perm(attachment.resource)
              req.check_modified(attachment.date, str(can_delete))
      
      
      Severity: Minor
      Found in trac/attachment.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 move has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def move(cls, env, rule_id, priority, sid=None, authenticated=None):
              with env.db_transaction as db:
                  kwargs = {'id': rule_id}
                  if sid is not None or authenticated is not None:
                      kwargs['sid'] = sid
      Severity: Minor
      Found in trac/notification/model.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__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def __get__(self, instance, owner):
              if instance is None:
                  return self
              order = ListOption.__get__(self, instance, owner)
              components = []
      Severity: Minor
      Found in trac/config.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 create_header has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_header(key, value, charset):
          """Create an email Header.
      
          The `key` is always a string and will be converted to the
          appropriate `charset`. The `value` can either be a string or a
      Severity: Minor
      Found in trac/notification/mail.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

      Severity
      Category
      Status
      Source
      Language