sanger/sequencescape

View on GitHub
lib/accession/accession/tag_list.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Accession::TagList#extract contains iterators nested 2 deep
Open

        tags.keys.each do |key|
Severity: Minor
Found in lib/accession/accession/tag_list.rb by reek

A Nested Iterator occurs when a block contains another block.

Example

Given

class Duck
  class << self
    def duck_names
      %i!tick trick track!.each do |surname|
        %i!duck!.each do |last_name|
          puts "full name is #{surname} #{last_name}"
        end
      end
    end
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [5]:Duck#duck_names contains iterators nested 2 deep (NestedIterators)

Accession::TagList#by_group contains iterators nested 2 deep
Open

        .tap { |result| tags.values.each { |tag| tag.groups.each { |group| result[group] << tag } } }
Severity: Minor
Found in lib/accession/accession/tag_list.rb by reek

A Nested Iterator occurs when a block contains another block.

Example

Given

class Duck
  class << self
    def duck_names
      %i!tick trick track!.each do |surname|
        %i!duck!.each do |last_name|
          puts "full name is #{surname} #{last_name}"
        end
      end
    end
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [5]:Duck#duck_names contains iterators nested 2 deep (NestedIterators)

Accession::TagList#extract calls 'tags[key]' 2 times
Open

          value = tags[key].value_for(record, key)
          tag_list.add(tags[key].dup.add_value(value)) if value.present?
Severity: Minor
Found in lib/accession/accession/tag_list.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Complex method Accession::TagList#extract (22.5)
Open

    def extract(record)
      TagList.new do |tag_list|
        tags.keys.each do |key|
          value = tags[key].value_for(record, key)
          tag_list.add(tags[key].dup.add_value(value)) if value.present?
Severity: Minor
Found in lib/accession/accession/tag_list.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Accession::TagList#groups is a writable attribute
Open

    attr_accessor :groups
Severity: Minor
Found in lib/accession/accession/tag_list.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

Accession::TagList#factory_class_for doesn't depend on instance state (maybe move it to another class?)
Open

    def factory_class_for(tag_yaml)
Severity: Minor
Found in lib/accession/accession/tag_list.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Accession::TagList#add_tags has the variable name 'k'
Open

      tags.each { |k, tag| add(tag.is_a?(Accession::Tag) ? add(tag) : build_tag(tag, k)) }
Severity: Minor
Found in lib/accession/accession/tag_list.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

There are no issues that match your filters.

Category
Status