edgewall/trac

View on GitHub

Showing 1,372 of 1,372 total issues

Function format has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    def format(self, text, out=None, escape_newlines=False):
        text = self.reset(text, out)
        if isinstance(text, str):
            text = text.splitlines()

Severity: Minor
Found in trac/wiki/formatter.py - About 5 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 37 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    args = parse_args()

    wsgi_app = TracEnvironMiddleware(dispatch_request, args.env_parent_dir,
                                     args.envs, args.single_env)
Severity: Minor
Found in trac/web/standalone.py - About 5 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 parse_args has a Cognitive Complexity of 37 (exceeds 5 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 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function _format_comment_link has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    def _format_comment_link(self, formatter, ns, target, label):
        resource = None
        if ':' in target:
            elts = target.split(':')
            if len(elts) == 3:
Severity: Minor
Found in trac/ticket/api.py - About 5 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

File api.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# Copyright (C) 2003-2005 Jonas Borgström <jonas@edgewall.com>
# Copyright (C) 2004-2005 Christopher Lenz <cmlenz@gmx.de>
Severity: Minor
Found in trac/wiki/api.py - About 5 hrs to fix

    Function parse has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse(authz_file, modules):
        """Parse a Subversion authorization file.
    
        Return a dict of modules, each containing a dict of paths, each containing
        a dict mapping users to permissions. Only modules contained in `modules`
    Severity: Minor
    Found in trac/versioncontrol/svn_authz.py - About 5 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 print_table has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    def print_table(data, headers=None, sep='  ', out=None, ambiwidth=None):
        """Print data according to a tabular layout.
    
        :param data: a sequence of rows; assume all rows are of equal length.
        :param headers: an optional row containing column headers; must be of
    Severity: Minor
    Found in trac/util/text.py - About 5 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 load_eggs has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_eggs(entry_point_name):
        """Loader that loads any eggs on the search path and `sys.path`."""
        def _load_eggs(env, search_path, auto_enable=None):
            # Note that the following doesn't seem to support unicode search_path
            distributions, errors = working_set.find_plugins(
    Severity: Minor
    Found in trac/loader.py - About 5 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 scan has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    def scan(lines):
        """Scans template lines and separates Jinja2 structure from HTML structure.
        """
    
        def count_parens(line):
    Severity: Minor
    Found in contrib/jinjachecker.py - About 5 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

        def delete(self):
            """Delete the version.
    
            :raises TracError: if version does not exist.
            """
    Severity: Major
    Found in trac/ticket/model.py and 1 other location - About 5 hrs to fix
    trac/ticket/model.py on lines 963..975

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

    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 delete(self):
            """Delete the component.
    
            :raises TracError: if component does not exist.
            """
    Severity: Major
    Found in trac/ticket/model.py and 1 other location - About 5 hrs to fix
    trac/ticket/model.py on lines 1387..1399

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

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

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

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

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

    Refactorings

    Further Reading

    File cache.py has 389 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      File sqlite_backend.py has 388 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

        Function _render_admin_panel has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

            def _render_admin_panel(self, req, cat, page, component):
                # Detail view?
                if component:
                    comp = model.Component(self.env, component)
                    if req.method == 'POST':
        Severity: Minor
        Found in trac/ticket/admin.py - About 5 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

        File svn_prop.py has 383 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        #
        # Copyright (C) 2005-2023 Edgewall Software
        # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
        # Copyright (C) 2005-2007 Christian Boos <cboos@edgewall.org>
        Severity: Minor
        Found in tracopt/versioncontrol/svn/svn_prop.py - About 5 hrs to fix

          Chrome has 39 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Chrome(Component):
              """Web site chrome assembly manager.
          
              Chrome is everything that is not actual page content.
              """
          Severity: Minor
          Found in trac/web/chrome.py - About 5 hrs to fix

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

                                if dateonly:
                                    label = absolute
                                elif req.lc_time == 'iso8601':
                                    label = _("at %(iso8601)s", iso8601=absolute)
                                elif format == 'date':
            Severity: Major
            Found in trac/timeline/web_ui.py and 1 other location - About 5 hrs to fix
            trac/web/chrome.py on lines 1215..1224

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

            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

                            if dateonly:
                                label = absolute
                            elif req.lc_time == 'iso8601':
                                label = _("at %(iso8601)s", iso8601=absolute)
                            elif format == 'date':
            Severity: Major
            Found in trac/web/chrome.py and 1 other location - About 5 hrs to fix
            trac/timeline/web_ui.py on lines 302..311

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

            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

                    class _UserAction(argparse.Action):
            
                        def __call__(self, parser, namespace, values, option_string=None):
                            import pwd
                            try:
            Severity: Major
            Found in trac/web/standalone.py and 1 other location - About 5 hrs to fix
            trac/web/standalone.py on lines 219..231

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

            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

                    class _GroupAction(argparse.Action):
            
                        def __call__(self, parser, namespace, values, option_string=None):
                            import grp
                            try:
            Severity: Major
            Found in trac/web/standalone.py and 1 other location - About 5 hrs to fix
            trac/web/standalone.py on lines 233..245

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

            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

            Severity
            Category
            Status
            Source
            Language