edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

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

        for manipulator in self.page_manipulators:
            for field, message in manipulator.validate_wiki_page(req, page):
                valid = False
                if field:
                    add_warning(req, tag_("The Wiki page field %(field)s"
Severity: Major
Found in trac/wiki/web_ui.py and 1 other location - About 4 hrs to fix
trac/attachment.py on lines 414..425

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

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 manipulator in self.manipulators:
            for field, message in manipulator.validate_attachment(req,
                                                                  attachment):
                valid = False
                if field:
Severity: Major
Found in trac/attachment.py and 1 other location - About 4 hrs to fix
trac/wiki/web_ui.py on lines 210..219

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

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

    def _do_changeset_modified(self, reponame, first_rev, *revs):
        if is_default(reponame):
            reponame = ''
        rm = RepositoryManager(self.env)
        errors = rm.notify('changeset_modified', reponame, (first_rev,) + revs)
Severity: Major
Found in trac/versioncontrol/admin.py and 1 other location - About 4 hrs to fix
trac/versioncontrol/admin.py on lines 96..103

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

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 convertDiff has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function convertDiff(name, table, pre) {
    var inline = $(table).hasClass('inline');
    var ths = table.tHead.rows[0].cells;
    var afile, bfile;
    if ( inline ) {
Severity: Major
Found in trac/htdocs/js/diff.js - About 4 hrs to fix

    Function _set_list_depth has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_list_depth(self, depth, new_type=None, lclass=None, start=None):
            def open_list():
                self.close_table()
                self.close_paragraph()
                self.close_indentation() # FIXME: why not lists in quotes?
    Severity: Minor
    Found in trac/wiki/formatter.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_initenv has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_initenv(self, line):
            def initenv_error(msg):
                printerr(_("Initenv for '%(env)s' failed.", env=self.envname),
                         "\n%s" % msg)
            if self.env_check():
    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

    Function copy_tables has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def copy_tables(src_env, dst_env, src_db, dst_db, src_dburi, dst_dburi):
        printfout("Copying tables:")
    
        if src_dburi.startswith('sqlite:'):
            src_db.cnx._eager = False  # avoid uses of eagar cursor
    Severity: Minor
    Found in trac/db/convert.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 save has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self):
            """Write the configuration options to the primary file."""
    
            all_options = {}
            for (section, name), option in Option.get_registry().items():
    Severity: Minor
    Found in trac/config.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 save_changes has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def save_changes(self, author=None, comment=None, when=None, replyto=None):
            """
            Store ticket changes in the database. The ticket must already exist in
            the database.  Returns False if there were no changes to save, True
            otherwise.
    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 custom_fields has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def custom_fields(self):
            """Return the list of custom ticket fields available for tickets."""
            fields = TicketFieldList()
            config = self.ticket_custom_section
            for name in [option for option, value in config.options()
    Severity: Minor
    Found in trac/ticket/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 get_ticket_group_stats has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_ticket_group_stats(self, ticket_ids):
            total_cnt = len(ticket_ids)
            all_statuses = set(TicketSystem(self.env).get_all_status())
            status_cnt = {}
            for s in all_statuses:
    Severity: Minor
    Found in trac/ticket/roadmap.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 main has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def main():
        """Merge translated strings from another PO file.
    
        $ src=../trac-1.2-stable/trac/locale/de/LC_MESSAGES
        $ PYTHONPATH=. contrib/%(prog)s messages $src/messages.po [locale]
    Severity: Minor
    Found in contrib/merge_catalog.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 name:
                for owner, description in self.env.db_query("""
                        SELECT owner, description FROM component WHERE name=%s
                        """, (name,)):
                    self.name = self._old_name = name
    Severity: Major
    Found in trac/ticket/model.py and 1 other location - About 3 hrs to fix
    trac/ticket/model.py on lines 1372..1381

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

    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:
                for time, description in self.env.db_query("""
                        SELECT time, description FROM version WHERE name=%s
                        """, (name,)):
                    self.name = self._old_name = name
    Severity: Major
    Found in trac/ticket/model.py and 1 other location - About 3 hrs to fix
    trac/ticket/model.py on lines 948..957

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

    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

    CachedRepository has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CachedRepository(Repository):
    
        has_linear_changesets = False
    
        scope = property(lambda self: self.repos.scope)
    Severity: Minor
    Found in trac/versioncontrol/cache.py - About 3 hrs to fix

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

          table = Table('notify_watch', key='id')[
                      Column('id', auto_increment=True),
                      Column('sid'),
                      Column('authenticated', type='int'),
                      Column('class'),
      Severity: Major
      Found in trac/upgrades/db35.py and 1 other location - About 3 hrs to fix
      trac/db_default.py on lines 185..193

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

      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('ticket_change', key=('ticket', 'time', 'field'))[
              Column('ticket', type='int'),
              Column('time', type='int64'),
              Column('author'),
              Column('field'),
      Severity: Major
      Found in trac/db_default.py and 1 other location - About 3 hrs to fix
      trac/upgrades/db18.py on lines 35..43

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

      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

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

          Table('notify_watch', key='id')[
              Column('id', auto_increment=True),
              Column('sid'),
              Column('authenticated', type='int'),
              Column('class'),
      Severity: Major
      Found in trac/db_default.py and 1 other location - About 3 hrs to fix
      trac/upgrades/db35.py on lines 19..27

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

      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('ticket_change', key=('ticket', 'time', 'field'))[
                      Column('ticket', type='int'),
                      Column('time', type='int'),
                      Column('author'),
                      Column('field'),
      Severity: Major
      Found in trac/upgrades/db18.py and 1 other location - About 3 hrs to fix
      trac/db_default.py on lines 131..139

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

      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 grouped_stats_data has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def grouped_stats_data(env, stats_provider, tickets, by, per_group_stats_data):
          """Get the `tickets` stats data grouped by ticket field `by`.
      
          `per_group_stats_data(gstat, group_name)` should return a data dict to
          include for the group with field value `group_name`.
      Severity: Minor
      Found in trac/ticket/roadmap.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