vegantech/sims

View on GitHub
lib/unobtrusive_date_picker/unobtrusive_date_picker.rb

Summary

Maintainability
C
1 day
Test Coverage

File unobtrusive_date_picker.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module UnobtrusiveDatePicker
  
  DATEPICKER_DEFAULT_NAME_ID_SUFFIXES = { :year  => {:id => '',   :name => 'year'},
                                          :month => {:id => 'mm', :name => 'month'},
                                          :day   => {:id => 'dd', :name => 'day'} }
Severity: Minor
Found in lib/unobtrusive_date_picker/unobtrusive_date_picker.rb - About 2 hrs to fix

    Method make_date_picker_class_options has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_date_picker_class_options(options)
          html_classes = []
    
          if options[:highlight_days]
            highlight_days = parse_days_of_week(options[:highlight_days])
    Severity: Minor
    Found in lib/unobtrusive_date_picker/unobtrusive_date_picker.rb - 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

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

        def parse_range_option(option, direction)
          if option.is_a? Symbol
            case option
            when :today
              range_class = 'today'
    Severity: Minor
    Found in lib/unobtrusive_date_picker/unobtrusive_date_picker.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 make_date_picker_class_options has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def make_date_picker_class_options(options)
          html_classes = []
    
          if options[:highlight_days]
            highlight_days = parse_days_of_week(options[:highlight_days])
    Severity: Minor
    Found in lib/unobtrusive_date_picker/unobtrusive_date_picker.rb - About 1 hr to fix

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

            def input_id_from_type(type, html_options_id = nil)
              if html_options_id.blank?
                prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
                prefix += "_#{@options[:index]}" if @options.has_key?(:index)
                prefix += "_#{@options[:field_name]}" if @options.has_key?(:field_name)
      Severity: Minor
      Found in lib/unobtrusive_date_picker/unobtrusive_date_picker.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 datepicker_selector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def datepicker_selector(options, html_options)
                datetime = value(object) || default_datetime(options)
      
                options = options.dup
                options[:field_name]           = @method_name
      Severity: Minor
      Found in lib/unobtrusive_date_picker/unobtrusive_date_picker.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

      There are no issues that match your filters.

      Category
      Status