bio-miga/miga

View on GitHub
lib/miga/result.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
91%

Class has too many lines. [129/100]
Open

class MiGA::Result < MiGA::MiGA
  include MiGA::Result::Dates
  include MiGA::Result::Source
  include MiGA::Result::Stats
  include MiGA::Result::Versions
Severity: Minor
Found in lib/miga/result.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class Result has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class MiGA::Result < MiGA::MiGA
  include MiGA::Result::Dates
  include MiGA::Result::Source
  include MiGA::Result::Stats
  include MiGA::Result::Versions
Severity: Minor
Found in lib/miga/result.rb - About 2 hrs to fix

Method has too many lines. [14/10]
Open

  def each_file(&blk)
    return to_enum(:each_file) unless block_given?

    @data[:files] ||= {}
    self[:files].each do |k, files|
Severity: Minor
Found in lib/miga/result.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for each_file is too high. [15.94/15]
Open

  def each_file(&blk)
    return to_enum(:each_file) unless block_given?

    @data[:files] ||= {}
    self[:files].each do |k, files|
Severity: Minor
Found in lib/miga/result.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method each_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def each_file(&blk)
    return to_enum(:each_file) unless block_given?

    @data[:files] ||= {}
    self[:files].each do |k, files|
Severity: Minor
Found in lib/miga/result.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def create(path, force = false)
      # Deal with old results first
      r_old = load(path)
      return r_old if r_old && !force

Severity: Minor
Found in lib/miga/result.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

Use yield instead of blk.call.
Open

        when 2 then blk.call(k, file)
Severity: Minor
Found in lib/miga/result.rb by rubocop

This cop identifies the use of a &block parameter and block.call where yield would do just as well.

Example:

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

Use yield instead of blk.call.
Open

        when 3 then blk.call(k, file, File.expand_path(file, dir))
Severity: Minor
Found in lib/miga/result.rb by rubocop

This cop identifies the use of a &block parameter and block.call where yield would do just as well.

Example:

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

Use yield instead of blk.call.
Open

        when 1 then blk.call(file)
Severity: Minor
Found in lib/miga/result.rb by rubocop

This cop identifies the use of a &block parameter and block.call where yield would do just as well.

Example:

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

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

    !!self[:recalculate]
Severity: Minor
Found in lib/miga/result.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.

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

    !!self[:clean]
Severity: Minor
Found in lib/miga/result.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.

Trailing whitespace detected.
Open

    # JSON in +path+ if any, but it can rescue the versions 
Severity: Minor
Found in lib/miga/result.rb by rubocop

There are no issues that match your filters.

Category
Status