SebastianEdwards/time-interval

View on GitHub

Showing 4 of 6 total issues

Method parse has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse(duration_str)
      if duration_str['PT']
        date_str = nil
        time_str = duration_str
      else
Severity: Minor
Found in lib/time_interval/duration.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 subtract_from has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def subtract_from(time)
      time -= years.years if years > 0
      time -= months.months if months > 0
      time -= weeks.weeks if weeks > 0
      time -= days.days if days > 0
Severity: Minor
Found in lib/time_interval/duration.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 add_to has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def add_to(time)
      time += years.years if years > 0
      time += months.months if months > 0
      time += weeks.weeks if weeks > 0
      time += days.days if days > 0
Severity: Minor
Found in lib/time_interval/duration.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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def parse(iso8601)
    if interval? iso8601
      if repeating?(iso8601) && duration?(iso8601)
        RepeatingInterval.parse iso8601
      elsif duration? iso8601
Severity: Minor
Found in lib/time_interval.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

Severity
Category
Status
Source
Language