edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

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

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

    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 not strict:
                            content = re_box_processor.sub('', content)
                        lines = content.replace('\r\n', '\n').splitlines(True)
    Severity: Major
    Found in contrib/checkwiki.py - About 45 mins to fix

      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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self, id, retriever, instance):
                """Get cached or fresh data for the given id."""
                # Get cache metadata
                local_meta = self._local.meta
                local_cache = self._local.cache
        Severity: Minor
        Found in trac/cache.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, path, params, log):
                self.log = log
                self.pool = Pool()
        
                # note that this should usually not happen (str arg expected)
        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

                                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 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 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 isinstance(permissions, str):
                                        return [permissions]
                                    else:
                                        return permissions
                    return None
            Severity: Major
            Found in tracopt/perm/authz_policy.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for k, v in change['fields'].items():
                                          values[k] = v['new']
                                  if 'description' in change['fields']:
              Severity: Major
              Found in trac/ticket/web_ui.py - About 45 mins to fix

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

                    def expand_macro(self, formatter, name, content, args=None):
                        args = args or {}
                        reponame = args.get('repository') or ''
                        rev = args.get('revision')
                        repos = RepositoryManager(self.env).get_repository(reponame)
                Severity: Minor
                Found in tracopt/ticket/commit_updater.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 _format_revision_link has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _format_revision_link(self, formatter, ns, reponame, rev, label,
                Severity: Minor
                Found in sample-plugins/revision_links.py - About 45 mins to fix

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

                      def milestone_changed(self, milestone, old_values):
                          if not milestone.is_completed or 'completed' not in old_values \
                                  or old_values['completed'] is not None:
                              return
                          m = re.match(self.pattern, milestone.name)
                  Severity: Minor
                  Found in sample-plugins/milestone_to_version.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 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_ev:
                                                yield prev_ev
                                            prev_ev = ev
                    Severity: Major
                    Found in trac/ticket/web_ui.py - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                  if (show_old or show_new) and (show_entry or not show_diff):
                                      info = {'change': change,
                                              'old': old_node and node_info(old_node, annotated),
                                              'new': new_node and node_info(new_node, annotated),
                                              'props': props,
                      Severity: Major
                      Found in trac/versioncontrol/web_ui/changeset.py - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if mode == 'path_history':
                                    def history():
                                        for h in repos.get_path_history(path, rev):
                                            if 'CHANGESET_VIEW' in req.perm(cset_resource(id=h[1])):
                                                yield h
                        Severity: Major
                        Found in trac/versioncontrol/web_ui/log.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