Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style/ExtraSpacing offense incorrectly triggered with unary plus in argument list #2265

Closed
tilthouse opened this issue Sep 21, 2015 · 0 comments
Assignees
Labels

Comments

@tilthouse
Copy link

Test:

    it 'can handle unary plus in an argument list' do
      source = ['assert_difference MyModel.count, +2 do',
                '  puts "a thing"',
                'end']
      inspect_source(cop, source)
      expect(cop.offenses.size).to eq(0)
    end

Result:

rspec spec/rubocop/cop/style/extra_spacing_spec.rb
Run options:
  include {:focus=>true}
  exclude {:broken=>#<Proc:./spec/spec_helper.rb:32>, :ruby_greater_than_or_equal=>#<Proc:./spec/spec_helper.rb:28>, :ruby_less_than=>#<Proc:./spec/spec_helper.rb:25>, :ruby=>#<Proc:./spec/spec_helper.rb:22>}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 30038
..F.................F...................

Failures:

  1) RuboCop::Cop::Style::ExtraSpacing when AllowForAlignment is false can handle unary plus in an argument list
     Failure/Error: expect(cop.offenses.size).to eq(0)

       expected: 0
            got: 1

       (compared using ==)
     Shared Example Group: "common behavior" called from ./spec/rubocop/cop/style/extra_spacing_spec.rb:181
     # ./spec/rubocop/cop/style/extra_spacing_spec.rb:39:in `block (3 levels) in <top (required)>'

  2) RuboCop::Cop::Style::ExtraSpacing when AllowForAlignment is true can handle unary plus in an argument list
     Failure/Error: expect(cop.offenses.size).to eq(0)

       expected: 0
            got: 1

       (compared using ==)
     Shared Example Group: "common behavior" called from ./spec/rubocop/cop/style/extra_spacing_spec.rb:164
     # ./spec/rubocop/cop/style/extra_spacing_spec.rb:39:in `block (3 levels) in <top (required)>'

Finished in 0.06017 seconds (files took 0.34958 seconds to load)
40 examples, 2 failures

Failed examples:

rspec './spec/rubocop/cop/style/extra_spacing_spec.rb[1:2:4]' # RuboCop::Cop::Style::ExtraSpacing when AllowForAlignment is false can handle unary plus in an argument list
rspec './spec/rubocop/cop/style/extra_spacing_spec.rb[1:1:4]' # RuboCop::Cop::Style::ExtraSpacing when AllowForAlignment is true can handle unary plus in an argument list

Randomized with seed 30038

Note: Normally I'd say that the unary plus here is redundant, but in this case we like it for clarity (with assert_difference in this case). In any case, it does not have extra spaces.

@jonas054 jonas054 self-assigned this Sep 22, 2015
@jonas054 jonas054 added the bug label Sep 22, 2015
bbatsov added a commit that referenced this issue Oct 5, 2015
jonas054 added a commit that referenced this issue Oct 14, 2015
Fix reference to #2265.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants