geminabox/geminabox

View on GitHub
lib/geminabox/gem_version.rb

Summary

Maintainability
A
45 mins
Test Coverage
A
100%

Method <=> has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Confirmed

    def <=>(other)
      sort = other.name <=> name
      sort = version <=>  other.version       if sort.zero?
      sort = (other.ruby? && !ruby?) ? 1 : -1 if sort.zero? && ruby? != other.ruby?
      sort = other.platform <=> platform      if sort.zero?
Severity: Minor
Found in lib/geminabox/gem_version.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

Avoid the use of double negation (!!).
Open

      !!(platform =~ /ruby/i)
Severity: Minor
Found in lib/geminabox/gem_version.rb by rubocop

This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

Example:

# bad
!!something

# good
!something.nil?

Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

There are no issues that match your filters.

Category
Status