edgewall/trac

View on GitHub
trac/util/datefmt.py

Summary

Maintainability
F
1 wk
Test Coverage

File datefmt.py has 1027 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# Copyright (C) 2003-2006 Jonas Borgström <jonas@edgewall.com>
# Copyright (C) 2006 Matthew Good <trac@matt-good.net>
Severity: Major
Found in trac/util/datefmt.py - About 2 days to fix

    Function _parse_relative_time has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_relative_time(text, tzinfo, now=None):
        if now is None:     # now argument for unit tests
            now = datetime_now(tzinfo)
        if text == 'now':
            return now
    Severity: Minor
    Found in trac/util/datefmt.py - About 6 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 _i18n_parse_date_0 has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def _i18n_parse_date_0(text, order, regexp, period_names, month_names, tzinfo):
        matches = regexp.findall(text)
        if not matches:
            return None
    
    
    Severity: Minor
    Found in trac/util/datefmt.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 _i18n_parse_date_pattern has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def _i18n_parse_date_pattern(locale):
        format_keys = {
            'y': ('y', 'Y'),
            'M': ('M',),
            'd': ('d',),
    Severity: Minor
    Found in trac/util/datefmt.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_first_week_day_jquery_ui has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_first_week_day_jquery_ui(req):
        """Get first week day for jQuery date picker"""
        locale = req.lc_time
        if locale == 'iso8601':
            return 1 # Monday
    Severity: Minor
    Found in trac/util/datefmt.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 _tzinfo has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def _tzinfo(self, dt, is_dst=False):
            tzinfo = dt.tzinfo
            if isinstance(tzinfo, LocalTimezone) and tzinfo._offset is not None:
                return tzinfo
    
    
    Severity: Minor
    Found in trac/util/datefmt.py - About 2 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_date_iso8601 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _parse_date_iso8601(text, tzinfo):
        match = _ISO_8601_RE.match(text)
        if match:
            try:
                g = match.groups()
    Severity: Minor
    Found in trac/util/datefmt.py - About 2 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_date has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_date(text, tzinfo=None, locale=None, hint='date'):
        tzinfo = tzinfo or localtz
        text = text.strip()
    
        dt = _parse_date_iso8601(text, tzinfo)
    Severity: Minor
    Found in trac/util/datefmt.py - About 2 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 to_datetime has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def to_datetime(t, tzinfo=None):
        """Convert ``t`` into a `datetime` object in the ``tzinfo`` timezone.
    
        If no ``tzinfo`` is given, the local timezone `localtz` will be used.
    
    
    Severity: Minor
    Found in trac/util/datefmt.py - About 2 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_datetime has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _format_datetime(t, format, tzinfo, locale, hint):
        t = to_datetime(t, tzinfo or localtz)
    
        if format == 'iso8601':
            return _format_datetime_iso8601(t, 'long', hint)
    Severity: Minor
    Found in trac/util/datefmt.py - About 2 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_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 _format_datetime_babel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _format_datetime_babel(t, format, locale, hint):
        if hint in ('datetime', 'date'):
            datepart = babel_format_date(t, format, locale)
            if hint == 'date':
                return datepart
    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 _precise_now_windows has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _precise_now_windows():
            """Provide high-resolution system time if Windows 8+ and Windows
            Server 2012+.
            """
            import ctypes
    Severity: Minor
    Found in trac/util/datefmt.py - About 55 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

    Function _i18n_parse_date_0 has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _i18n_parse_date_0(text, order, regexp, period_names, month_names, tzinfo):
    Severity: Minor
    Found in trac/util/datefmt.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if dt.month > 1:
                              dt = dt.replace(month=dt.month - 1)
                          else:
                              dt = dt.replace(year=dt.year - 1, month=12)
                      elif start == 'year':
      Severity: Major
      Found in trac/util/datefmt.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if l.territory:
                                    locale = l
                                    break
                            except (UnknownLocaleError, ValueError):
        Severity: Major
        Found in trac/util/datefmt.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if dt.month < 12:
                                  dt = dt.replace(month=dt.month + 1)
                              else:
                                  dt = dt.replace(year=dt.year + 1, month=1)
                          elif start == 'year':
          Severity: Major
          Found in trac/util/datefmt.py - About 45 mins to fix

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

            def _format_datetime(t, format, tzinfo, locale, hint):
            Severity: Minor
            Found in trac/util/datefmt.py - About 35 mins to fix

              Function get_period_names_jquery_ui has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_period_names_jquery_ui(req):
                  # allow to use always English am/pm markers
                  english_names = {'am': 'AM', 'pm': 'PM'}
                  locale = req.lc_time
                  if locale == 'iso8601':
              Severity: Minor
              Found in trac/util/datefmt.py - About 35 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

              Function pretty_timedelta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def pretty_timedelta(time1, time2=None, resolution=None):
                  """Calculate time delta between two `datetime` objects.
                  (the result is somewhat imprecise, only use for prettyprinting).
              
                  If either `time1` or `time2` is None, the current time will be used
              Severity: Minor
              Found in trac/util/datefmt.py - About 35 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

              Avoid too many return statements within this function.
              Open

                          return _format_datetime_babel(t, format, locale, hint)
              Severity: Major
              Found in trac/util/datefmt.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return _format_datetime_without_babel(t, format)
                Severity: Major
                Found in trac/util/datefmt.py - About 30 mins to fix

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

                  def _format_datetime_iso8601(t, format, hint):
                      if format != 'full':
                          t = t.replace(microsecond=0)
                      text = t.isoformat()  # YYYY-MM-DDThh:mm:ss.SSSSSS±hh:mm
                      if format == 'short':
                  Severity: Minor
                  Found in trac/util/datefmt.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

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

                  def _i18n_parse_date(text, tzinfo, locale):
                      if locale is None:
                          key = getlocale(LC_TIME)[0]
                          patterns = _I18N_PARSE_DATE_PATTERNS_LIBC
                      else:
                  Severity: Minor
                  Found in trac/util/datefmt.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

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

                      def fromutc(self, dt):
                          if dt.tzinfo is None or dt.tzinfo is not self:
                              raise ValueError('fromutc: dt.tzinfo is not self')
                          dt = dt.replace(tzinfo=utc)
                          try:
                  Severity: Minor
                  Found in trac/util/datefmt.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

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

                          if tz_offset == self._std_offset:
                              tz = self._std_tz
                          elif tz_offset == self._dst_offset:
                              tz = self._dst_tz
                          else:
                  Severity: Major
                  Found in trac/util/datefmt.py and 1 other location - About 1 hr to fix
                  trac/util/datefmt.py on lines 1143..1148

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

                  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 tz_offset == self._std_offset:
                              tz = self._std_tz
                          elif tz_offset == self._dst_offset:
                              tz = self._dst_tz
                          else:
                  Severity: Major
                  Found in trac/util/datefmt.py and 1 other location - About 1 hr to fix
                  trac/util/datefmt.py on lines 1087..1092

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

                  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 format:
                          units = [(unit[0], '%(' + unit[1] + ')s') for unit in units]
                  Severity: Major
                  Found in trac/util/datefmt.py and 1 other location - About 1 hr to fix
                  trac/util/datefmt.py on lines 404..405

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

                  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 format:
                          units = [(unit[0], '%(' + unit[1] + ')s') for unit in units]
                  Severity: Major
                  Found in trac/util/datefmt.py and 1 other location - About 1 hr to fix
                  trac/util/datefmt.py on lines 373..374

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

                  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 format is None:
                              format = 'medium'
                          elif format in _STRFTIME_HINTS:
                              hint = _STRFTIME_HINTS[format]
                              format = 'medium'
                  Severity: Major
                  Found in trac/util/datefmt.py and 1 other location - About 1 hr to fix
                  trac/util/datefmt.py on lines 281..285

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

                  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 format is None:
                              format = 'long'
                          elif format in _STRFTIME_HINTS:
                              hint = _STRFTIME_HINTS[format]
                              format = 'long'
                  Severity: Major
                  Found in trac/util/datefmt.py and 1 other location - About 1 hr to fix
                  trac/util/datefmt.py on lines 291..295

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

                  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 tmpl.replace('1999', 'yy', 1).replace('99', 'y', 1) \
                                 .replace('10', 'mm', 1).replace('29', 'dd', 1)
                  Severity: Minor
                  Found in trac/util/datefmt.py and 1 other location - About 45 mins to fix
                  trac/util/datefmt.py on lines 488..489

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

                  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 tmpl.replace('23', 'HH', 1).replace('11', 'hh', 1) \
                                     .replace('59', 'mm', 1).replace('58', 'ss', 1)
                  Severity: Minor
                  Found in trac/util/datefmt.py and 1 other location - About 45 mins to fix
                  trac/util/datefmt.py on lines 461..462

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

                  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