bikeindex/bike_index

View on GitHub
app/services/time_parser.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
94%

Method parse has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring.
Open

  def self.parse(time_str = nil, timezone_str = nil)
    return nil unless time_str.present?
    return time_str if time_str.is_a?(Time)
    if time_str.is_a?(Integer) || time_str.is_a?(Float) || time_str.to_s.strip.match(/^\d+\z/) # it's only numbers
      return parse("#{time_str}-01-01") if time_str.to_s.length == 4 # Looks a year, valid 8601 format
Severity: Minor
Found in app/services/time_parser.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

Avoid too many return statements within this method.
Open

    return nil unless new_str.split("-").first.to_i.between?(EARLIEST_YEAR, LATEST_YEAR)
Severity: Major
Found in app/services/time_parser.rb - About 30 mins to fix

    There are no issues that match your filters.

    Category
    Status