bogdanRada/enhanced_date_select

View on GitHub

Showing 3 of 3 total issues

Method reset_options_enhanced has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def reset_options_enhanced(order)
          @options[:discard_hour] = true
          @options[:discard_minute] = true
          @options[:discard_second] = true
          @options[:discard_year] ||= true unless order.include?(:year)
Severity: Minor
Found in lib/enhanced_date_select.rb - 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

Method enhanced_select_date has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def enhanced_select_date
          order = date_order.dup
          reset_options_enhanced(order)
          # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are valid (otherwise it could be 31 and February wouldn't be a valid date)
          if @datetime && @options[:discard_day] && !@options[:discard_month]
Severity: Minor
Found in lib/enhanced_date_select.rb - 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

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

        def enhanced_datetime_selector(options, html_options)
          datetime = options[:value] || value(object) || default_datetime(options)

          @auto_index ||= nil

Severity: Minor
Found in lib/enhanced_date_select.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