Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Code convention/"hint" to reduce excessive Feature Envy

#28

Just brain dumping here but how about if reek saw this:

class FarmYard
  attr_reader :cow, :duck, :pig
  
  def ==(other_farm_yard)
    cow == other_farm_yard.cow &&
      duck == other_farm_yard.duck
  end

  def foot_and_mouth(thing)
    cow.feed_to(thing.pig)
    duck.feed_to(thing.pig)
  end
end

it ignored the feature envy in #== because it could see the class name inflected in the parameter other_farm_yard but not in thing.

Not sure this is a good idea - conventions can be opaque - but this is a fairly common case.

WDYT?

Reported by Ashley Moran · March 8th, 2009 @ 04:30 PM

State: resolved
Milestone: none
Assigned to: Kevin Rutherford Kevin Rutherford

Activity

  1. Kevin Rutherford
    Kevin Rutherford
    • Assigned user set to Kevin Rutherford
    • Tag set to defect

    In this case I believe the reports of Feature Envy are all fallacious. This is a defect.

    March 8th, 2009 @ 07:31 PM

  2. Kevin Rutherford
    Kevin Rutherford

    Defect has appeared because recent version of ParseTree now renders local method calls differently.

    March 8th, 2009 @ 07:40 PM

  3. Kevin Rutherford
    Kevin Rutherford
    • State changed from new to resolved

    (from [09de77b4e1a0e048f0936a19626122cc2e7570fc]) Fixed false reports of FeatureEnvy [#28 Code convention/"hint" to reduce excessive Feature Envy state:resolved] http://github.com/kevinrutherfor...

    March 10th, 2009 @ 08:49 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.