sonntagsgesicht/businessdate

View on GitHub

Showing 195 of 195 total issues

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

    def min_days(self):
        if self._months < 0 :
            sgn = -1
            days_in_month = 28, 31, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 # days from feb to jan backwards
        else:
Severity: Major
Found in businessdate/businessperiod.py and 1 other location - About 1 day to fix
businessdate/businessperiod.py on lines 292..305

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

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 max_days(self):
        if self._months < 0:
            sgn = -1
            days_in_month = 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28  # days from mar to feb forwards
        else:
Severity: Major
Found in businessdate/businessperiod.py and 1 other location - About 1 day to fix
businessdate/businessperiod.py on lines 307..319

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

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 businessdate.py has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

# businessdate
# ------------
# Python library for generating business dates for fast date operations
Severity: Minor
Found in businessdate/businessdate.py - About 5 hrs to fix

    Function __init__ has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, period='', years=0, quarters=0, months=0, weeks=0, days=0, businessdays=0):
            """ class to store and calculate date periods as combinations of days, weeks, years etc.
    
            :param str period: encoding a business period.
             Such is given by a sequence of digits as :class:`int` followed by a :class:`char` -
    Severity: Minor
    Found in businessdate/businessperiod.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 __new__ has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(cls, year=None, month=0, day=0,
                    convention=None, holidays=None, day_count=None):
            """ date class to perform calculations coming from financial businesses
    
            :param year: number of year or some other input value t
    Severity: Minor
    Found in businessdate/businessdate.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

    BusinessPeriod has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BusinessPeriod(object):
    
        def __init__(self, period='', years=0, quarters=0, months=0, weeks=0, days=0, businessdays=0):
            """ class to store and calculate date periods as combinations of days, weeks, years etc.
    
    
    Severity: Minor
    Found in businessdate/businessperiod.py - About 3 hrs to fix

      BusinessDate has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class BusinessDate(BaseDateDatetimeDate):
          ADJUST = 'No'
          BASE_DATE = None
          DATE_FORMAT = '%Y%m%d'
          DAY_COUNT = 'act_36525'
      Severity: Minor
      Found in businessdate/businessdate.py - About 2 hrs to fix

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

            for k, v in BusinessDate._adj_func.items():
                s += '           * ' + (":code:`%s`" % k).ljust(
                    16) + '' + v.__doc__ + '\n\n'
        Severity: Major
        Found in businessdate/businessdate.py and 1 other location - About 2 hrs to fix
        businessdate/businessdate.py on lines 471..473

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

        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

            for k, v in BusinessDate._dc_func.items():
                s += '           * ' + (":code:`%s`" % k).ljust(
                    16) + '' + v.__doc__ + '\n\n'
        Severity: Major
        Found in businessdate/businessdate.py and 1 other location - About 2 hrs to fix
        businessdate/businessdate.py on lines 479..481

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

        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 adjust_mod_previous(business_date, holidays=()):
            """ adjusts to Business Day Convention "Modified Preceding". """
            month = business_date.month
            new = adjust_previous(business_date, holidays)
            if month != new.month:
        Severity: Major
        Found in businessdate/conventions.py and 1 other location - About 2 hrs to fix
        businessdate/conventions.py on lines 54..61

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

        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 adjust_mod_follow(business_date, holidays=()):
            """ adjusts to Business Day Convention "Modified [Following]". """
            month = business_date.month
            new = adjust_follow(business_date, holidays)
            if month != new.month:
        Severity: Major
        Found in businessdate/conventions.py and 1 other location - About 2 hrs to fix
        businessdate/conventions.py on lines 64..71

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

        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 _from_complex_input has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def _from_complex_input(cls, date_str):
                date_str = str(date_str).upper()
                convention, origin, holidays = None, None, None
        
                # first, extract origin
        Severity: Minor
        Found in businessdate/businessdate.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

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

            return (360 * (y2 - y1) + 30 * (m2 - m1) + (d2 - d1)) / 360.0
        Severity: Major
        Found in businessdate/daycount.py and 1 other location - About 2 hrs to fix
        businessdate/daycount.py on lines 58..58

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

        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

            return (360 * (y2 - y1) + 30 * (m2 - m1) + (d2 - d1)) / 360.0
        Severity: Major
        Found in businessdate/daycount.py and 1 other location - About 2 hrs to fix
        businessdate/daycount.py on lines 44..44

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

        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 businessperiod.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        
        # businessdate
        # ------------
        # Python library for generating business dates for fast date operations
        Severity: Minor
        Found in businessdate/businessperiod.py - About 2 hrs to fix

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

              def _parse_ymd(cls, period):
                  # can even parse strings like '-1B-2Y-4Q+5M' but also '0B', '-1Y2M3D' as well.
                  period = period.upper().replace(' ', '')
                  period = period.replace('BUSINESSDAYS', 'B')
                  period = period.replace('YEARS', 'Y')
          Severity: Minor
          Found in businessdate/businessperiod.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 __str__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def __str__(self):
          
                  if self.businessdays:
                      period_str = str(self.businessdays) + 'B'
                  else:
          Severity: Minor
          Found in businessdate/businessperiod.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 _add_business_days has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_business_days(self, days_int, holidays=None):
                  res = self.__deepcopy__()
                  if days_int >= 0:
                      count = 0
                      while count < days_int:
          Severity: Minor
          Found in businessdate/businessdate.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 diff_in_ymd has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def diff_in_ymd(self, end_date):
          
                  if end_date < self:
                      y, m, d = 0, 0, 0
                      while end_date < self._add_ymd(y, 0, 0):
          Severity: Minor
          Found in businessdate/businessdate.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

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

              @property
              def day(self):
                  if not self._ymd:
                      self._ymd = self.to_ymd()
                  return self._ymd[2]
          Severity: Major
          Found in businessdate/basedate.py and 2 other locations - About 1 hr to fix
          businessdate/basedate.py on lines 36..40
          businessdate/basedate.py on lines 42..46

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 40.

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

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

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

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

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language