edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

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

    def as_int(self, key, default=None, min=None, max=None):
        """Return the value as an integer. Return `default` if
        if an exception is raised while converting the value to an
        integer.

Severity: Major
Found in trac/web/session.py and 1 other location - About 1 hr to fix
trac/web/session.py on lines 90..106

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

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 as_float(self, key, default=None, min=None, max=None):
        """Return the value as a float. Return `default` if
        if an exception is raised while converting the value to a
        float.

Severity: Major
Found in trac/web/session.py and 1 other location - About 1 hr to fix
trac/web/session.py on lines 72..88

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

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 render_fragment(self, req, filename, data, text=False, domain=None):
        """Produces a string from given template *filename* and input *data*,
        with minimal overhead.

        It calls `prepare_template` to augment the *data* with the
Severity: Major
Found in trac/web/chrome.py and 1 other location - About 1 hr to fix
trac/web/chrome.py on lines 1420..1440

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

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 generate_fragment(self, req, filename, data, text=False, domain=None):
        """Produces content ready to be sent from the given template
        *filename* and input *data*, with minimal overhead.

        It calls `prepare_template` to augment the *data* with the
Severity: Major
Found in trac/web/chrome.py and 1 other location - About 1 hr to fix
trac/web/chrome.py on lines 1442..1463

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

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

    function removeRow(button, propertyName) {
      var m = propertyName.match(/^(\d+)_(.*)$/);
      var clauseNum = m[1], field = m[2];
      var tr = $(button).closest("tr");

Severity: Minor
Found in trac/htdocs/js/query.js - About 1 hr to fix

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

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

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

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

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

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

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

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

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

                  case 75: // 'k' - previous line
                    if ( selection == null )
                      pickFirst();
                    else
                      do {
            Severity: Major
            Found in trac/htdocs/js/keyboard_nav.js and 1 other location - About 1 hr to fix
            trac/htdocs/js/keyboard_nav.js on lines 25..32

            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

                  case 74: // 'j' - next line
                    if ( selection == null )
                      pickFirst();
                    else
                      do {
            Severity: Major
            Found in trac/htdocs/js/keyboard_nav.js and 1 other location - About 1 hr to fix
            trac/htdocs/js/keyboard_nav.js on lines 33..40

            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

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

                def get_custom_colorizer(self):
                    """Returns a converter for values from [0.0, 1.0] to a RGB triple."""
            
                    def interpolate(old, new, value):
                        # Provides a linearly interpolated color triple for `value`
            Severity: Minor
            Found in trac/versioncontrol/web_ui/browser.py - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                def match_request(self, req):
                    match = re.match(r'/(export|browser|file)(/.*)?$', req.path_info)
                    if match:
                        mode, path = match.groups()
                        if mode == 'export':
            Severity: Minor
            Found in trac/versioncontrol/web_ui/browser.py - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                def expand_macro(self, formatter, name, content):
                    intertracs = {}
                    for key, value in self.intertrac_section.options():
                        idx = key.rfind('.')
                        if idx > 0:  # 0 itself doesn't help much: .xxx = ...
            Severity: Minor
            Found in trac/wiki/intertrac.py - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

            def get_time_format_jquery_ui(locale):
                """Get the time format for the jQuery UI timepicker addon."""
                if locale == 'iso8601':
                    return 'HH:mm:ssZ'
            
            
            Severity: Minor
            Found in trac/util/datefmt.py - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                def render_admin_panel(self, req, cat, page, path_info):
                    valid_default_handlers = [handler.__class__.__name__
                                              for handler in self.request_handlers
                                              if is_valid_default_handler(handler)]
                    if Locale:
            Severity: Minor
            Found in trac/admin/web_ui.py - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

            def _restart_with_reloader():
                is_win32 = sys.platform == 'win32'
                if is_win32:
                    can_exec = lambda path: os.path.isfile(path) and \
                                            os.path.normpath(path).endswith('.exe')
            Severity: Minor
            Found in trac/util/autoreload.py - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

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

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                def send(self, from_addr, recipients, message):
                    global local_hostname
            
                    # Ensure the message complies with RFC2822: use CRLF line endings
                    message = fix_eol(message, CRLF)
            Severity: Minor
            Found in trac/notification/mail.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 rmtree has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            def rmtree(path):
                def onexc(function, path, e):
                    # `os.unlink` and `os.remove` fail for a readonly file on Windows.
                    # Then, it attempts to be writable and remove.
                    if function not in (os.unlink, os.remove):
            Severity: Minor
            Found in trac/test.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