edgewall/trac

View on GitHub

Showing 1,050 of 1,372 total issues

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

def _get_registry(cls, compmgr=None):
    """Return the descriptor registry.

    If `compmgr` is specified, only return descriptors for components that
    are enabled in the given `ComponentManager`.
Severity: Minor
Found in trac/config.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, section, name, default=None, doc='',
Severity: Minor
Found in trac/config.py - About 45 mins to fix

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

    def get_configinfo(env):
        """Returns a list of dictionaries containing the `name` and `options`
        of each configuration section. The value of `options` is a list of
        dictionaries containing the `name`, `value` and `modified` state of
        each configuration option. The `modified` value is True if the value
    Severity: Minor
    Found in trac/config.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 __new__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(mcs, name, bases, d):
            """Create the component class."""
    
            new_class = type.__new__(mcs, name, bases, d)
            if name == 'Component':
    Severity: Minor
    Found in trac/core.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 f['filename'].endswith(nsrc):
                                    plugin['frame_idx'] = i
                                    return
                except KeyError:
    Severity: Major
    Found in trac/loader.py - About 45 mins to fix

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

          def shutdown(self, tid=None):
              """Close pooled connections not used in a while"""
              delay = 120
              if tid is None:
                  delay = 0
      Severity: Minor
      Found in trac/db/pool.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 'meta' in base and i in base['meta']:
                                  f[i] = Markup('<em>%s</em>') % f[i]
                          for i in range(len(t)):
      Severity: Major
      Found in trac/mimeview/patch.py - About 45 mins to fix

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

        def add_meta(req, content, http_equiv=None, name=None, scheme=None, lang=None):
        Severity: Minor
        Found in trac/web/chrome.py - About 45 mins to fix

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

              def run(self):
                  """Begin processing data from the socket."""
                  self._keepGoing = True
                  while self._keepGoing:
                      try:
          Severity: Minor
          Found in trac/web/_fcgi.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 _get_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _get_list(self, sids):
                  all_anon = 'anonymous' in sids or '*' in sids
                  all_auth = 'authenticated' in sids or '*' in sids
                  sids = {self._split_sid(sid)
                          for sid in sids
          Severity: Minor
          Found in trac/web/session.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 get_supported_conversions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_supported_conversions(self, mimetype):
                  """Return a list of target MIME types as instances of the `namedtuple`
                  `MimeConversion`. Output is ordered from best to worst quality.
          
                  The `MimeConversion` `namedtuple` has fields: key, name, extension,
          Severity: Minor
          Found in trac/mimeview/api.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 'meta' in changed and i in changed['meta']:
                                      t[i] = Markup('<em>%s</em>') % t[i]
                  return changes
          Severity: Major
          Found in trac/mimeview/patch.py - About 45 mins to fix

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

                def get_change(self, cnum=None, cdate=None):
                    """Return a ticket change by its number or date.
                    """
                    if cdate is None:
                        row = self._find_change(cnum)
            Severity: Minor
            Found in trac/ticket/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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, env, tkt_id=None, version=None):
                    self.env = env
                    self.fields = TicketSystem(self.env).get_ticket_fields()
                    self.editable_fields = \
                        {f['name'] for f in self.fields
            Severity: Minor
            Found in trac/ticket/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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, req, options):
                    environ = {}
                    environ.update(apache.build_cgi_env(req))
            
                    environ['trac.web.frontend'] = 'mod_python'
            Severity: Minor
            Found in trac/web/modpython_frontend.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 keyword in kwds:
                                        self._mime_map[keyword] = mimetype
                        # augment/override mime_map from trac.ini
                        for mapping in self.config['mimeviewer'].getlist('mime_map'):
            Severity: Major
            Found in trac/mimeview/api.py - About 45 mins to fix

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

                  def _send_headers(self):
                      assert self.headers_set, 'Response not started'
              
                      if not self.headers_sent:
                          status, headers = self.headers_sent = self.headers_set
              Severity: Minor
              Found in trac/web/modpython_frontend.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 len(f) == 0:
                                          b['type'] = 'add'
                                      elif len(t) == 0:
                                          b['type'] = 'rem'
                                      elif len(f) == len(t):
              Severity: Major
              Found in trac/mimeview/patch.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if side == 'base':
                                                fromline += 1
                                            else:
                                                toline += 1
                                            block[side]['lines'].append(line)
                Severity: Major
                Found in trac/mimeview/patch.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if old_db_val is None:
                                              field = self.fields.by_name(name)
                                              default = self._custom_field_default(field)
                                              if self.values.get(name) == default:
                                                  continue
                  Severity: Major
                  Found in trac/ticket/model.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language