Skip to content

Commit

Permalink
fix hanging while auto correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroyuki Sato committed Mar 24, 2014
1 parent b380236 commit 9d1a76c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* [#914](https://github.com/bbatsov/rubocop/issues/914): Fixed rdoc error during gem installation. ([@bbatsov][])
* The `--only` option now enables the given cop in case it is disabled in configuration. ([@jonas054][])
* Fix path resolution so that the default exclusion of `vendor` directories works. ([@jonas054][])
* [#908](https://github.com/bbatsov/rubocop/issues/908): Fixed hanging while auto correct for `SpaceAfterComma` and `SpaceInsideBrackets`. ([@hiroponz][])

## 0.19.1 (17/03/2014)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/space_after_punctuation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def investigate(processed_source)
processed_source.tokens.each_cons(2) do |t1, t2|
if kind(t1) && t1.pos.line == t2.pos.line &&
t2.pos.column == t1.pos.column + offset(t1) &&
t2.type != :tRPAREN
![:tRPAREN, :tRBRACK].include?(t2.type)
add_offense(t1, t1.pos, format(MSG, kind(t1)))
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/rubocop/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,19 @@ def abs(path)
'some_method(a,)',
''].join("\n"))
end

it 'should not hang SpaceAfterPunctuation and SpaceInsideBrackets' do
create_file('example.rb',
['# encoding: utf-8',
'puts [1, ]'])
Timeout.timeout(10) do
expect(cli.run(%w(--auto-correct))).to eq(1)
end
expect($stderr.string).to eq('')
expect(IO.read('example.rb')).to eq(['# encoding: utf-8',
'puts [1,]',
''].join("\n"))
end
end

describe '--auto-gen-config' do
Expand Down

0 comments on commit 9d1a76c

Please sign in to comment.