GitHub PullRequestReviewCommentEvent at 2014-05-11 07:46:27
Repository: rubocop
Actor: bbatsov
Payload: {"comment":{"url":"https://api.github.com/repos/bbatsov/rubocop/pulls/comments/12507804","id":12507804,"diff_hunk":"@@ -0,0 +1,75 @@\n+# encoding: utf-8\n+\n+require 'spec_helper'\n+\n+describe Rubocop::Cop::Style::NewlineAfterMultilineBlockStart do\n+  subject(:cop) { described_class.new }\n+\n+  it 'registers an offense when newline is absent for block without params' do\n+    inspect_source(cop,\n+                   ['test do foo',\n+                    'end'\n+                   ])\n+    expect(cop.messages)\n+      .to eq(['expression at 1, 8 is on the same line as the block start'])\n+  end\n+\n+  it 'registers an offense when newline is absent for block with params' do\n+    inspect_source(cop,\n+                   ['test do |x| foo',\n+                    'end'\n+                   ])\n+    expect(cop.messages)\n+      .to eq(['expression at 1, 12 is on the same line as the block start'])\n+  end\n+\n+  it 'does not register an offense for one-line blocks' do\n+    inspect_source(cop, 'test do foo end')\n+    expect(cop.offenses).to be_empty\n+  end\n+\n+  it 'does not register offenses when there is a newline' do\n+    inspect_source(cop,\n+                   ['test do',\n+                    '  foo',\n+                    'end'\n+                   ])\n+    expect(cop.offenses).to be_empty\n+  end\n+\n+  it 'registers offenses for lambdas as expected' do\n+    inspect_source(cop,\n+                   ['-> (x) do foo',\n+                    '  bar',\n+                    'end'\n+                   ])\n+    expect(cop.messages)\n+      .to eq(['expression at 1, 10 is on the same line as the block start'])\n+  end\n+\n+  it 'auto-corrects when the do/ end statements are not separated from the\n+  block contents with newlines' do\n+    src = ['test do |foo| bar',\n+           'end']\n+\n+    new_source = autocorrect_source(cop, src)\n+\n+    expect(new_source).to eq(['test do |foo| ',\n+                              '  bar',\n+                              'end'].join(\"\\n\"))\n+  end\n+\n+  it 'autocorrects in more complex case with lambda and assignment, and '\\\n+     'aligns the next line two spaces out from the start of the block' do\n+    src = ['x = -> (y) { foo',\n+           '  bar',\n+           '}']\n+\n+    new_source = autocorrect_source(cop, src)\n+\n+    expect(new_source).to eq(['x = -> (y) { ',","path":"spec/rubocop/cop/style/newline_after_multiline_block_start_spec.rb","position":70,"original_position":70,"commit_id":"9be091b9aaba1b236f82f4c70b2d2318782cd1e4","original_commit_id":"9be091b9aaba1b236f82f4c70b2d2318782cd1e4","user":{"login":"bbatsov","id":103882,"avatar_url":"https://avatars.githubusercontent.com/u/103882?","gravatar_id":"7710f41976a45c0b25deaf0f2a4577bc","url":"https://api.github.com/users/bbatsov","html_url":"https://github.com/bbatsov","followers_url":"https://api.github.com/users/bbatsov/followers","following_url":"https://api.github.com/users/bbatsov/following{/other_user}","gists_url":"https://api.github.com/users/bbatsov/gists{/gist_id}","starred_url":"https://api.github.com/users/bbatsov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbatsov/subscriptions","organizations_url":"https://api.github.com/users/bbatsov/orgs","repos_url":"https://api.github.com/users/bbatsov/repos","events_url":"https://api.github.com/users/bbatsov/events{/privacy}","received_events_url":"https://api.github.com/users/bbatsov/received_events","type":"User","site_admin":false},"body":"Ideally the auto-correct would remove the ` ` after `{` and indent the expression accordingly. It's true that block-alignment would auto-correct the second problem, but still...","created_at":"2014-05-11T07:46:27Z","updated_at":"2014-05-11T07:46:27Z","html_url":"https://github.com/bbatsov/rubocop/pull/1079#discussion_r12507804","pull_request_url":"https://api.github.com/repos/bbatsov/rubocop/pulls/1079","_links":{"self":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/comments/12507804"},"html":{"href":"https://github.com/bbatsov/rubocop/pull/1079#discussion_r12507804"},"pull_request":{"href":"https://api.github.com/repos/bbatsov/rubocop/pulls/1079"}}}}