edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

Function babel has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var babel = new function() {

  var defaultPluralExpr = function(n) { return n == 1 ? 0 : 1; };
  var formatRegex = /%(?:(?:\(([^\)]+)\))?([disr])|%)/g;
  var translations = {};
Severity: Major
Found in trac/htdocs/js/babel.js - About 4 hrs to fix

    File presentation.py has 360 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    #
    # Copyright (C) 2006-2023 Edgewall Software
    # Copyright (C) 2006 Christopher Lenz <cmlenz@gmx.de>
    # All rights reserved.
    Severity: Minor
    Found in trac/util/presentation.py - About 4 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              for i in range(curr_depth-1, min_depth-2, -1):
                  out.write(whitespace_indent * (2*i+1) + '</li>\n' +
                            whitespace_indent * (2*i) + '</ol>\n')
      Severity: Major
      Found in trac/wiki/formatter.py and 1 other location - About 4 hrs to fix
      trac/wiki/formatter.py on lines 1519..1521

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 81.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      for i in range(curr_depth-1, depth-1, -1):
                          out.write(whitespace_indent * (2*i+1) + '</li>\n' +
                                    whitespace_indent * (2*i) + '</ol>\n')
      Severity: Major
      Found in trac/wiki/formatter.py and 1 other location - About 4 hrs to fix
      trac/wiki/formatter.py on lines 1531..1533

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 81.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      for line in fromlines[i1:i2]:
                          line = line.expandtabs(tabwidth)
                          line = space_re.sub(htmlify, escape(line, quotes=False))
                          blocks[-1]['base']['lines'].append(Markup(str(line)))
      Severity: Major
      Found in trac/versioncontrol/diff.py and 1 other location - About 4 hrs to fix
      trac/versioncontrol/diff.py on lines 238..241

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      for line in tolines[j1:j2]:
                          line = line.expandtabs(tabwidth)
                          line = space_re.sub(htmlify, escape(line, quotes=False))
                          blocks[-1]['changed']['lines'].append(Markup(str(line)))
      Severity: Major
      Found in trac/versioncontrol/diff.py and 1 other location - About 4 hrs to fix
      trac/versioncontrol/diff.py on lines 234..237

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      File admin.py has 353 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      #
      # Copyright (C) 2008-2023 Edgewall Software
      # All rights reserved.
      #
      Severity: Minor
      Found in trac/versioncontrol/admin.py - About 4 hrs to fix

        File translation.py has 352 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        #
        # Copyright (C) 2007-2023 Edgewall Software
        # All rights reserved.
        #
        Severity: Minor
        Found in trac/util/translation.py - About 4 hrs to fix

          Function make_log_graph has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

          def make_log_graph(repos, revs):
              """Generate graph information for the given revisions.
          
              Returns a tuple `(threads, vertices, columns)`, where:
          
          
          Severity: Minor
          Found in trac/versioncontrol/web_ui/util.py - About 4 hrs 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 30 (exceeds 5 allowed). Consider refactoring.
          Open

              def expand_macro(self, formatter, name, content):
                  from trac.config import ConfigSection, Option
          
                  args, kw = parse_args(content)
                  filters = {}
          Severity: Minor
          Found in trac/wiki/macros.py - About 4 hrs 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 a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

          def _i18n_parse_date_0(text, order, regexp, period_names, month_names, tzinfo):
              matches = regexp.findall(text)
              if not matches:
                  return None
          
          
          Severity: Minor
          Found in trac/util/datefmt.py - About 4 hrs 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 _populate has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              def _populate(self, req, ticket, plain_fields=False):
                  if not plain_fields:
                      fields = {k[6:]: req.args.get(k) for k in req.args
                                if k.startswith('field_') and
                                   'revert_' + k[6:] not in req.args}
          Severity: Minor
          Found in trac/ticket/web_ui.py - About 4 hrs 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_ticket_changes has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_ticket_changes(self, req, ticket, action):
                  this_action = self.actions[action]
          
                  # Enforce permissions
                  if not self._is_action_allowed(req, this_action, ticket.resource):
          Severity: Minor
          Found in trac/ticket/default_workflow.py - About 4 hrs 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 30 (exceeds 5 allowed). Consider refactoring.
          Open

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  with self.env.db_transaction as db:
                      try:
                          db("""
                                  INSERT INTO component (name,owner,description)
                                  VALUES (%s,%s,%s)
          Severity: Major
          Found in trac/ticket/model.py and 1 other location - About 4 hrs to fix
          trac/ticket/model.py on lines 1410..1420

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 79.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  with self.env.db_transaction as db:
                      try:
                          db("""
                              INSERT INTO version (name,time,description)
                              VALUES (%s,%s,%s)
          Severity: Major
          Found in trac/ticket/model.py and 1 other location - About 4 hrs to fix
          trac/ticket/model.py on lines 989..999

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 79.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File postgres_backend.py has 350 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          #
          # Copyright (C) 2005-2023 Edgewall Software
          # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
          # All rights reserved.
          Severity: Minor
          Found in trac/db/postgres_backend.py - About 4 hrs to fix

            Function __init__ has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, formatter, name, args=None):
                    """Find the processor by name
            
                    :param formatter: the formatter embedding a call for this processor
                    :param name: the name of the processor
            Severity: Minor
            Found in trac/wiki/formatter.py - About 4 hrs 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 has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def format(self, text, out, shorten=False):
                    if not text:
                        return
                    text = self.reset(text, out)
            
            
            Severity: Minor
            Found in trac/wiki/formatter.py - About 4 hrs 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 grouped_changelog_entries has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                def grouped_changelog_entries(self, ticket, when=None):
                    """Iterate on changelog entries, consolidating related changes
                    in a `dict` object.
                    """
                    field_labels = TicketSystem(self.env).get_ticket_field_labels()
            Severity: Minor
            Found in trac/ticket/web_ui.py - About 4 hrs 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