laserlemon/vestal_versions

View on GitHub

Showing 4 of 4 total issues

Method restore has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def restore
      if tag == 'deleted'
        attrs = modifications

        class_name = attrs['type'].blank? ? versioned_type : attrs['type']
Severity: Minor
Found in lib/vestal_versions/version.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 changes_between has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def changes_between(from, to)
            from_number, to_number = versions.number_at(from), versions.number_at(to)
            return {} if from_number == to_number
            chain = versions.between(from_number, to_number).reject(&:initial?)
            return {} if chain.empty?
Severity: Minor
Found in lib/vestal_versions/changes.rb - About 55 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 number_at has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def number_at(value)
      case value
        when Date, Time then (v = at(value)) ? v.number : 1
        when Numeric then value.floor
        when String, Symbol then (v = at(value)) ? v.number : nil
Severity: Minor
Found in lib/vestal_versions/versions.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 between has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def between(from, to)
      from_number, to_number = number_at(from), number_at(to)
      return [] if from_number.nil? || to_number.nil?

      condition = (from_number == to_number) ? to_number : Range.new(*[from_number, to_number].sort)
Severity: Minor
Found in lib/vestal_versions/versions.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