SpeciesFileGroup/taxonworks

View on GitHub
lib/utilities/dates.rb

Summary

Maintainability
F
3 days
Test Coverage

File dates.rb has 491 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Utilities::Dates

  EARLIEST_DATE = '1700/01/10'.freeze # Reconcile with in-app

  LONG_MONTHS = %w{january february march april may june july august september october november december}.freeze
Severity: Minor
Found in lib/utilities/dates.rb - About 7 hrs to fix

    Method extract_dates has 180 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.extract_dates(trial, match_data)
        end_date_year, end_date_month, end_date_day = 0, 0, 0
        case trial[:method].downcase.to_sym
          when :month_dd_yyyy_2
            start_date_year = 3
    Severity: Major
    Found in lib/utilities/dates.rb - About 7 hrs to fix

      Method has too many lines. [43/25]
      Open

        def self.date_sql_from_params(params)
          st_date, end_date = params['st_datepicker'], params['en_datepicker']
          # processing start date data
          st_year, st_month, st_day = params['start_date_year'], params['start_date_month'], params['start_date_day']
          unless st_date.blank?
      Severity: Minor
      Found in lib/utilities/dates.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method date_sql_from_params has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.date_sql_from_params(params)
          st_date, end_date = params['st_datepicker'], params['en_datepicker']
          # processing start date data
          st_year, st_month, st_day = params['start_date_year'], params['start_date_month'], params['start_date_day']
          unless st_date.blank?
      Severity: Minor
      Found in lib/utilities/dates.rb - 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

      Method extract_dates has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.extract_dates(trial, match_data)
          end_date_year, end_date_month, end_date_day = 0, 0, 0
          case trial[:method].downcase.to_sym
            when :month_dd_yyyy_2
              start_date_year = 3
      Severity: Minor
      Found in lib/utilities/dates.rb - 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

      Method date_sql_from_params has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.date_sql_from_params(params)
          st_date, end_date = params['st_datepicker'], params['en_datepicker']
          # processing start date data
          st_year, st_month, st_day = params['start_date_year'], params['start_date_month'], params['start_date_day']
          unless st_date.blank?
      Severity: Minor
      Found in lib/utilities/dates.rb - About 1 hr to fix

        Method from_parts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.from_parts(y, m, d)
            return '????/??/??' if y.nil? && m.nil? && d.nil?
            [y ? "#{y}" : '????',
             m ? "#{'%02d' % m}" : '??',
             d ? "#{'%02d' % d}" : '??'
        Severity: Minor
        Found in lib/utilities/dates.rb - 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

        Method invalid_month_day has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.invalid_month_day(trial)
            retval = false
            if trial[:start_date_day].to_i > 31 or trial[:end_date_day].to_i > 31
              retval = true
            end
        Severity: Minor
        Found in lib/utilities/dates.rb - 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 ((st_y or st_my) and (end_y or end_my)) and not (st_y and end_y)
                # we have two dates of some kind, complete with years
                # three specific cases:
                #   case 1: start year, (start month, (start day)) forward
                #   case 2: end year, (end month, (end day)) backward
        Severity: Major
        Found in lib/utilities/dates.rb - About 40 mins to fix

          Method fix_2_digit_year has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.fix_2_digit_year(year)
              if year.length < 4
                year = year.gsub("'", '')
                if year.length < 3
                  tny = Time.now.year
          Severity: Minor
          Found in lib/utilities/dates.rb - 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

          Method normalize_and_order_dates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.normalize_and_order_dates(start_date, end_date)
              if start_date.blank? && end_date.blank? # set entire range
                [ EARLIEST_DATE, today] # 1700-01-01 - Today
              else
                end_date = start_date if end_date.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb - 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

          Method nomenclature_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.nomenclature_date(day = nil, month = nil, year = nil)
              if year.nil?
                nil
              elsif month.nil?
                Time.utc(year.to_i, 12, 31)
          Severity: Minor
          Found in lib/utilities/dates.rb - 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

          Method hunt_dates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.hunt_dates(label, filters = REGEXP_DATES.keys)
              trials = {}
              filters.each_with_index {|kee, dex|
                trials[kee] = {}
                matches = label.to_enum(:scan, REGEXP_DATES[kee][:reg]).map {Regexp.last_match}
          Severity: Minor
          Found in lib/utilities/dates.rb - 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

          Use st_month.present? instead of !st_month.blank?.
          Open

              st_my = (!st_month.blank? and !st_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if st_year.present? instead of unless st_year.blank?.
          Open

              unless st_year.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if end_date.present? instead of unless end_date.blank?.
          Open

              unless end_date.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if st_day.present? instead of unless st_day.blank?.
          Open

              unless st_day.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use trial[:end_date_month].present? instead of !trial[:end_date_month].blank?.
          Open

              if trial[:start_date_month].to_i < 1 or (trial[:end_date_month].to_i < 1 and !trial[:end_date_month].blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if st_date.present? instead of unless st_date.blank?.
          Open

              unless st_date.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if st_month.present? instead of unless st_month.blank?.
          Open

              unless st_month.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if matches.present? instead of unless matches.blank?.
          Open

                unless matches.blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use st_month.present? instead of !st_month.blank?.
          Open

              st_m = (!st_month.blank? and st_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use end_year.present? instead of !end_year.blank?.
          Open

              end_my = (!end_month.blank? and !end_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use end_year.present? instead of !end_year.blank?.
          Open

              end_y = (end_month.blank? and !end_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use end_month.present? instead of !end_month.blank?.
          Open

              end_my = (!end_month.blank? and !end_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use trial[:end_date_day].present? instead of !trial[:end_date_day].blank?.
          Open

              if trial[:start_date_day].to_i < 1 or (trial[:end_date_day].to_i < 1 and !trial[:end_date_day].blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if pieces[1].present? instead of unless pieces[1].blank?.
          Open

              unless pieces[1].blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if match_data[1].present? instead of unless match_data[1].blank?.
          Open

              unless match_data[1].blank?
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use end_month.present? instead of !end_month.blank?.
          Open

              end_m = (!end_month.blank? and end_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use st_year.present? instead of !st_year.blank?.
          Open

              st_my = (!st_month.blank? and !st_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use st_year.present? instead of !st_year.blank?.
          Open

              st_y = (st_month.blank? and !st_year.blank?)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          TODO found
          Open

            # TODO: Write unit tests
          Severity: Minor
          Found in lib/utilities/dates.rb by fixme

          TODO found
          Open

            # TODO: still needs more work for some date combinations
          Severity: Minor
          Found in lib/utilities/dates.rb by fixme

          TODO found
          Open

          # TODO: Extract to gem
          Severity: Minor
          Found in lib/utilities/dates.rb by fixme

          Do not use Time.new without zone. Use one of Time.zone.local, Time.current, Time.new.in_time_zone, Time.new.utc, Time.new.getlocal, Time.new.xmlschema, Time.new.iso8601, Time.new.jisx0301, Time.new.rfc3339, Time.new.httpdate, Time.new.to_i, Time.new.to_f instead.
          Open

              Time.new(year, month, day)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
          Open

                  tny = Time.now.year
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Useless private access modifier.
          Open

            private
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

          Example:

          class Foo
            public # this is redundant (default access is public)
          
            def method
            end
          
            private # this is not redundant (a method is defined)
            def method2
            end
          
            private # this is redundant (no following methods are defined)
          end

          Example:

          class Foo
            # The following is not redundant (conditionally defined methods are
            # considered as always defining a method)
            private
          
            if condition?
              def method
              end
            end
          
            protected # this is not redundant (method is defined)
          
            define_method(:method2) do
            end
          
            protected # this is redundant (repeated from previous modifier)
          
            [1,2,3].each do |i|
              define_method("foo#{i}") do
              end
            end
          
            # The following is redundant (methods defined on the class'
            # singleton class are not affected by the public modifier)
            public
          
            def self.method3
            end
          end

          Example:

          # Lint/UselessAccessModifier:
          #   ContextCreatingMethods:
          #     - concerning
          require 'active_support/concern'
          class Foo
            concerning :Bar do
              def some_public_method
              end
          
              private
          
              def some_private_method
              end
            end
          
            # this is not redundant because `concerning` created its own context
            private
          
            def some_other_private_method
            end
          end

          Example:

          # Lint/UselessAccessModifier:
          #   MethodCreatingMethods:
          #     - delegate
          require 'active_support/core_ext/module/delegation'
          class Foo
            # this is not redundant because `delegate` creates methods
            private
          
            delegate :method_a, to: :method_b
          end

          Do not use Time.new without zone. Use one of Time.zone.local, Time.current, Time.new.in_time_zone, Time.new.utc, Time.new.getlocal, Time.new.xmlschema, Time.new.iso8601, Time.new.jisx0301, Time.new.rfc3339, Time.new.httpdate, Time.new.to_i, Time.new.to_f instead.
          Open

              start = Time.new(1970, 1, 1)
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Re-enable Metrics/MethodLength cop with # rubocop:enable after disabling it.
          Open

            # rubocop:disable Metrics/MethodLength
          Severity: Minor
          Found in lib/utilities/dates.rb by rubocop

          There are no issues that match your filters.

          Category
          Status