sealink/timely

View on GitHub

Showing 25 of 25 total issues

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

      def to_s
         "every " + duration.parts.
                      reduce(::Hash.new(0)) { |h,(l,r)| h[l] += r; h }.
                      sort_by {|unit,  _ | [:years, :months, :days, :minutes, :seconds].index(unit)}.
                      map     {|unit, val| "#{val} #{val == 1 ? unit.to_s.chop : unit.to_s}" if val.nonzero?}.compact.
Severity: Minor
Found in lib/timely/temporal_patterns/frequency.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 condition_intervals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def condition_intervals(datetimes, &block)
          return [] if datetimes.blank? || !block_given?
          datetimes = datetimes.clone
          current_datetime = first_datetime = datetimes.shift
          last_datetime = nil
Severity: Minor
Found in lib/timely/temporal_patterns/finder.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 validate_range has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.validate_range(first, last)
      raise ArgumentError, 'Date range missing start date' if first.nil?
      raise ArgumentError, 'Date range missing end date' if last.nil?
      raise ArgumentError, 'Start date is not a date' unless first.is_a? Date
      raise ArgumentError, 'End date is not a date' unless last.is_a? Date
Severity: Minor
Found in lib/timely/date_range.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 to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_s
      str = start_date && end_date ? (start_date..end_date).to_date_range.to_s : (start_date || end_date).to_s
      str += " on #{weekdays}" unless weekdays.all_days?
      str
    end
Severity: Minor
Found in lib/timely/rails/date_group.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 best_pattern has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def best_pattern(frequency_patterns)
          best_fit = nil
          frequency_patterns.each do |pattern_hash|
            if best_fit.nil? ||
                (best_fit[:intervals].count < pattern_hash[:intervals].count) ||
Severity: Minor
Found in lib/timely/temporal_patterns/finder.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