edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

Function do_upgrade has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def do_upgrade(env, version, cursor):
    """Add `description` column to `enum` table."""
    new_schema = [
        Table('enum', key=('type', 'name'))[
            Column('type'),
Severity: Minor
Found in trac/upgrades/db44.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

Avoid deeply nested control flow statements.
Open

                        if ev:
                            yield ev

            # Attachments
            if 'ticket_details' in filters:
Severity: Major
Found in trac/ticket/web_ui.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 tracopt/versioncontrol/svn/svn_prop.py - About 45 mins to fix

      Function get_changesets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_changesets(self, start, stop):
              for key, csets in itertools.groupby(
                      CachedRepository.get_changesets(self, start, stop),
                      key=lambda cset: cset.date):
                  csets = list(csets)
      Severity: Minor
      Found in tracopt/versioncontrol/git/git_fs.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

      Avoid deeply nested control flow statements.
      Open

                          if not data:
                              break
                          m.update(data)
      Severity: Major
      Found in contrib/checksum.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if top and top.expr != s.expr:
                                warn.append(("'endblock %s' misplaced or misspelled,"
                                             " current block is '%s %s'") %
                                            (s.expr, top.kw, top.expr))
                        else:
        Severity: Major
        Found in contrib/jinjachecker.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if prev_t == t:
                                      ticket = ev[3][0]
                                      batch_ev[3][0].append(ticket.id)
                                  else:
                                      yield batch_ev
          Severity: Major
          Found in trac/ticket/web_ui.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if prev_ev:
                                        yield prev_ev
                                    prev_ev = ev
            Severity: Major
            Found in trac/ticket/web_ui.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if older[0] == path:
                                          # still on the path: 'newer' was an edit
                                          yield newer[0], newer[1], Changeset.EDIT
                                      else:
                                          # the path changed: 'newer' was a copy
              Severity: Major
              Found in tracopt/versioncontrol/svn/svn_fs.py - About 45 mins to fix

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

                    def __init__(self, git_dir, log, git_bin='git', git_fs_encoding=None,
                Severity: Minor
                Found in tracopt/versioncontrol/git/PyGIT.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for prev_id, in db(
                                                  "SELECT max(id) FROM ticket WHERE id < %s",
                                                  (ticket.id,)):
                                              add_ticket_link('prev', int(prev_id))
                                      if ticket.id < max_id:
                  Severity: Major
                  Found in trac/ticket/web_ui.py - About 45 mins to fix

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

                        def __init__(self, repos, path, rev, log, ls_tree_info=None,
                    Severity: Minor
                    Found in tracopt/versioncontrol/git/git_fs.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              with open(description_path, 'r',
                                                        encoding='utf-8') as fd:
                                                  info['description'] = fd.read().strip()
                                          if self.projects_url:
                      Severity: Major
                      Found in tracopt/versioncontrol/git/git_fs.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if not group['fields']:
                                                    continue
                                        yield group
                        Severity: Major
                        Found in trac/ticket/web_ui.py - About 45 mins to fix

                          Function blame has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def blame(self, commit_sha, path):
                                  in_metadata = False
                          
                                  commit_sha = _rev_b(commit_sha)
                                  path = self._fs_from_unicode(path)
                          Severity: Minor
                          Found in tracopt/versioncontrol/git/PyGIT.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

                          Avoid deeply nested control flow statements.
                          Open

                                                  if k not in values:
                                                      values[k] = v['old']
                                              skip = True
                          Severity: Major
                          Found in trac/ticket/web_ui.py - About 45 mins to fix

                            Function next_rev has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def next_rev(self, rev, path='', find_initial_rev=False):
                                    """Return revision immediately following `rev`, eventually below
                                    given `path` or globally.
                                    """
                                    rev = self.normalize_rev(rev)
                            Severity: Minor
                            Found in tracopt/versioncontrol/svn/svn_fs.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

                            Avoid deeply nested control flow statements.
                            Open

                                                    if line.strip().startswith(LINE_COMMENT_PREFIX):
                                                        check_for_hint(linenum, line)
                                                    else:
                                                        # check for a line statement
                                                        m = LINE_STATEMENT_RE.match(line)
                            Severity: Major
                            Found in contrib/jinjachecker.py - About 45 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                              if db_provider and req.args.get('add_repos'):
                                                  name = req.args.get('name')
                                                  pretty_name = name or '(default)'
                                                  if name in all_repos:
                                                      raise TracError(_('The repository "%(name)s" already '
                              Severity: Major
                              Found in trac/versioncontrol/admin.py - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                      if (name !== "id" && name !== "summary" && name !== "description" && name !== "status" && name !== "resolution" && name !== "reporter") {
                                        addField(form, name, oldvalue);
                                      }
                                Severity: Major
                                Found in tracopt/ticket/htdocs/ticketclone.js - About 40 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language