edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

Function process_request has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def process_request(self, req):
        id = req.args.getint('id')
        req.perm('ticket', id).require('TICKET_ADMIN')
        ticket = Ticket(self.env, id)
        action = req.args['action']
Severity: Minor
Found in tracopt/ticket/deleter.py - About 3 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

            if field in self.time_fields:
                self.values[field] = from_utimestamp(value)
            elif value is None:
                self.values[field] = empty
            else:
Severity: Major
Found in trac/ticket/model.py and 1 other location - About 3 hrs to fix
trac/ticket/model.py on lines 214..220

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

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

            if name in self.custom_fields:
                if name in self.time_fields:
                    self.values[name] = _db_str_to_datetime(value)
                elif value is None:
                    self.values[name] = empty
Severity: Major
Found in trac/ticket/model.py and 1 other location - About 3 hrs to fix
trac/ticket/model.py on lines 203..208

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

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

Repository has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class Repository(object, metaclass=ABCMeta):
    """Base class for a repository provided by a version control system."""

    has_linear_changesets = False

Severity: Minor
Found in trac/versioncontrol/api.py - About 3 hrs to fix

    DatabaseManager has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseManager(Component):
        """Component used to manage the `IDatabaseConnector` implementations."""
    
        implements(IEnvironmentSetupParticipant, ISystemInfoProvider)
    
    
    Severity: Minor
    Found in trac/db/api.py - About 3 hrs to fix

      Function modify_repository has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def modify_repository(self, reponame, changes):
              """Modify attributes of a repository."""
              if is_default(reponame):
                  reponame = ''
              new_reponame = changes.get('name', reponame)
      Severity: Minor
      Found in trac/versioncontrol/api.py - About 3 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 interwiki_map has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def interwiki_map(self):
              """Map from upper-cased namespaces to (namespace, prefix, title)
              values.
              """
              from trac.wiki.model import WikiPage
      Severity: Minor
      Found in trac/wiki/interwiki.py - About 3 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_first_week_day_jquery_ui has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_first_week_day_jquery_ui(req):
          """Get first week day for jQuery date picker"""
          locale = req.lc_time
          if locale == 'iso8601':
              return 1 # Monday
      Severity: Minor
      Found in trac/util/datefmt.py - About 3 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 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def expand_macro(self, formatter, name, content):
              min_depth, max_depth = 1, 6
              title = None
              inline = False
              numbered = True
      Severity: Minor
      Found in trac/wiki/macros.py - About 3 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_pattern has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def _i18n_parse_date_pattern(locale):
          format_keys = {
              'y': ('y', 'Y'),
              'M': ('M',),
              'd': ('d',),
      Severity: Minor
      Found in trac/util/datefmt.py - About 3 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 render_preference_panel has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def render_preference_panel(self, req, panel, path_info=None):
              if req.method == 'POST':
                  action_arg = req.args.getfirst('action', '').split('_', 1)
                  if len(action_arg) == 2:
                      action, arg = action_arg
      Severity: Minor
      Found in trac/notification/prefs.py - About 3 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 send_internal_error has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def send_internal_error(env, req, exc_info):
          if env:
              env.log.error("[%s] Internal Server Error: %r, referrer %r%s",
                            req.remote_addr, req, req.environ.get('HTTP_REFERER'),
                            exception_to_unicode(exc_info[1], traceback=True))
      Severity: Minor
      Found in trac/web/main.py - About 3 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 _fetch_ticket has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _fetch_ticket(self, tkt_id):
              row = None
              if self.id_is_valid(tkt_id):
                  # Fetch the standard ticket fields
                  tkt_id = int(tkt_id)
      Severity: Minor
      Found in trac/ticket/model.py - About 3 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_default_columns has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_default_columns(self):
              cols = self.get_all_columns()
      
              # Semi-intelligently remove columns that are restricted to a single
              # value by a query constraint.
      Severity: Minor
      Found in trac/ticket/query.py - About 3 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 process_request has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_request(self, req):
              # did the user ask for any special report?
              id = req.args.getint('id', self.REPORT_LIST_ID)
              req.perm(self.realm, id).require('REPORT_VIEW')
      
      
      Severity: Minor
      Found in trac/ticket/report.py - About 3 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

          Table('revision', key=('repos', 'rev'))[
              Column('repos', type='int'),
              Column('rev', key_size=40),
              Column('time', type='int64'),
              Column('author'),
      Severity: Major
      Found in trac/db_default.py and 1 other location - About 3 hrs to fix
      trac/upgrades/db24.py on lines 38..44

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

      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

                    Table('revision', key=('repos', 'rev'))[
                        Column('repos', type='int'),
                        Column('rev', key_size=20),
                        Column('time', type='int'),
                        Column('author'),
      Severity: Major
      Found in trac/upgrades/db24.py and 1 other location - About 3 hrs to fix
      trac/db_default.py on lines 91..97

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

      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

      Function addWikiFormattingToolbar has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        window.addWikiFormattingToolbar = function(textarea) {
          if ((document.selection == undefined)
           && (textarea.setSelectionRange == undefined)) {
            return;
          }
      Severity: Major
      Found in trac/htdocs/js/wikitoolbar.js - About 3 hrs to fix

        Function native_path has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def native_path(path):
            """Converts a Windows-style or POSIX-style path to the native style.
        
            i.e. on Windows, convert POSIX path to Windows path, and in a
            POSIX system, convert Windows path to POSIX path.
        Severity: Minor
        Found in trac/util/__init__.py - About 3 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 do_help has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_help(self, line=None):
                arg = self.arg_tokenize(line)
                if arg[0]:
                    cmd_mgr = None
                    doc = getattr(self, "_help_" + arg[0], None)
        Severity: Minor
        Found in trac/admin/console.py - About 3 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