edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

Avoid deeply nested control flow statements.
Open

                            if isinstance(elt, tuple):
                                subkey, subnodes = elt
                                elt = (key + subkey, subnodes)
                            groups.append(elt)
Severity: Major
Found in trac/wiki/macros.py - About 45 mins to fix

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

        def _make_lhref_link(self, match, fullmatch, rel, ns, target, label):
    Severity: Minor
    Found in trac/wiki/formatter.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for chg in c.get_changes():
                                  resource = c.resource.parent.child('source',
                                                                     chg[0] or '/',
                                                                     r.id)
                                  if 'FILE_VIEW' not in context.perm(resource):
      Severity: Major
      Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

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

            def _next_prev_rev(self, direction, rev, path=''):
                srev = self.db_rev(rev)
                with self.env.db_query as db:
                    # the changeset revs are sequence of ints:
                    sql = "SELECT %(aggr)s(rev) FROM %(tab)s " \
        Severity: Minor
        Found in trac/versioncontrol/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 export_page has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def export_page(self, page, filename):
                wikipage = model.WikiPage(self.env, page)
                if wikipage.exists:
                    if not filename:
                        printout(wikipage.text)
        Severity: Minor
        Found in trac/wiki/admin.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 prev_rev:
                                    prev_href = req.href.changeset(prev_rev, reponame,
                                                                   prev_path)
                            else:
        Severity: Major
        Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if uid:
                                          # uid can be seen in multiple repositories
                                          if uid in uids_seen:
                                              uids_seen[uid].append(repos.reponame)
                                              continue  # already viewable, just append
          Severity: Major
          Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if len(flag) > 1:
                                    keys.append(str(flag[1:]))
                                    values.append(False)
                            else:
            Severity: Major
            Found in trac/wiki/parser.py - About 45 mins to fix

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

                  def _prepare_diff(self, req, page, old_text, new_text,
              Severity: Minor
              Found in trac/wiki/web_ui.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if repos.has_node(path, next_rev):
                                            next_href = req.href.changeset(next_rev, reponame,
                                                                           path)
                                        else:  # must be 'D'elete or 'R'ename, show full cset
                                            next_href = req.href.changeset(next_rev, reponame)
                Severity: Major
                Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

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

                      def check_permission(self, action, username, resource, perm):
                          if resource and resource.realm == self.realm:
                              if action == 'WIKI_CHANGE_READONLY':
                                  return 'WIKI_ADMIN' in perm(resource)
                              if action in ('WIKI_DELETE', 'WIKI_MODIFY', 'WIKI_RENAME'):
                  Severity: Minor
                  Found in trac/wiki/web_ui.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_link has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _format_link(self, formatter, ns, pagename, label, ignore_missing,
                  Severity: Minor
                  Found in trac/wiki/api.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if diffs:
                                                has_diffs = True
                                            # elif None (means: manually compare to (previous))
                                            show_entry = True
                    Severity: Major
                    Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for chg in c.get_changes():
                                                  resource = c.resource.parent.child('source',
                                                                                     chg[0] or '/',
                                                                                     r.id)
                                                  if 'FILE_VIEW' not in context.perm(resource):
                      Severity: Major
                      Found in trac/versioncontrol/web_ui/changeset.py - About 45 mins to fix

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

                            def _bolditalic_formatter(self, match, fullmatch):
                                if self._list_stack and not self.in_list_item:
                                    self.close_list()
                        
                                bold_open = self.tag_open_p('MM_BOLD')
                        Severity: Minor
                        Found in trac/wiki/formatter.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 _validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _validate(self, req, page):
                                valid = True
                        
                                # Validate page size
                                if len(req.args.get('text', '')) > self.max_size:
                        Severity: Minor
                        Found in trac/wiki/web_ui.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 emit_linebreak has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def emit_linebreak(self, args):
                                if args:
                                    sep = ':' if ':' in args else '='
                                    kv = args.split(sep, 1)
                                    if kv[0] == 'clear':
                        Severity: Minor
                        Found in trac/wiki/formatter.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 hasattr(macro_provider, 'expand_macro'):
                                                    self.processor = self._macro_processor
                                                else:
                                                    raise TracError(
                                                        tag_("Pre-0.11 macros with the %(method)s "
                        Severity: Major
                        Found in trac/wiki/formatter.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if os.path.isfile(filename):
                                                      self._import(filename, page, replace)
                                          else:
                          Severity: Major
                          Found in trac/wiki/admin.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if m:
                                                        val = m.group(1)
                                                    attr[str(key)] = val  # will be used as a __call__ kwd
                            Severity: Major
                            Found in trac/wiki/macros.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language