edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

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

    Avoid deeply nested control flow statements.
    Open

                            if processor != 'comment':
                                buf.write(' [...]\n')
                            processor = None
    Severity: Major
    Found in trac/wiki/formatter.py - About 45 mins to fix

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

          def render_timeline_event(self, context, field, event):
              wiki_page, comment = event[3]
              if field == 'url':
                  return context.href.wiki(wiki_page.id, version=wiki_page.version)
              elif field == 'title':
      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 v < version:
                                  if not prev_version:
                                      prev_version = v
                                      break
                              else:
      Severity: Major
      Found in trac/wiki/web_ui.py - About 45 mins to fix

        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 left_space < w:
                                      break
                                  left_space -= w
          Severity: Major
          Found in trac/util/text.py - About 45 mins to fix

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

                def __init__(self, safe_schemes=SAFE_SCHEMES, safe_css=SAFE_CSS,
            Severity: Minor
            Found in trac/util/html.py - About 45 mins to fix

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

                  def __call__(self, *args, **kwargs):
                      if kwargs:
                          d = self._dict_from_kwargs(kwargs)
                          if d:
                              if self.attrib:
              Severity: Minor
              Found in trac/util/html.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 _do_install has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _do_install(self, req):
                      """Install a plugin."""
                      if 'plugin_file' not in req.args:
                          raise TracError(_("No file uploaded"))
                      upload = req.args['plugin_file']
              Severity: Minor
              Found in trac/admin/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 action not in req.perm:
                                          add_warning(req,
                                                      _("The permission %(action)s was "
                                                        "not granted to %(subject)s "
                                                        "because users cannot grant "
              Severity: Major
              Found in trac/admin/web_ui.py - About 45 mins to fix

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

                def to_utf8(text, charset='latin1'):
                    """Convert input to a UTF-8 `bytes` object.
                
                    If the input is not an `str` object, we assume the encoding is
                    already UTF-8, ISO Latin-1, or as specified by the optional
                Severity: Minor
                Found in trac/util/text.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 create_zipinfo has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def create_zipinfo(filename, mtime=None, dir=False, executable=False, symlink=False,
                Severity: Minor
                Found in trac/util/__init__.py - About 45 mins to fix

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

                  def wrap(t, cols=75, initial_indent='', subsequent_indent='',
                  Severity: Minor
                  Found in trac/util/text.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if name not in func_kwargs_map:
                                                continue
                                            index = func_kwargs_map[name]
                    Severity: Major
                    Found in trac/dist.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if dt.month > 1:
                                              dt = dt.replace(month=dt.month - 1)
                                          else:
                                              dt = dt.replace(year=dt.year - 1, month=12)
                                      elif start == 'year':
                      Severity: Major
                      Found in trac/util/datefmt.py - About 45 mins to fix

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

                            def __init__(self, cols, replace_whitespace=0, break_long_words=0,
                        Severity: Minor
                        Found in trac/util/text.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if dt.month < 12:
                                                  dt = dt.replace(month=dt.month + 1)
                                              else:
                                                  dt = dt.replace(year=dt.year + 1, month=1)
                                          elif start == 'year':
                          Severity: Major
                          Found in trac/util/datefmt.py - About 45 mins to fix

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

                                def _download_as_zip(self, req, parent, attachments=None):
                                    if attachments is None:
                                        attachments = self.viewable_attachments(web_context(req, parent))
                                    total_size = sum(attachment.size for attachment in attachments)
                                    if total_size > self.max_zip_size:
                            Severity: Minor
                            Found in trac/attachment.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 escape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def escape(text, quotes=True):
                                """Create a Markup instance from a string and escape special characters
                                it may contain (<, >, & and \").
                            
                                :param text: the string to escape; if not a string, it is assumed that
                            Severity: Minor
                            Found in trac/util/html.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 kwarg_name in func_kwargs_map:
                                                        messages_kwargs[kwarg_name] = message
                                                    else:
                                                        messages.append(message)
                                                    del buf[:]
                            Severity: Major
                            Found in trac/dist.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language