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/MixinGrouping registers offense for rspec's include-expectation #4172

Closed
andreaswachowski opened this issue Mar 26, 2017 · 4 comments
Closed
Labels

Comments

@andreaswachowski
Copy link
Contributor

The new Style/MixinGrouping incorrectly registers an offense when rspec's include-expectation is used with multiple elements.


Expected behavior

Rubocop does not register an offense.

Actual behavior

Rubocop registers an offense.

Steps to reproduce the problem

Create the following file, e.g. as mixin_grouping_spec.rb:

require 'rspec'

describe 'rubocop Style/MixinGrouping' do
  it 'should not register an offense for rspec-include' do
    expect([1, 2, 3]).to include(1, 2)
  end
end

Call rubocop mixin_grouping_spec.rb:

$ rubocop mixin_grouping_spec.rb
Inspecting 1 file
C

Offenses:

mixin_grouping_spec.rb:5:26: C: Put include mixins in separate statements.
    expect([1, 2, 3]).to include(1, 2)
                         ^^^^^^^^^^^^^

1 file inspected, 1 offense detected

RuboCop version

$ rubocop -V
0.48.0 (using Parser 2.4.0.0, running on ruby 2.4.0 x86_64-darwin16)
@tagliala
Copy link
Contributor

Another false positive:

  config.include Mongoid::Matchers, type: :model

sinsoku added a commit to sinsoku/rubocop that referenced this issue Mar 27, 2017
@bbatsov bbatsov added the bug label Mar 28, 2017
Drenmi added a commit to Drenmi/rubocop that referenced this issue Mar 28, 2017
This cop would register an offense when one of the methods `#include`,
`#extend`, or `#prepend` was sent to an explicit receiver, or used as an
argument to another method.

This change fixes that.
@tagliala
Copy link
Contributor

Hi, I think the something is happening for extend

lib/client_side_validations/active_record.rb:8:1: C: Style/MixinGrouping: Put extend mixins in separate statements.
ClientSideValidations::Extender.extend 'ActiveRecord', %w(Uniqueness)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@Drenmi
Copy link
Collaborator

Drenmi commented Mar 31, 2017

@tagliala: It is fixed for all methods on master, but it is has not gone into any release yet. 🙂

@tagliala
Copy link
Contributor

tagliala commented Mar 31, 2017

@Drenmi thanks for answering.

I'm pretty confident I'm using master branch

Using rubocop 0.48.0 from git://github.com/bbatsov/rubocop.git (at master@e50e7ad)

$ bundle exec rubocop -d
For ~/dev/client_side_validations: configuration from ~/dev/client_side_validations/.rubocop.yml
Default configuration from ~/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-e50e7ad6356b/config/default.yml
Inheriting configuration from ~/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-e50e7ad6356b/config/enabled.yml
Inheriting configuration from ~/.rvm/gems/ruby-2.4.1/bundler/gems/rubocop-e50e7ad6356b/config/disabled.yml

[...]

Offenses:

lib/client_side_validations/active_record.rb:8:1: W: Lint/UnneededDisable: Unnecessary disabling of Style/MixinGrouping.
# rubocop:disable Style/MixinGrouping
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

edit: Please ignore me, it's fixed 👍 :)

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

4 participants