edgewall/trac

View on GitHub
trac/versioncontrol/web_ui/log.py

Summary

Maintainability
F
4 days
Test Coverage

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

    def process_request(self, req):
        req.perm.require('LOG_VIEW')

        mode = req.args.get('mode', 'stop_on_copy')
        path = req.args.get('path', '/')
Severity: Minor
Found in trac/versioncontrol/web_ui/log.py - About 2 days 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 log.py has 431 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) 2005-2006 Christian Boos <cboos@edgewall.org>
Severity: Minor
Found in trac/versioncontrol/web_ui/log.py - About 6 hrs to fix

    Function _format_link has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def _format_link(self, formatter, ns, match, label, fullmatch=None):
            if ns == 'log1':
                groups = fullmatch.groupdict()
                it_log = groups.get('it_log')
                revs = groups.get('log_revs')
    Severity: Minor
    Found in trac/versioncontrol/web_ui/log.py - About 4 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function process_request has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def process_request(self, req):
            req.perm.require('LOG_VIEW')
    
            mode = req.args.get('mode', 'stop_on_copy')
            path = req.args.get('path', '/')
    Severity: Minor
    Found in trac/versioncontrol/web_ui/log.py - About 1 hr to fix

      Function _append has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def _append(self, revs):
              if not revs:
                  return
      
              pairs = []
      Severity: Minor
      Found in trac/versioncontrol/web_ui/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 _reduce has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def _reduce(self):
              if all(isinstance(pair[0], int) and isinstance(pair[1], int)
                     for pair in self.pairs):
                  try:
                      ranges = Ranges(str(self), reorder=True)
      Severity: Minor
      Found in trac/versioncontrol/web_ui/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 truncate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def truncate(self, curr_pair, new_pair=None):
              curr_pair = tuple(curr_pair)
              if new_pair:
                  new_pair = tuple(new_pair)
              revranges = RevRanges(self.repos, resolve=self.resolve)
      Severity: Minor
      Found in trac/versioncontrol/web_ui/log.py - About 45 mins 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

      Consider simplifying this complex logical expression.
      Open

              if mode == 'path_history':
                  def history():
                      for h in repos.get_path_history(path, rev):
                          if 'CHANGESET_VIEW' in req.perm(cset_resource(id=h[1])):
                              yield h
      Severity: Major
      Found in trac/versioncontrol/web_ui/log.py - About 40 mins to fix

        Function _format_link has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _format_link(self, formatter, ns, match, label, fullmatch=None):
        Severity: Minor
        Found in trac/versioncontrol/web_ui/log.py - About 35 mins to fix

          Function _normrev has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _normrev(self, rev):
                  if not rev:
                      raise NoSuchChangeset(rev)
                  if self.resolve:
                      return self.repos.normalize_rev(rev)
          Severity: Minor
          Found in trac/versioncontrol/web_ui/log.py - About 25 mins 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 pairs:
                      revranges.a = pairs[0][0]
                      revranges.b = pairs[-1][1]
          Severity: Major
          Found in trac/versioncontrol/web_ui/log.py and 1 other location - About 1 hr to fix
          trac/util/__init__.py on lines 1165..1167

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

          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

                          for h in node.get_history():
                              if 'CHANGESET_VIEW' in req.perm(cset_resource(id=h[1])):
                                  yield h
          Severity: Minor
          Found in trac/versioncontrol/web_ui/log.py and 1 other location - About 35 mins to fix
          trac/versioncontrol/web_ui/log.py on lines 128..130

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

          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

                          for h in repos.get_path_history(path, rev):
                              if 'CHANGESET_VIEW' in req.perm(cset_resource(id=h[1])):
                                  yield h
          Severity: Minor
          Found in trac/versioncontrol/web_ui/log.py and 1 other location - About 35 mins to fix
          trac/versioncontrol/web_ui/log.py on lines 158..160

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

          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

          There are no issues that match your filters.

          Category
          Status