edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

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

            ticket_values['description'] = wrap(
                ticket_values.get('description', ''), self.COLS,
                initial_indent=' ', subsequent_indent=' ', linesep='\n',
                ambiwidth=self.ambiwidth)
Severity: Major
Found in trac/ticket/notification.py and 1 other location - About 1 hr to fix
trac/ticket/notification.py on lines 270..273

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

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

            ticket_values['description'] = wrap(
                ticket_values.get('description', ''), self.COLS,
                initial_indent=' ', subsequent_indent=' ', linesep='\n',
                ambiwidth=self.ambiwidth)
Severity: Major
Found in trac/ticket/notification.py and 1 other location - About 1 hr to fix
trac/ticket/notification.py on lines 232..235

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

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

            tag.tr(tag.th(tag.em(_("Prefix"))),
                   tag.th(tag.em(_("Trac Site")))),
Severity: Major
Found in trac/wiki/intertrac.py and 1 other location - About 1 hr to fix
trac/wiki/interwiki.py on lines 177..178

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

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

        return tag.table(tag.tr(tag.th(tag.em(_("Prefix"))),
                                tag.th(tag.em(_("Site")))),
Severity: Major
Found in trac/wiki/interwiki.py and 1 other location - About 1 hr to fix
trac/wiki/intertrac.py on lines 128..129

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

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

    def _do_send(self, transport, event, message, cc_addrs, bcc_addrs):
        notify_sys = NotificationSystem(self.env)
        smtp_from = notify_sys.smtp_from
        smtp_from_name = notify_sys.smtp_from_name or self.env.project_name
        smtp_replyto = notify_sys.smtp_replyto
Severity: Minor
Found in trac/notification/mail.py - About 1 hr to fix

    Function parse_args has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def parse_args(args=None):
        parser = argparse.ArgumentParser()
    
        class _AuthAction(argparse.Action):
    
    
    Severity: Minor
    Found in trac/web/standalone.py - About 1 hr to fix

      Function _render_ics has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def _render_ics(self, req, milestones):
              req.send_response(200)
              req.send_header('Content-Type', 'text/calendar;charset=utf-8')
              buf = io.StringIO()
      
      
      Severity: Minor
      Found in trac/ticket/roadmap.py - About 1 hr to fix

        Function code_block_directive has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def code_block_directive(name, arguments, options, content, lineno,
        Severity: Major
        Found in trac/mimeview/rst.py - About 1 hr to fix

          Function trac_directive has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def trac_directive(name, arguments, options, content, lineno,
          Severity: Major
          Found in trac/mimeview/rst.py - About 1 hr to fix

            Function enableExpandDir has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              window.enableExpandDir = function(parent_tr, rows, qargs, autoexpand) {
                // the ancestors folder ids are present in the parent_tr class attribute
                var ancestor_folderids = [];
            
                if (parent_tr) // rows are logical children of the parent_tr row
            Severity: Minor
            Found in trac/htdocs/js/expand_dir.js - About 1 hr to fix

              Function encloseSelection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function encloseSelection(prefix, suffix) {
                    textarea.focus();
                    var start, end, sel, scrollPos, subst;
                    if (document.selection != undefined) {
                      sel = document.selection.createRange().text;
              Severity: Minor
              Found in trac/htdocs/js/wikitoolbar.js - About 1 hr to fix

                Function _process_ticket_request has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def _process_ticket_request(self, req):
                        id = req.args.getint('id')
                        version = req.args.getint('version', None)
                
                        if req.is_xhr and 'preview_comment' in req.args:
                Severity: Minor
                Found in trac/ticket/web_ui.py - About 1 hr to fix

                  Function _render_comment_diff has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def _render_comment_diff(self, req, ticket, data, cnum):
                          """Show differences between two versions of a ticket comment."""
                          req.perm(ticket.resource).require('TICKET_VIEW')
                          new_version = req.args.getint('version', 1)
                          old_version = req.args.getint('old_version', new_version)
                  Severity: Minor
                  Found in trac/ticket/web_ui.py - About 1 hr to fix

                    Function upgrade has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def upgrade(self, backup=False, backup_dest=None):
                            """Upgrade database.
                    
                            :param backup: whether or not to backup before upgrading
                            :param backup_dest: name of the backup file
                    Severity: Minor
                    Found in trac/env.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_repositories_by_dir has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_repositories_by_dir(self, directory):
                            """Retrieve the repositories based on the given directory.
                    
                               :param directory: the key for identifying the repositories.
                               :return: list of `Repository` instances.
                    Severity: Minor
                    Found in trac/versioncontrol/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 resource_exists has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def resource_exists(self, resource):
                            if resource.realm == self.repository_realm:
                                reponame = resource.id
                            else:
                                reponame = resource.parent.id
                    Severity: Minor
                    Found in trac/versioncontrol/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 logger_handler_factory has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def logger_handler_factory(logtype='syslog', logfile=None, level='WARNING',
                                               logid='Trac', format=None):
                        logger = logging.getLogger(logid)
                        logtype = logtype.lower()
                        if logtype == 'file':
                    Severity: Minor
                    Found in trac/log.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 handle_match has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def handle_match(self, fullmatch):
                            for itype, match in fullmatch.groupdict().items():
                                if match and itype not in self.wikiparser.helper_patterns:
                                    # Check for preceding escape character '!'
                                    if match[0] == '!':
                    Severity: Minor
                    Found in trac/wiki/formatter.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 normalize_rev has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def normalize_rev(self, rev):
                            if rev is None or isinstance(rev, str) and \
                                   rev.lower() in ('', 'head', 'latest', 'youngest'):
                                return self.rev_db(self.youngest_rev or 0)
                            else:
                    Severity: Minor
                    Found in trac/versioncontrol/cache.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_search_results has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_search_results(self, req, terms, filters):
                            if 'changeset' not in filters:
                                return
                            rm = RepositoryManager(self.env)
                            repositories = {repos.params['id']: repos
                    Severity: Minor
                    Found in trac/versioncontrol/web_ui/changeset.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