{"action":"created","issue":{"url":"https://api.github.com/repos/troessner/reek/issues/681","labels_url":"https://api.github.com/repos/troessner/reek/issues/681/labels{/name}","comments_url":"https://api.github.com/repos/troessner/reek/issues/681/comments","events_url":"https://api.github.com/repos/troessner/reek/issues/681/events","html_url":"https://github.com/troessner/reek/issues/681","id":104275288,"number":681,"title":"UtilityFunction should not complain method that works inside an interator","user":{"login":"isaiah","id":18042,"avatar_url":"https://avatars.githubusercontent.com/u/18042?v=3","gravatar_id":"","url":"https://api.github.com/users/isaiah","html_url":"https://github.com/isaiah","followers_url":"https://api.github.com/users/isaiah/followers","following_url":"https://api.github.com/users/isaiah/following{/other_user}","gists_url":"https://api.github.com/users/isaiah/gists{/gist_id}","starred_url":"https://api.github.com/users/isaiah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaiah/subscriptions","organizations_url":"https://api.github.com/users/isaiah/orgs","repos_url":"https://api.github.com/users/isaiah/repos","events_url":"https://api.github.com/users/isaiah/events{/privacy}","received_events_url":"https://api.github.com/users/isaiah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-09-01T14:10:52Z","updated_at":"2015-09-02T17:56:02Z","closed_at":null,"body":"The `UtilityFunction` smell could be misleading, e.g.\r\n\r\n```ruby\r\n# Just for Fun\r\nclass Fun\r\n  attr_accessor :arr\r\n\r\n  def bar\r\n    arr.each do |a_variable|\r\n      # This is an intermediate state, should not be communicated as\r\n      # an instance variable, as reek suggests\r\n      b_variable = process(a_variable)\r\n      puts b_variable\r\n    end\r\n  end\r\n\r\n  private\r\n\r\n  def process(x_variable)\r\n    x_variable + 1\r\n  end\r\nend\r\n```\r\n\r\n```shell\r\nreek fun.rb\r\n=> fun.rb -- 1 warning:\r\n=>   [16]:Fun#process doesn't depend on instance state (UtilityFunction)\r\n```\r\n\r\nIt is useful most of the time, but for method that process an intermediate state, create a instance variable is not the right way."},"comment":{"url":"https://api.github.com/repos/troessner/reek/issues/comments/137190344","html_url":"https://github.com/troessner/reek/issues/681#issuecomment-137190344","issue_url":"https://api.github.com/repos/troessner/reek/issues/681","id":137190344,"user":{"login":"isaiah","id":18042,"avatar_url":"https://avatars.githubusercontent.com/u/18042?v=3","gravatar_id":"","url":"https://api.github.com/users/isaiah","html_url":"https://github.com/isaiah","followers_url":"https://api.github.com/users/isaiah/followers","following_url":"https://api.github.com/users/isaiah/following{/other_user}","gists_url":"https://api.github.com/users/isaiah/gists{/gist_id}","starred_url":"https://api.github.com/users/isaiah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaiah/subscriptions","organizations_url":"https://api.github.com/users/isaiah/orgs","repos_url":"https://api.github.com/users/isaiah/repos","events_url":"https://api.github.com/users/isaiah/events{/privacy}","received_events_url":"https://api.github.com/users/isaiah/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T17:56:02Z","updated_at":"2015-09-02T17:56:02Z","body":"Let's put it the other way, please tell me how the code suggested by reek is acceptable.\r\n\r\n```ruby\r\n# Just for Fun\r\nclass Fun\r\n  attr_accessor :arr\r\n\r\n  def bar\r\n    arr.each do |a_variable|\r\n      @x_variable = avariable\r\n      b_variable = process\r\n      puts b_variable\r\n    end\r\n  end\r\n\r\n  private\r\n\r\n  def process\r\n    @x_variable + 1\r\n  end\r\nend\r\n```\r\n\r\nI saw this code in real code base, and it's there basically to conform reek. "}}