edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

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

    def load_pages(self, dir, ignore=[], create_only=[], replace=False):
        loaded = []
        with self.env.db_transaction:
            for page in sorted(os.listdir(dir)):
                if page in ignore:
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

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

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

    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

      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

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

            def get_timeline_events(self, req, start, stop, filters):
                if 'wiki' in filters:
                    wiki_realm = Resource(self.realm)
                    for ts, name, comment, author, version in self.env.db_query("""
                            SELECT time, name, comment, author, version FROM wiki
        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 rename has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def rename(self, new_name):
                """Rename wiki page in-place, keeping the history intact.
                Renaming a page this way will eventually leave dangling references
                to the old page - which literally doesn't exist anymore.
                """
        Severity: Minor
        Found in trac/wiki/model.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 _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 _i18n_parse_date_0 has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def _i18n_parse_date_0(text, order, regexp, period_names, month_names, tzinfo):
        Severity: Minor
        Found in trac/util/datefmt.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if old_offset != depth: # adjust last depth
                                      self._list_stack[-1] = (old_type, depth)
                                  close_item()
          Severity: Major
          Found in trac/wiki/formatter.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

            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 arg == 'inline':
                                          inline = True
                                      elif arg == 'unnumbered':
                                          numbered = False
              
              
              Severity: Major
              Found in trac/wiki/macros.py - About 45 mins to fix

                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 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 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

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

                          def _macro_formatter(self, match, fullmatch, macro, only_inline=False):
                              name = fullmatch.group('macroname')
                              if name and name[-1] == '?': # Macro?() shortcut for MacroList(Macro)
                                  args = name[:-1] or '*'
                              else:
                      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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language