Flockingbird/roost

View on GitHub
test/support/shared/attribute_behaviour.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

AttributeBehaviour::ClassMethods takes parameters ['attribute', 'method'] to 4 methods
Invalid

    def it_behaves_as_attribute_setter(method, attribute, event)
      it_sets_attribute(method, attribute)
      it_sends_event_on_change(method, attribute, event)
      it_omits_event_on_no_change(method, attribute, event)
    end

In general, a Data Clump occurs when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

The recurrence of the items often means there is duplicate code spread around to handle them. There may be an abstraction missing from the code, making the system harder to understand.

Example

Given

class Dummy
  def x(y1,y2); end
  def y(y1,y2); end
  def z(y1,y2); end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [2, 3, 4]:Dummy takes parameters [y1, y2] to 3 methods (DataClump)

A possible way to fix this problem (quoting from Martin Fowler):

The first step is to replace data clumps with objects and use the objects whenever you see them. An immediate benefit is that you'll shrink some parameter lists. The interesting stuff happens as you begin to look for behavior to move into the new objects.

There are no issues that match your filters.

Category
Status