Skip to content

Commit

Permalink
Merge pull request #2122 from jonas054/2113_extra_spacing_crash
Browse files Browse the repository at this point in the history
[Fix #2113] Handle non-string tokens in ExtraSpacing
  • Loading branch information
bbatsov committed Aug 8, 2015
2 parents 49339c5 + 77d21c3 commit a4ca6e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [#2105](https://github.com/bbatsov/rubocop/pull/2105): Fix a warning that was thrown when enabling `Style/OptionHash`. ([@wli][])
* [#2107](https://github.com/bbatsov/rubocop/pull/2107): Fix auto-correct of `Style/ParallelAssignment` for nested expressions. ([@rrosenblum][])
* [#2111](https://github.com/bbatsov/rubocop/issues/2111): Deal with byte order mark in `Style/InitialIndentation`. ([@jonas054][])
* [#2113](https://github.com/bbatsov/rubocop/issues/2113): Handle non-string tokens in `Style/ExtraSpacing`. ([@jonas054][])

## 0.33.0 (05/08/2015)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/extra_spacing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def aligned_assignments?(token, line)
end

def aligned_same_character?(token, line)
line[token.pos.column] == token.text[0]
line[token.pos.column] == token.text.to_s[0]
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/rubocop/cop/style/extra_spacing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
expect(cop.offenses.size).to eq(1)
end

it 'can handle extra space before a float' do
source = ['{:a => "a",',
' :b => [nil, 2.5]}']
inspect_source(cop, source)
expect(cop.offenses.size).to eq(1)
end

it 'gives the correct line' do
inspect_source(cop, ['class A < String',
'end'])
Expand Down

0 comments on commit a4ca6e5

Please sign in to comment.