dgilperez/schedule_attributes

View on GitHub

Showing 8 of 8 total issues

Method schedule_attributes has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    def schedule_attributes
      atts = {}
      time_format = ScheduleAttributes.configuration.time_format
      schedule = read_schedule_field || ScheduleAttributes.default_schedule

Severity: Minor
Found in lib/schedule_attributes/core.rb - About 7 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

Class Input has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Input

    module RepeatingDates
      def repeat?; true end

Severity: Minor
Found in lib/schedule_attributes/input.rb - About 3 hrs to fix

    Method schedule_attributes has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def schedule_attributes
          atts = {}
          time_format = ScheduleAttributes.configuration.time_format
          schedule = read_schedule_field || ScheduleAttributes.default_schedule
    
    
    Severity: Major
    Found in lib/schedule_attributes/core.rb - About 2 hrs to fix

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

          def self.parse_in_zone(str)
            if Time.respond_to?(:zone) && Time.zone
              # Rails 4.1 removes Date.to_time_in_current_zone in favour of Date.in_time_zone
              if str.respond_to?(:in_time_zone)
                str.in_time_zone
      Severity: Minor
      Found in lib/schedule_attributes/time_helpers.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 end_time_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def end_time_date
            return date_input unless @params[:start_time].present?
            return nil if @params[:all_day]
            return nil unless @params[:end_time].present?
            parse_date_time(date_input, @params[:end_time]) <= start_time ? (Time.parse(date_input) + 1.day).strftime('%Y-%m-%d') : date_input
      Severity: Minor
      Found in lib/schedule_attributes/input.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 schedule_attributes= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def schedule_attributes=(options)
            raise ArgumentError "expecting a Hash" unless options.is_a? Hash
      
            options = options.with_indifferent_access
            merge_date_and_time_into_time_attribute!(options)
      Severity: Minor
      Found in lib/schedule_attributes/core.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 end_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def end_date
            if @params[:end_date]
              parse_date_time(@params[:end_date], @params[:end_time] || @params[:start_time])
            elsif @params[:end_time] && !time_only?(@params[:end_time])
              parse_date_time(@params[:end_time])
      Severity: Minor
      Found in lib/schedule_attributes/input.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

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

          def self.today
            if Time.respond_to?(:zone) && Time.zone
              # Rails 4.1 removes Date.to_time_in_current_zone in favour of Date.in_time_zone
              current_date = Date.current
              current_date.respond_to?(:in_time_zone) ? current_date.in_time_zone : current_date.to_time_in_current_zone
      Severity: Minor
      Found in lib/schedule_attributes/time_helpers.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

      Severity
      Category
      Status
      Source
      Language