edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

Function write has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def write(self, data):
        """Write the given data to the response body.

        *data* **must** be a `bytes` string or an iterable instance
        which iterates `bytes` strings, encoded with the charset which
Severity: Minor
Found in trac/web/api.py - About 1 hr 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 process_input has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def process_input(self):
        """Attempt to read a single Record from the socket and process it."""
        # Currently, any children Request threads notify this Connection
        # that it is no longer needed by closing the Connection's socket.
        # We need to put a timeout on select, otherwise we might get
Severity: Minor
Found in trac/web/_fcgi.py - About 1 hr 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 _query_link_words has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def _query_link_words(self, context, name, value, query=None):
        """Splits a list of words and makes a query link to each separately"""
        from trac.ticket.query import QueryModule
        if not (isinstance(value, str) and  # None or other non-splitable
                self.env.is_component_enabled(QueryModule)):
Severity: Minor
Found in trac/ticket/web_ui.py - About 1 hr 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 process_request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def process_request(self, req):
        req.perm.require('SEARCH_VIEW')

        if req.path_info == '/search/opensearch':
            return ('opensearch.xml', {},
Severity: Minor
Found in trac/search/web_ui.py - About 1 hr 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 14 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, git_dir, log, git_bin='git', git_fs_encoding=None,
                 rev_cache=None):
        """Initialize PyGit.Storage instance

        `git_dir`: path to .git folder;
Severity: Minor
Found in tracopt/versioncontrol/git/PyGIT.py - About 1 hr 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_upgrade has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def do_upgrade(env, version, cursor):
    """Replace list of repositories in [trac] repository_sync_per_request
    with boolean values [repositories] <repos>.sync_per_request and a list
    of repositories in [gitweb-repositories] sync_per_request. Move and
    rename the Gitweb configuration options from the [git] section to
Severity: Minor
Found in trac/upgrades/db32.py - About 1 hr 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 main has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    """
    %(prog)s [-c] passwordfile username
    %(prog)s -b[c] passwordfile username password
    %(prog)s -D passwordfile username\
Severity: Minor
Found in contrib/htpasswd.py - About 1 hr 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

Consider simplifying this complex logical expression.
Open

                if show_location:
                    filestats = self._prepare_filestats()
                    for c, r, repos_for_c in changesets:
                        for chg in c.get_changes():
                            resource = c.resource.parent.child('source',
Severity: Critical
Found in trac/versioncontrol/web_ui/changeset.py - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

                if youngest_rev is not None and oldest_rev is not None and \
                        rev_dict and refs_dict and srev_dict:
                    pass  # all fields are not empty
                elif not youngest_rev and not oldest_rev and \
                        not rev_dict and not refs_dict and not srev_dict:
    Severity: Critical
    Found in tracopt/versioncontrol/git/PyGIT.py - About 1 hr to fix

      Function autoPreview has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        $.fn.autoPreview = function(href, args, update) {
          if (auto_preview_timeout <= 0)
            return this;
          var timeout = auto_preview_timeout * 1000;
          return this.each(function() {
      Severity: Minor
      Found in trac/htdocs/js/auto_preview.js - About 1 hr to fix

        Function removeRow has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function removeRow(button, propertyName) {
              var m = propertyName.match(/^(\d+)_(.*)$/);
              var clauseNum = m[1], field = m[2];
              var tr = $(button).closest("tr");
        
        
        Severity: Minor
        Found in trac/htdocs/js/query.js - About 1 hr to fix

          Function test_suite has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def test_suite():
              import trac.tests
              import trac.admin.tests
              import trac.db.tests
              import trac.mimeview.tests
          Severity: Minor
          Found in trac/test.py - About 1 hr to fix

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

                def __init__(self, title, input, expected, file, line,
            Severity: Major
            Found in trac/wiki/test.py - About 1 hr to fix

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

                  def __init__(self, env, report=None, constraints=None, cols=None,
              Severity: Major
              Found in trac/ticket/query.py - About 1 hr to fix

                Function match_request has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def match_request(self, req):
                        match = re.match(r'/(export|browser|file)(/.*)?$', req.path_info)
                        if match:
                            mode, path = match.groups()
                            if mode == 'export':
                Severity: Minor
                Found in trac/versioncontrol/web_ui/browser.py - About 1 hr 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_custom_colorizer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_custom_colorizer(self):
                        """Returns a converter for values from [0.0, 1.0] to a RGB triple."""
                
                        def interpolate(old, new, value):
                            # Provides a linearly interpolated color triple for `value`
                Severity: Minor
                Found in trac/versioncontrol/web_ui/browser.py - About 1 hr 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_time_format_jquery_ui has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_time_format_jquery_ui(locale):
                    """Get the time format for the jQuery UI timepicker addon."""
                    if locale == 'iso8601':
                        return 'HH:mm:ssZ'
                
                
                Severity: Minor
                Found in trac/util/datefmt.py - About 1 hr 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 expand_macro has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def expand_macro(self, formatter, name, content):
                        intertracs = {}
                        for key, value in self.intertrac_section.options():
                            idx = key.rfind('.')
                            if idx > 0:  # 0 itself doesn't help much: .xxx = ...
                Severity: Minor
                Found in trac/wiki/intertrac.py - About 1 hr 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 render_admin_panel has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def render_admin_panel(self, req, cat, page, path_info):
                        valid_default_handlers = [handler.__class__.__name__
                                                  for handler in self.request_handlers
                                                  if is_valid_default_handler(handler)]
                        if Locale:
                Severity: Minor
                Found in trac/admin/web_ui.py - About 1 hr 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 expandtabs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def expandtabs(s, tabstop=8, ignoring=None):
                    """Expand tab characters `'\\\\t'` into spaces.
                
                    :param tabstop: number of space characters per tab
                                    (defaults to the canonical 8)
                Severity: Minor
                Found in trac/util/text.py - About 1 hr 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