sonntagsgesicht/businessdate

View on GitHub

Showing 23 of 195 total issues

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

        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

        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

          Function is_businessperiod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def is_businessperiod(cls, period):
                  """ returns true if the argument can be understood as :class:`BusinessPeriod` """
                  if period is None:
                      return False
                  if isinstance(period, (int, float, list, set, dict, tuple)):
          Severity: Minor
          Found in businessdate/businessperiod.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 __cmp__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def __cmp__(self, other):
                  other = self.__class__() if other == 0 else other
                  if not isinstance(other, BusinessPeriod):
                      other = BusinessPeriod(other)
                  if self.businessdays:
          Severity: Minor
          Found in businessdate/businessperiod.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 from_excel_to_ymd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def from_excel_to_ymd(excel_int):
              """
              converts date in Microsoft Excel representation style and returns `(year, month, day)` tuple
          
              :param int excel_int: date as int (days since 1899-12-31)
          Severity: Minor
          Found in businessdate/ymd.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, period='', years=0, quarters=0, months=0, weeks=0, days=0, businessdays=0):
          Severity: Major
          Found in businessdate/businessperiod.py - About 50 mins to fix

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

                def __new__(cls, year=None, month=0, day=0,
            Severity: Minor
            Found in businessdate/businessdate.py - About 45 mins to fix

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

                  def _parse_date_string(cls, date_str, default=None):
                      date_str = str(date_str)
                      if date_str.count('-'):
                          str_format = '%Y-%m-%d'
                      elif date_str.count('.'):
              Severity: Minor
              Found in businessdate/businessdate.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 True
              Severity: Major
              Found in businessdate/businessperiod.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return False
                Severity: Major
                Found in businessdate/businessperiod.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return False
                  Severity: Major
                  Found in businessdate/businessperiod.py - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language